diff options
author | mcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2010-05-05 15:29:01 +0000 |
---|---|---|
committer | mcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2010-05-05 15:29:01 +0000 |
commit | b1c8641a63a67e3c64d948f9e8dce5c01e11e2dd (patch) | |
tree | 0883f08a408f89f758e9a1be629232e3dd055c3a /utils/src/test/java/at/gv/egiz/slbinding | |
parent | 83a9b613836910f7edc370c2fe60fa2268dc4461 (diff) | |
download | mocca-b1c8641a63a67e3c64d948f9e8dce5c01e11e2dd.tar.gz mocca-b1c8641a63a67e3c64d948f9e8dce5c01e11e2dd.tar.bz2 mocca-b1c8641a63a67e3c64d948f9e8dce5c01e11e2dd.zip |
Merged feature branch mocca-1.2.13-id@r724 back to trunk.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@725 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'utils/src/test/java/at/gv/egiz/slbinding')
-rw-r--r-- | utils/src/test/java/at/gv/egiz/slbinding/RedirectTest.java | 55 | ||||
-rw-r--r-- | utils/src/test/java/at/gv/egiz/slbinding/UnmarshallCXSRTest.java | 53 |
2 files changed, 55 insertions, 53 deletions
diff --git a/utils/src/test/java/at/gv/egiz/slbinding/RedirectTest.java b/utils/src/test/java/at/gv/egiz/slbinding/RedirectTest.java index 7c8c206a..bdabedba 100644 --- a/utils/src/test/java/at/gv/egiz/slbinding/RedirectTest.java +++ b/utils/src/test/java/at/gv/egiz/slbinding/RedirectTest.java @@ -52,8 +52,6 @@ import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLInputFactory; import static org.junit.Assert.*; -import org.w3._2000._09.xmldsig_.TransformType; -import org.w3._2000._09.xmldsig_.TransformsType; /** * @@ -80,13 +78,6 @@ public class RedirectTest { JAXBContext jaxbContext = JAXBContext.newInstance(slPkg + ":" + dsigPkg); Unmarshaller um = jaxbContext.createUnmarshaller(); -// SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); -// File schemaFile = new File(FILENAME_REQ_SCHEMA); -// Schema TestRequestLaxSchema = schemaFactory.newSchema(schemaFile); -// // validate request -// um.setSchema(TestRequestLaxSchema); - - FileInputStream fis = new FileInputStream(FILENAME_REQ); InputStream is = new BufferedInputStream(fis); @@ -97,24 +88,13 @@ public class RedirectTest { um.setListener(new RedirectUnmarshallerListener(contentFilter)); -// List<Class> redirectTriggers = Arrays.asList(new Class[]{XMLContentType.class, TransformsType.class}); -// Set<Class<? extends RedirectCallback>> redirectTriggers = new HashSet<Class<? extends RedirectCallback>>(); //{XMLContentType.class, TransformsType.class -// redirectTriggers.add(XMLContentType.class); -// redirectTriggers.add(TransformsType.class); -// ByteArrayRedirectCallback.registerRedirectTriggers(redirectTriggers); -// -// Set<Class<? extends RedirectCallback>> preserveNSContextTriggers = new HashSet<Class<? extends RedirectCallback>>(); -//// preserveNSContextTriggers.add(TransformsType.class); -// preserveNSContextTriggers.add(SignatureInfoCreationType.SignatureLocation.class); -// ByteArrayRedirectCallback.registerPreserveContextTriggers(preserveNSContextTriggers); - - JAXBElement<CreateXMLSignatureRequestType> req = (JAXBElement<CreateXMLSignatureRequestType>) um.unmarshal(filteredReader); + JAXBElement<?> req = (JAXBElement<?>) um.unmarshal(filteredReader); is.close(); FileOutputStream fos = new FileOutputStream(FILENAME_REQ + "_redirect.txt"); OutputStream os = new BufferedOutputStream(fos); - CreateXMLSignatureRequestType request = req.getValue(); + CreateXMLSignatureRequestType request = (CreateXMLSignatureRequestType) req.getValue(); List<DataObjectInfoType> dataObjectInfos = request.getDataObjectInfo(); Iterator<DataObjectInfoType> doiIt = dataObjectInfos.iterator(); while (doiIt.hasNext()) { @@ -133,29 +113,8 @@ public class RedirectTest { Iterator<TransformsInfoType> tiIt = transformsInfos.iterator(); while (tiIt.hasNext()) { at.gv.egiz.slbinding.impl.TransformsInfoType ti = (at.gv.egiz.slbinding.impl.TransformsInfoType) tiIt.next(); -// TransformsInfoType ti = tiIt.next(); assertNotNull(ti); System.out.println("found sl:TransformsInfo: " + ti.getClass().getName()); //at.gv.egiz.slbinding.impl.TransformsInfoType TransformsInfo"); -// TransformsType ts = ti.getTransforms(); -// assertNotNull(ts); -// System.out.println("found dsig:Transforms " + ts.getClass().getName()); //org.w3._2000._09.xmldsig_.TransformsType dsig:Transforms"); -// List<TransformType> tL = ts.getTransform(); -// assertNotNull(tL); -// System.out.println("found " + tL.size() + " org.w3._2000._09.xmldsig_.TransformType dsig:Transform"); -// for (TransformType t : tL) { -// if (t instanceof at.gv.egiz.slbinding.impl.TransformType) { -// System.out.println("found at.gv.egiz.slbinding.impl.TransformType"); -// byte[] redirectedBytes = ((at.gv.egiz.slbinding.impl.TransformType) t).getRedirectedStream().toByteArray(); -// if (redirectedBytes != null && redirectedBytes.length > 0) { -// System.out.println("reading redirected stream..."); -// os.write("--- redirected Transform ---".getBytes()); -// os.write(redirectedBytes); -// os.write("\n".getBytes()); -// } else { -// System.out.println("no redirected stream"); -// } -// } -// } ByteArrayOutputStream dsigTransforms = ti.getRedirectedStream(); os.write("--- redirected TransformsInfo content ---".getBytes()); @@ -177,16 +136,6 @@ public class RedirectTest { } SignatureInfoCreationType si = request.getSignatureInfo(); if (si != null) { -// Base64XMLOptRefContentType sigEnv = si.getSignatureEnvironment(); -// XMLContentType sigEnvXML = sigEnv.getXMLContent(); -// if (sigEnvXML != null) { -// System.out.println("found SignatureEnvironment XMLContent"); -// ByteArrayOutputStream xmlContent = sigEnvXML.getRedirectedStream(); -// os.write(xmlContent.toByteArray()); -// os.write("\n".getBytes()); -// } -// -// SignatureInfoCreationType.SignatureLocation sigLocation = si.getSignatureLocation(); SignatureLocationType sigLocation = (SignatureLocationType) si.getSignatureLocation(); assertNotNull(sigLocation); System.out.println("found at.gv.egiz.slbinding.impl.SignatureLocationType SignatureLocation"); diff --git a/utils/src/test/java/at/gv/egiz/slbinding/UnmarshallCXSRTest.java b/utils/src/test/java/at/gv/egiz/slbinding/UnmarshallCXSRTest.java new file mode 100644 index 00000000..0025c312 --- /dev/null +++ b/utils/src/test/java/at/gv/egiz/slbinding/UnmarshallCXSRTest.java @@ -0,0 +1,53 @@ +/* +* Copyright 2009 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package at.gv.egiz.slbinding; + +import java.io.InputStream; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.stream.XMLStreamException; +import javax.xml.transform.stream.StreamSource; + +import org.junit.Test; + +import at.gv.egiz.slbinding.impl.CreateXMLSignatureResponseType; +import static org.junit.Assert.*; + +public class UnmarshallCXSRTest { + + @Test + public void testUnmarshallCreateXMLSignatureResponse() throws XMLStreamException, JAXBException { + + ClassLoader cl = UnmarshallCXSRTest.class.getClassLoader(); + InputStream s = cl.getResourceAsStream("at/gv/egiz/slbinding/CreateXMLSignatureResponse.xml"); + + assertNotNull(s); + + SLUnmarshaller unmarshaller = new SLUnmarshaller(); + Object object = unmarshaller.unmarshal(new StreamSource(s)); + + assertTrue(object.getClass().getName(), object instanceof JAXBElement<?>); + + Object value = ((JAXBElement<?>) object).getValue(); + + assertTrue(value.getClass().getName(), value instanceof CreateXMLSignatureResponseType); + + } + +} |