summaryrefslogtreecommitdiff
path: root/utils/src/test/java/at/gv/egiz
diff options
context:
space:
mode:
Diffstat (limited to 'utils/src/test/java/at/gv/egiz')
-rw-r--r--utils/src/test/java/at/gv/egiz/idlink/IdentityLink.java5
-rw-r--r--utils/src/test/java/at/gv/egiz/slbinding/RedirectTest.java55
-rw-r--r--utils/src/test/java/at/gv/egiz/slbinding/UnmarshallCXSRTest.java53
-rw-r--r--utils/src/test/java/at/gv/egiz/urldereferencer/FormDataTest.java96
4 files changed, 55 insertions, 154 deletions
diff --git a/utils/src/test/java/at/gv/egiz/idlink/IdentityLink.java b/utils/src/test/java/at/gv/egiz/idlink/IdentityLink.java
index a97a468e..f47d79bc 100644
--- a/utils/src/test/java/at/gv/egiz/idlink/IdentityLink.java
+++ b/utils/src/test/java/at/gv/egiz/idlink/IdentityLink.java
@@ -19,7 +19,6 @@ package at.gv.egiz.idlink;
import iaik.xml.crypto.XSecProvider;
import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.InvalidAlgorithmParameterException;
@@ -44,11 +43,7 @@ import javax.xml.crypto.MarshalException;
import javax.xml.crypto.dsig.XMLSignatureException;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
import oasis.names.tc.saml._1_0.assertion.AssertionType;
import oasis.names.tc.saml._1_0.assertion.AttributeStatementType;
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);
+
+ }
+
+}
diff --git a/utils/src/test/java/at/gv/egiz/urldereferencer/FormDataTest.java b/utils/src/test/java/at/gv/egiz/urldereferencer/FormDataTest.java
deleted file mode 100644
index ecd4c8f7..00000000
--- a/utils/src/test/java/at/gv/egiz/urldereferencer/FormDataTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
-* Copyright 2008 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.urldereferencer;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-import at.gv.egiz.bku.utils.StreamUtil;
-import at.gv.egiz.bku.utils.urldereferencer.FormDataURLSupplier;
-import at.gv.egiz.bku.utils.urldereferencer.SimpleFormDataContextImpl;
-import at.gv.egiz.bku.utils.urldereferencer.StreamData;
-import at.gv.egiz.bku.utils.urldereferencer.URLDereferencer;
-import at.gv.egiz.bku.utils.urldereferencer.URLDereferencerContext;
-
-public class FormDataTest implements FormDataURLSupplier {
-
- protected URLDereferencerContext urlCtx;
- protected InputStream testStream = null;
- protected String contentType = null;
- protected String paramName = "";
-
- @Override
- public InputStream getFormData(String parameterName) {
- if (paramName.equals(parameterName)) {
- return testStream;
- } else {
- return null;
- }
- }
-
- @Override
- public String getFormDataContentType(String parameterName) {
- if (paramName.equals(parameterName)) {
- return contentType;
- } else {
- return null;
- }
- }
-
- @Before
- public void setUp() {
- urlCtx = new SimpleFormDataContextImpl(this);
- }
-
- @Test(expected = MalformedURLException.class)
- public void testInvalidFormdataUrl() throws IOException {
- String url = "abs://whatknowi";
- StreamData sd = URLDereferencer.getInstance().dereference(url, urlCtx);
- assertNull(sd);
- url = ":://whatknowi";
- sd = URLDereferencer.getInstance().dereference(url, urlCtx);
- assertNull(sd);
- url = "";
- sd = URLDereferencer.getInstance().dereference(url, urlCtx);
- }
-
- @Test
- public void testFormData() throws IOException {
- paramName = "Müllcontainer";
- testStream = new ByteArrayInputStream("HelloWorld".getBytes("UTF-8"));
- String url = "formdata:"+paramName;
- StreamData sd = URLDereferencer.getInstance().dereference(url, urlCtx);
- assertNotNull(sd);
- String result = StreamUtil.asString(sd.getStream(), "UTF-8");
- assertEquals("HelloWorld", result);
- }
-
- @Test(expected=IOException.class)
- public void testFormDataNotFound() throws IOException {
- paramName = "Müllcontainer";
- testStream = new ByteArrayInputStream("HelloWorld".getBytes("UTF-8"));
- String url = "formdata:"+paramName+"2";
- StreamData sd = URLDereferencer.getInstance().dereference(url, urlCtx);
- }
-
-}