From d89f36b67ea1d838a78523538a24e044518f3587 Mon Sep 17 00:00:00 2001 From: mcentner Date: Tue, 26 Jan 2010 16:22:56 +0000 Subject: MOCCA 1.2.11 with SHA-2 enabled. git-svn-id: https://joinup.ec.europa.eu/svn/mocca/branches/mocca-1.2.11-sha2@599 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../service/translator/STALTranslatorTest.java | 146 +++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 mocca-1.2.11/STALService/src/test/java/at/gv/egiz/stal/service/translator/STALTranslatorTest.java (limited to 'mocca-1.2.11/STALService/src/test/java') diff --git a/mocca-1.2.11/STALService/src/test/java/at/gv/egiz/stal/service/translator/STALTranslatorTest.java b/mocca-1.2.11/STALService/src/test/java/at/gv/egiz/stal/service/translator/STALTranslatorTest.java new file mode 100644 index 00000000..1dad7973 --- /dev/null +++ b/mocca-1.2.11/STALService/src/test/java/at/gv/egiz/stal/service/translator/STALTranslatorTest.java @@ -0,0 +1,146 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package at.gv.egiz.stal.service.translator; + +import at.gv.egiz.stal.STALRequest; +import at.gv.egiz.stal.STALResponse; +import at.gv.egiz.stal.SignRequest; +import at.gv.egiz.stal.service.translator.STALTranslator.TranslationHandler; +import at.gv.egiz.stal.service.types.ObjectFactory; +import at.gv.egiz.stal.service.types.RequestType; +import at.gv.egiz.stal.service.types.ResponseType; +import at.gv.egiz.stal.service.types.SignRequestType; +import javax.xml.bind.JAXBElement; +import javax.xml.namespace.QName; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author clemens + */ +public class STALTranslatorTest { + + static ObjectFactory of; + + public STALTranslatorTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + of = new ObjectFactory(); + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of registerTranslationHandler method, of class STALTranslator. + */ + @Test + @Ignore + public void testRegisterTranslationHandler() { + System.out.println("registerTranslationHandler"); + TranslationHandler handler = null; + STALTranslator instance = new STALTranslator(); + instance.registerTranslationHandler(handler); + + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of translate method, of class STALTranslator. + */ + @Test + public void testTranslate_STALRequest() throws Exception { + System.out.println("translate"); + SignRequest request = new SignRequest(); + request.setKeyIdentifier("kid"); + request.setSignedInfo("signedinfo".getBytes()); + STALTranslator instance = new STALTranslator(); + JAXBElement result = instance.translate(request); + assertEquals(SignRequestType.class, result.getValue().getClass()); + SignRequestType resultT = (SignRequestType) result.getValue(); + assertEquals(request.getKeyIdentifier(), resultT.getKeyIdentifier()); + assertEquals(request.getSignedInfo(), resultT.getSignedInfo()); + } + + /** + * Test of translate method, of class STALTranslator. + */ + @Test + public void testTranslate_1args_1() throws Exception { + System.out.println("translate"); + SignRequestType req = of.createSignRequestType(); + req.setKeyIdentifier("kid"); + req.setSignedInfo("signedinfo".getBytes()); + JAXBElement request = of.createGetNextRequestResponseTypeSignRequest(req); + STALTranslator instance = new STALTranslator(); + STALRequest result = instance.translate(request); + assertEquals(SignRequest.class, result.getClass()); + assertEquals(req.getKeyIdentifier(), ((SignRequest) result).getKeyIdentifier()); + assertEquals(req.getSignedInfo(), ((SignRequest) result).getSignedInfo()); + } + + @Test(expected=RuntimeException.class) + public void testTranslate_invalidInput() throws Exception { + System.out.println("translate"); + QName n = new QName("http://www.egiz.gv.at/stal", "SignRequest"); + JAXBElement request = new JAXBElement(n, SignRequestType.class, null); + STALTranslator instance = new STALTranslator(); + STALRequest result = instance.translate(request); + assertEquals(SignRequest.class, result.getClass()); + } + + + /** + * Test of translate method, of class STALTranslator. + */ + @Test + @Ignore + public void testTranslate_STALResponse() throws Exception { + System.out.println("translate"); + STALResponse response = null; + STALTranslator instance = new STALTranslator(); + JAXBElement expResult = null; + JAXBElement result = instance.translate(response); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of translate method, of class STALTranslator. + */ + @Test + @Ignore + public void testTranslate_1args_2() throws Exception { + System.out.println("translate"); + JAXBElement response = null; + STALTranslator instance = new STALTranslator(); + STALResponse expResult = null; + STALResponse result = instance.translate(response); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + +} \ No newline at end of file -- cgit v1.2.3