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 /bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl | |
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 'bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl')
4 files changed, 153 insertions, 131 deletions
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureComandImplTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureComandImplTest.java index 4e9b4cd7..4f56b423 100644 --- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureComandImplTest.java +++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureComandImplTest.java @@ -21,7 +21,6 @@ import static org.junit.Assert.assertTrue; import iaik.xml.crypto.XSecProvider; import java.io.InputStream; -import java.security.Security; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; @@ -29,41 +28,56 @@ import javax.xml.transform.stream.StreamSource; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import at.gv.egiz.bku.slcommands.CreateXMLSignatureCommand; +import at.gv.egiz.bku.slcommands.ErrorResult; import at.gv.egiz.bku.slcommands.InfoboxReadCommand; import at.gv.egiz.bku.slcommands.SLCommand; import at.gv.egiz.bku.slcommands.SLCommandContext; import at.gv.egiz.bku.slcommands.SLCommandFactory; import at.gv.egiz.bku.slcommands.SLResult; -import at.gv.egiz.bku.slcommands.impl.xsect.STALProvider; import at.gv.egiz.bku.slexceptions.SLCommandException; import at.gv.egiz.bku.slexceptions.SLRequestException; import at.gv.egiz.bku.slexceptions.SLRuntimeException; import at.gv.egiz.bku.slexceptions.SLVersionException; +import at.gv.egiz.bku.utils.urldereferencer.URLDereferencer; import at.gv.egiz.stal.STAL; -import at.gv.egiz.stal.dummy.DummySTAL; +import at.gv.egiz.stal.STALFactory; //@Ignore
public class CreateXMLSignatureComandImplTest {
- private SLCommandFactory factory;
+ protected static ApplicationContext appCtx; + private SLCommandFactory factory; + + private STAL stal; + + private URLDereferencer urlDereferencer; - private STAL stal;
-
@BeforeClass
public static void setUpClass() {
- - new ClassPathXmlApplicationContext("at/gv/egiz/bku/slcommands/testApplicationContext.xml"); -
- Security.addProvider(new STALProvider());
+ appCtx = new ClassPathXmlApplicationContext("at/gv/egiz/bku/slcommands/testApplicationContext.xml"); XSecProvider.addAsProvider(true);
}
@Before
public void setUp() {
- factory = SLCommandFactory.getInstance();
- stal = new DummySTAL();
+ Object bean = appCtx.getBean("slCommandFactory"); + assertTrue(bean instanceof SLCommandFactory); + + factory = (SLCommandFactory) bean; + + bean = appCtx.getBean("stalFactory"); + assertTrue(bean instanceof STALFactory); + + stal = ((STALFactory) bean).createSTAL(); + + bean = appCtx.getBean("urlDereferencer"); + assertTrue(bean instanceof URLDereferencer); + + urlDereferencer = (URLDereferencer) bean; + }
@Test
@@ -71,33 +85,34 @@ public class CreateXMLSignatureComandImplTest { InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/createxmlsignaturerequest/CreateXMLSignatureRequest.xml");
assertNotNull(inputStream);
- SLCommandContext context = new SLCommandContext();
- context.setSTAL(stal);
- SLCommand command = factory.createSLCommand(new StreamSource(inputStream), context);
+ SLCommand command = factory.createSLCommand(new StreamSource(inputStream));
assertTrue(command instanceof CreateXMLSignatureCommand);
- SLResult result = command.execute();
+ SLCommandContext context = new SLCommandContext(stal, urlDereferencer); + SLResult result = command.execute(context);
result.writeTo(new StreamResult(System.out), false);
}
-// @Test(expected=SLCommandException.class)
+ @Test(expected=SLCommandException.class)
public void testInfboxReadRequestInvalid1() throws SLCommandException, SLRuntimeException, SLRequestException, SLVersionException {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-1.xml");
assertNotNull(inputStream);
- SLCommandContext context = new SLCommandContext();
- SLCommand command = factory.createSLCommand(new StreamSource(inputStream), context);
+ SLCommand command = factory.createSLCommand(new StreamSource(inputStream));
assertTrue(command instanceof InfoboxReadCommand);
}
-// @Test(expected=SLCommandException.class)
+ @Test
public void testInfboxReadRequestInvalid2() throws SLCommandException, SLRuntimeException, SLRequestException, SLVersionException {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-2.xml");
assertNotNull(inputStream);
- SLCommandContext context = new SLCommandContext();
- SLCommand command = factory.createSLCommand(new StreamSource(inputStream), context);
- assertTrue(command instanceof InfoboxReadCommand);
+ SLCommand command = factory.createSLCommand(new StreamSource(inputStream));
+ assertTrue(command instanceof InfoboxReadCommandImpl); +
+ SLCommandContext context = new SLCommandContext(stal, urlDereferencer); + SLResult result = command.execute(context); + assertTrue(result instanceof ErrorResult); }
}
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadComandImplTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadComandImplTest.java index bfc784f7..814ef8a9 100644 --- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadComandImplTest.java +++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadComandImplTest.java @@ -40,18 +40,20 @@ import at.gv.egiz.bku.slexceptions.SLCommandException; import at.gv.egiz.bku.slexceptions.SLRequestException; import at.gv.egiz.bku.slexceptions.SLRuntimeException; import at.gv.egiz.bku.slexceptions.SLVersionException; +import at.gv.egiz.bku.utils.urldereferencer.URLDereferencer; import at.gv.egiz.stal.STAL; -import at.gv.egiz.stal.dummy.DummySTAL; +import at.gv.egiz.stal.STALFactory; //@Ignore
public class InfoboxReadComandImplTest {
- private static ApplicationContext appCtx; + protected static ApplicationContext appCtx; + private SLCommandFactory factory; + + private STAL stal; + + private URLDereferencer urlDereferencer; - private SLCommandFactory factory;
-
- private STAL stal;
-
@BeforeClass public static void setUpClass() { appCtx = new ClassPathXmlApplicationContext("at/gv/egiz/bku/slcommands/testApplicationContext.xml"); @@ -59,8 +61,20 @@ public class InfoboxReadComandImplTest { @Before
public void setUp() {
- factory = SLCommandFactory.getInstance();
- stal = new DummySTAL();
+ Object bean = appCtx.getBean("slCommandFactory"); + assertTrue(bean instanceof SLCommandFactory); + + factory = (SLCommandFactory) bean; + + bean = appCtx.getBean("stalFactory"); + assertTrue(bean instanceof STALFactory); + + stal = ((STALFactory) bean).createSTAL(); + + bean = appCtx.getBean("urlDereferencer"); + assertTrue(bean instanceof URLDereferencer); + + urlDereferencer = (URLDereferencer) bean; }
@Test
@@ -68,12 +82,12 @@ public class InfoboxReadComandImplTest { InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.xml");
assertNotNull(inputStream);
- SLCommandContext context = new SLCommandContext();
+ SLCommandContext context = new SLCommandContext(stal, urlDereferencer); context.setSTAL(stal);
- SLCommand command = factory.createSLCommand(new StreamSource(inputStream), context);
+ SLCommand command = factory.createSLCommand(new StreamSource(inputStream));
assertTrue(command instanceof InfoboxReadCommand);
- SLResult result = command.execute();
+ SLResult result = command.execute(context);
result.writeTo(new StreamResult(System.out), false);
}
@@ -82,9 +96,7 @@ public class InfoboxReadComandImplTest { InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-1.xml");
assertNotNull(inputStream);
- SLCommandContext context = new SLCommandContext(); - context.setSTAL(stal);
- SLCommand command = factory.createSLCommand(new StreamSource(inputStream), context);
+ SLCommand command = factory.createSLCommand(new StreamSource(inputStream));
assertTrue(command instanceof InfoboxReadCommand);
}
@@ -92,12 +104,11 @@ public class InfoboxReadComandImplTest { InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-2.xml");
assertNotNull(inputStream);
- SLCommandContext context = new SLCommandContext(); - context.setSTAL(stal);
- SLCommand command = factory.createSLCommand(new StreamSource(inputStream), context);
+ SLCommandContext context = new SLCommandContext(stal, urlDereferencer); + SLCommand command = factory.createSLCommand(new StreamSource(inputStream));
assertTrue(command instanceof InfoboxReadCommand); - SLResult result = command.execute(); + SLResult result = command.execute(context); assertTrue(result instanceof ErrorResult);
}
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImplTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImplTest.java index a17f0797..2627de72 100644 --- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImplTest.java +++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImplTest.java @@ -19,6 +19,7 @@ package at.gv.egiz.bku.slcommands.impl; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import iaik.asn1.CodingException; +import iaik.xml.crypto.XSecProvider; import java.io.IOException; import java.io.InputStream; @@ -29,7 +30,8 @@ import javax.xml.bind.Marshaller; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; -import org.junit.Ignore; +import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -47,8 +49,9 @@ import at.gv.egiz.bku.slexceptions.SLCommandException; import at.gv.egiz.bku.slexceptions.SLRequestException; import at.gv.egiz.bku.slexceptions.SLRuntimeException; import at.gv.egiz.bku.slexceptions.SLVersionException; +import at.gv.egiz.bku.utils.urldereferencer.URLDereferencer; import at.gv.egiz.stal.STAL; -import at.gv.egiz.stal.dummy.DummySTAL; +import at.gv.egiz.stal.STALFactory; //@Ignore
public class SVPersonendatenInfoboxImplTest {
@@ -70,22 +73,37 @@ public class SVPersonendatenInfoboxImplTest { (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x5a }; - private static ApplicationContext appCtx; + protected static ApplicationContext appCtx; + private SLCommandFactory factory; + + private STAL stal; - private SLCommandFactory factory;
-
- private STAL stal;
-
-// @BeforeClass + private URLDereferencer urlDereferencer; + + @BeforeClass public static void setUpClass() { appCtx = new ClassPathXmlApplicationContext("at/gv/egiz/bku/slcommands/testApplicationContext.xml"); + XSecProvider.addAsProvider(true); } + + @Before + public void setUp() { + Object bean = appCtx.getBean("slCommandFactory"); + assertTrue(bean instanceof SLCommandFactory); + + factory = (SLCommandFactory) bean; + + bean = appCtx.getBean("stalFactory"); + assertTrue(bean instanceof STALFactory); + + stal = ((STALFactory) bean).createSTAL(); + + bean = appCtx.getBean("urlDereferencer"); + assertTrue(bean instanceof URLDereferencer); + + urlDereferencer = (URLDereferencer) bean; -// @Before
- public void setUp() {
- factory = SLCommandFactory.getInstance();
- stal = new DummySTAL();
- }
+ } @Test public void testEHIC() throws SLCommandException, JAXBException, CodingException, IOException { @@ -102,44 +120,38 @@ public class SVPersonendatenInfoboxImplTest { } - @Ignore
@Test
public void testInfboxReadRequest() throws SLCommandException, SLRuntimeException, SLRequestException, SLVersionException {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.xml");
assertNotNull(inputStream);
- SLCommandContext context = new SLCommandContext();
- context.setSTAL(stal);
- SLCommand command = factory.createSLCommand(new StreamSource(inputStream), context);
+ SLCommandContext context = new SLCommandContext(stal, urlDereferencer);
+ SLCommand command = factory.createSLCommand(new StreamSource(inputStream));
assertTrue(command instanceof InfoboxReadCommand);
- SLResult result = command.execute();
+ SLResult result = command.execute(context);
result.writeTo(new StreamResult(System.out), false);
}
- @Ignore
@Test(expected=SLCommandException.class)
public void testInfboxReadRequestInvalid1() throws SLCommandException, SLRuntimeException, SLRequestException, SLVersionException {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-1.xml");
assertNotNull(inputStream);
- SLCommandContext context = new SLCommandContext(); - context.setSTAL(stal);
- SLCommand command = factory.createSLCommand(new StreamSource(inputStream), context);
+ SLCommand command = factory.createSLCommand(new StreamSource(inputStream));
assertTrue(command instanceof InfoboxReadCommand);
}
- @Ignore
+ @Test
public void testInfboxReadRequestInvalid2() throws SLCommandException, SLRuntimeException, SLRequestException, SLVersionException {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-2.xml");
assertNotNull(inputStream);
- SLCommandContext context = new SLCommandContext(); - context.setSTAL(stal);
- SLCommand command = factory.createSLCommand(new StreamSource(inputStream), context);
+ SLCommandContext context = new SLCommandContext(stal, urlDereferencer); + SLCommand command = factory.createSLCommand(new StreamSource(inputStream));
assertTrue(command instanceof InfoboxReadCommand); - SLResult result = command.execute(); + SLResult result = command.execute(context); assertTrue(result instanceof ErrorResult);
}
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureTest.java index 0a34c8f3..6a413483 100644 --- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureTest.java +++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/xsect/SignatureTest.java @@ -73,14 +73,11 @@ import at.gv.egiz.bku.slexceptions.SLRequestException; import at.gv.egiz.bku.slexceptions.SLViewerException; import at.gv.egiz.bku.utils.urldereferencer.StreamData; import at.gv.egiz.bku.utils.urldereferencer.URLDereferencer; -import at.gv.egiz.bku.utils.urldereferencer.URLDereferencerContext; +import at.gv.egiz.bku.utils.urldereferencer.URLDereferencerImpl; import at.gv.egiz.bku.utils.urldereferencer.URLProtocolHandler; import at.gv.egiz.dom.DOMUtils; import at.gv.egiz.slbinding.RedirectEventFilter; import at.gv.egiz.slbinding.RedirectUnmarshallerListener; -import org.junit.Ignore; -import org.w3c.dom.NodeList; -import static org.junit.Assert.*; public class SignatureTest { @@ -135,6 +132,8 @@ public class SignatureTest { private static X509Certificate certificate; + private static URLDereferencer urlDereferencer; + @BeforeClass public static void setUpClass() throws JAXBException, NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException, UnrecoverableKeyException { @@ -161,14 +160,16 @@ public class SignatureTest { certificate = (X509Certificate) keystore.getCertificate(firstAlias); privateKey = (PrivateKey) keystore.getKey(firstAlias, passwd); + urlDereferencer = URLDereferencerImpl.getInstance(); + } private static void initURLDereferencer() { - URLDereferencer.getInstance().registerHandler("testlocal", new URLProtocolHandler() { + URLDereferencerImpl.getInstance().registerHandler("testlocal", new URLProtocolHandler() { @Override - public StreamData dereference(String url, URLDereferencerContext context) + public StreamData dereference(String url) throws IOException { ClassLoader classLoader = SignatureTest.class.getClassLoader(); @@ -237,12 +238,11 @@ public class SignatureTest { // // - @SuppressWarnings("unchecked") private SignatureInfoCreationType unmarshalSignatureInfo(String file) throws JAXBException, XMLStreamException { Object object = unmarshal(file); - Object requestType = ((JAXBElement) object).getValue(); + Object requestType = ((JAXBElement<?>) object).getValue(); assertTrue(requestType instanceof CreateXMLSignatureRequestType); @@ -259,7 +259,7 @@ public class SignatureTest { SignatureInfoCreationType signatureInfo = unmarshalSignatureInfo("SignatureInfo_Base64_1.xml"); - Signature signature = new Signature(null, new IdValueFactoryImpl(), null); + Signature signature = new Signature(urlDereferencer, new IdValueFactoryImpl(), null); signature.setSignatureInfo(signatureInfo); @@ -281,7 +281,7 @@ public class SignatureTest { SignatureInfoCreationType signatureInfo = unmarshalSignatureInfo("SignatureInfo_Base64_2.xml"); - Signature signature = new Signature(null, new IdValueFactoryImpl(), null); + Signature signature = new Signature(urlDereferencer, new IdValueFactoryImpl(), null); signature.setSignatureInfo(signatureInfo); @@ -301,7 +301,7 @@ public class SignatureTest { SignatureInfoCreationType signatureInfo = unmarshalSignatureInfo("SignatureInfo_Base64_3.xml"); - Signature signature = new Signature(null, new IdValueFactoryImpl(), null); + Signature signature = new Signature(urlDereferencer, new IdValueFactoryImpl(), null); signature.setSignatureInfo(signatureInfo); @@ -321,7 +321,7 @@ public class SignatureTest { SignatureInfoCreationType signatureInfo = unmarshalSignatureInfo("SignatureInfo_XMLContent_1.xml"); - Signature signature = new Signature(null, new IdValueFactoryImpl(), null); + Signature signature = new Signature(urlDereferencer, new IdValueFactoryImpl(), null); signature.setSignatureInfo(signatureInfo); @@ -341,7 +341,7 @@ public class SignatureTest { SignatureInfoCreationType signatureInfo = unmarshalSignatureInfo("SignatureInfo_Reference_1.xml"); - Signature signature = new Signature(null, new IdValueFactoryImpl(), null); + Signature signature = new Signature(urlDereferencer, new IdValueFactoryImpl(), null); signature.setSignatureInfo(signatureInfo); @@ -362,12 +362,11 @@ public class SignatureTest { // // - @SuppressWarnings("unchecked") private List<DataObjectInfoType> unmarshalDataObjectInfo(String file) throws JAXBException, XMLStreamException { Object object = unmarshal(file); - Object requestType = ((JAXBElement) object).getValue(); + Object requestType = ((JAXBElement<?>) object).getValue(); assertTrue(requestType instanceof CreateXMLSignatureRequestType); @@ -397,19 +396,17 @@ public class SignatureTest { output.setByteStream(System.out); LSSerializer serializer = domImplLS.createLSSerializer(); -// serializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE); serializer.getDomConfig().setParameter("namespaces", Boolean.FALSE); serializer.write(document, output); } - @SuppressWarnings("unchecked") @Test public void testDataObject_Base64Content_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException { List<DataObjectInfoType> dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_Base64Content_1.xml"); - Signature signature = new Signature(null, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); + Signature signature = new Signature(urlDereferencer, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); for (DataObjectInfoType dataObjectInfo : dataObjectInfos) { signature.addDataObject(dataObjectInfo); @@ -427,10 +424,10 @@ public class SignatureTest { Reference reference = references.get(0); assertNotNull(reference.getId()); - List<Transform> transforms = reference.getTransforms(); + List<?> transforms = reference.getTransforms(); assertTrue(transforms.size() == 1); - Transform transform = transforms.get(0); + Transform transform = (Transform) transforms.get(0); assertTrue(Transform.BASE64.equals(transform.getAlgorithm())); List<XMLObject> objects = signature.getXMLObjects(); @@ -443,16 +440,14 @@ public class SignatureTest { } - @SuppressWarnings("unchecked") @Test - public void testDataObject_XMLContent_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException { System.out.println("\n ****************** testDataObject_XMLContent_1 \n"); List<DataObjectInfoType> dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_XMLContent_1.xml"); - Signature signature = new Signature(null, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); + Signature signature = new Signature(urlDereferencer, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); for (DataObjectInfoType dataObjectInfo : dataObjectInfos) { signature.addDataObject(dataObjectInfo); @@ -470,10 +465,10 @@ public class SignatureTest { Reference reference = references.get(0); assertNotNull(reference.getId()); - List<Transform> transforms = reference.getTransforms(); + List<?> transforms = reference.getTransforms(); assertTrue(transforms.size() == 2); - Transform transform = transforms.get(0); + Transform transform = (Transform) transforms.get(0); assertTrue(Transform.XPATH2.equals(transform.getAlgorithm())); List<XMLObject> objects = signature.getXMLObjects(); @@ -486,7 +481,6 @@ public class SignatureTest { } - @SuppressWarnings("unchecked") @Test public void testDataObject_XMLContent_2() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException { @@ -494,7 +488,7 @@ public class SignatureTest { List<DataObjectInfoType> dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_XMLContent_2.xml"); - Signature signature = new Signature(null, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); + Signature signature = new Signature(urlDereferencer, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); for (DataObjectInfoType dataObjectInfo : dataObjectInfos) { signature.addDataObject(dataObjectInfo); @@ -512,10 +506,10 @@ public class SignatureTest { Reference reference = references.get(0); assertNotNull(reference.getId()); - List<Transform> transforms = reference.getTransforms(); + List<?> transforms = reference.getTransforms(); assertTrue(transforms.size() == 2); - Transform transform = transforms.get(0); + Transform transform = (Transform) transforms.get(0); assertTrue(Transform.XPATH2.equals(transform.getAlgorithm())); List<XMLObject> objects = signature.getXMLObjects(); @@ -529,7 +523,6 @@ public class SignatureTest { } - @SuppressWarnings("unchecked") @Test public void testDataObject_LocRefContent_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException { @@ -537,7 +530,7 @@ public class SignatureTest { List<DataObjectInfoType> dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_LocRefContent_1.xml"); - Signature signature = new Signature(null, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); + Signature signature = new Signature(urlDereferencer, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); for (DataObjectInfoType dataObjectInfo : dataObjectInfos) { signature.addDataObject(dataObjectInfo); @@ -553,10 +546,10 @@ public class SignatureTest { Reference reference = references.get(0); assertNotNull(reference.getId()); - List<Transform> transforms = reference.getTransforms(); + List<?> transforms = reference.getTransforms(); assertTrue(transforms.size() == 2); - Transform transform = transforms.get(0); + Transform transform = (Transform) transforms.get(0); assertTrue(Transform.XPATH2.equals(transform.getAlgorithm())); List<XMLObject> objects = signature.getXMLObjects(); @@ -569,7 +562,6 @@ public class SignatureTest { } - @SuppressWarnings("unchecked") @Test public void testDataObject_LocRefContent_2() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException { @@ -577,7 +569,7 @@ public class SignatureTest { List<DataObjectInfoType> dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_LocRefContent_2.xml"); - Signature signature = new Signature(null, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); + Signature signature = new Signature(urlDereferencer, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); for (DataObjectInfoType dataObjectInfo : dataObjectInfos) { signature.addDataObject(dataObjectInfo); @@ -593,10 +585,10 @@ public class SignatureTest { Reference reference = references.get(0); assertNotNull(reference.getId()); - List<Transform> transforms = reference.getTransforms(); + List<?> transforms = reference.getTransforms(); assertTrue(transforms.size() == 1); - Transform transform = transforms.get(0); + Transform transform = (Transform) transforms.get(0); assertTrue(Transform.BASE64.equals(transform.getAlgorithm())); List<XMLObject> objects = signature.getXMLObjects(); @@ -609,7 +601,6 @@ public class SignatureTest { } - @SuppressWarnings("unchecked") @Test public void testDataObject_Reference_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException { @@ -617,7 +608,7 @@ public class SignatureTest { List<DataObjectInfoType> dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_Reference_1.xml"); - Signature signature = new Signature(null, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); + Signature signature = new Signature(urlDereferencer, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); for (DataObjectInfoType dataObjectInfo : dataObjectInfos) { signature.addDataObject(dataObjectInfo); @@ -633,10 +624,10 @@ public class SignatureTest { Reference reference = references.get(0); assertNotNull(reference.getId()); - List<Transform> transforms = reference.getTransforms(); + List<?> transforms = reference.getTransforms(); assertTrue(transforms.size() == 1); - Transform transform = transforms.get(0); + Transform transform = (Transform) transforms.get(0); assertTrue(Transform.BASE64.equals(transform.getAlgorithm())); List<XMLObject> objects = signature.getXMLObjects(); @@ -649,7 +640,6 @@ public class SignatureTest { } - @SuppressWarnings("unchecked") @Test public void testDataObject_Detached_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException { @@ -657,7 +647,7 @@ public class SignatureTest { List<DataObjectInfoType> dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_Detached_1.xml"); - Signature signature = new Signature(null, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); + Signature signature = new Signature(urlDereferencer, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); for (DataObjectInfoType dataObjectInfo : dataObjectInfos) { signature.addDataObject(dataObjectInfo); @@ -673,7 +663,7 @@ public class SignatureTest { Reference reference = references.get(0); assertNotNull(reference.getId()); - List<Transform> transforms = reference.getTransforms(); + List<?> transforms = reference.getTransforms(); assertTrue(transforms.size() == 0); List<XMLObject> objects = signature.getXMLObjects(); @@ -682,7 +672,6 @@ public class SignatureTest { } - @SuppressWarnings("unchecked") @Test public void testDataObject_Detached_Base64Content() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException { @@ -690,7 +679,7 @@ public class SignatureTest { List<DataObjectInfoType> dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_Detached_Base64Content.xml"); - Signature signature = new Signature(null, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); + Signature signature = new Signature(urlDereferencer, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); for (DataObjectInfoType dataObjectInfo : dataObjectInfos) { signature.addDataObject(dataObjectInfo); @@ -700,13 +689,13 @@ public class SignatureTest { signAndMarshalSignature(signature); - List<Reference> references = signature.getReferences(); + List<?> references = signature.getReferences(); assertTrue(references.size() == 2); - Reference reference = references.get(0); + Reference reference = (Reference) references.get(0); assertNotNull(reference.getId()); - List<Transform> transforms = reference.getTransforms(); + List<?> transforms = reference.getTransforms(); assertTrue(transforms.size() == 0); List<XMLObject> objects = signature.getXMLObjects(); @@ -715,7 +704,6 @@ public class SignatureTest { } - @SuppressWarnings("unchecked") @Test public void testDataObject_Detached_LocRefContent() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException { @@ -723,7 +711,7 @@ public class SignatureTest { List<DataObjectInfoType> dataObjectInfos = unmarshalDataObjectInfo("DataObjectInfo_Detached_LocRefContent.xml"); - Signature signature = new Signature(null, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); + Signature signature = new Signature(urlDereferencer, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); for (DataObjectInfoType dataObjectInfo : dataObjectInfos) { signature.addDataObject(dataObjectInfo); @@ -739,7 +727,7 @@ public class SignatureTest { Reference reference = references.get(0); assertNotNull(reference.getId()); - List<Transform> transforms = reference.getTransforms(); + List<?> transforms = reference.getTransforms(); assertTrue(transforms.size() == 0); List<XMLObject> objects = signature.getXMLObjects(); @@ -754,12 +742,11 @@ public class SignatureTest { // // - @SuppressWarnings("unchecked") private CreateXMLSignatureRequestType unmarshalCreateXMLSignatureRequest(String file) throws JAXBException, XMLStreamException { Object object = unmarshal(file); - Object requestType = ((JAXBElement) object).getValue(); + Object requestType = ((JAXBElement<?>) object).getValue(); assertTrue(requestType instanceof CreateXMLSignatureRequestType); @@ -768,13 +755,12 @@ public class SignatureTest { } - @SuppressWarnings("unchecked") @Test public void testTransformsInfo_1() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException { CreateXMLSignatureRequestType requestType = unmarshalCreateXMLSignatureRequest("TransformsInfo_1.xml"); - Signature signature = new Signature(null, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); + Signature signature = new Signature(urlDereferencer, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); signature.setSignatureInfo(requestType.getSignatureInfo()); @@ -797,10 +783,10 @@ public class SignatureTest { Reference reference = references.get(0); assertNotNull(reference.getId()); - List<Transform> transforms = reference.getTransforms(); + List<?> transforms = reference.getTransforms(); assertTrue("Size " + transforms.size() + "", transforms.size() == 3); - Transform transform = transforms.get(0); + Transform transform = (Transform) transforms.get(0); assertTrue(Transform.ENVELOPED.equals(transform.getAlgorithm())); List<XMLObject> objects = signature.getXMLObjects(); @@ -809,14 +795,12 @@ public class SignatureTest { } - @SuppressWarnings("unchecked") @Test - @Ignore public void testTransformsInfo_2() throws JAXBException, SLCommandException, XMLStreamException, SLRequestException, MarshalException, XMLSignatureException, SLViewerException { CreateXMLSignatureRequestType requestType = unmarshalCreateXMLSignatureRequest("TransformsInfo_2.xml"); - Signature signature = new Signature(null, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); + Signature signature = new Signature(urlDereferencer, new IdValueFactoryImpl(), new AlgorithmMethodFactoryImpl()); signature.setSignatureInfo(requestType.getSignatureInfo()); @@ -839,10 +823,10 @@ public class SignatureTest { Reference reference = references.get(0); assertNotNull(reference.getId()); - List<Transform> transforms = reference.getTransforms(); + List<?> transforms = reference.getTransforms(); assertTrue("Size " + transforms.size() + "", transforms.size() == 2); - Transform transform = transforms.get(0); + Transform transform = (Transform) transforms.get(0); assertTrue(Transform.XSLT.equals(transform.getAlgorithm())); List<XMLObject> objects = signature.getXMLObjects(); |