From 212bbffc24ccc1cd909cabdc9650491dd221cd60 Mon Sep 17 00:00:00 2001 From: clemenso Date: Thu, 22 Jan 2009 13:21:50 +0000 Subject: STALTranslator git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@283 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../service/translator/STALTranslatorTest.java | 146 +++++++++++++++++++++ .../src/test/resources/commons-logging.properties | 1 + 2 files changed, 147 insertions(+) create mode 100644 STALService/src/test/java/at/gv/egiz/stal/service/translator/STALTranslatorTest.java create mode 100644 STALService/src/test/resources/commons-logging.properties (limited to 'STALService/src/test') diff --git a/STALService/src/test/java/at/gv/egiz/stal/service/translator/STALTranslatorTest.java b/STALService/src/test/java/at/gv/egiz/stal/service/translator/STALTranslatorTest.java new file mode 100644 index 00000000..1dad7973 --- /dev/null +++ b/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 diff --git a/STALService/src/test/resources/commons-logging.properties b/STALService/src/test/resources/commons-logging.properties new file mode 100644 index 00000000..29292562 --- /dev/null +++ b/STALService/src/test/resources/commons-logging.properties @@ -0,0 +1 @@ +org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger -- cgit v1.2.3