[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Fri Dec 14 16:26:00 UTC 2007


gordonp
Fri Dec 14 11:26:00 EST 2007
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test
In directory dev.open-bio.org:/tmp/cvs-serv23592/src/main/org/biomoby/service/test

Modified Files:
	MobyServletTestCase.java 
Log Message:
Added test of SOAP message parsing, so a proper servlet war can be deployed by bootstrapping the test case
moby-live/Java/src/main/org/biomoby/service/test MobyServletTestCase.java,1.7,1.8
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test/MobyServletTestCase.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test/MobyServletTestCase.java	2007/12/06 16:40:38	1.7
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test/MobyServletTestCase.java	2007/12/14 16:26:00	1.8
@@ -21,6 +21,7 @@
 
 public class MobyServletTestCase extends TestCase{
     private final static String TEST_MOBY_XML = "org/biomoby/service/test/mobyAASeqWithSecondaries.xml";
+    private final static String TEST_SOAP_XML = "org/biomoby/service/test/soapRequest.xml";  //full SOAP payload
     private final static String SERVLET_TEST_WEBXML = "org/biomoby/service/test/web.xml";
     private final static String SERVLET_TEST_URL = "http://moby.ucalgary.ca:8080/MobyServlet";
     private final static String TEST_MAIN_CLASS_NAME = "org.biomoby.service.test.ConvertAAtoFASTA_AA";
@@ -95,7 +96,7 @@
 	//MobyServlet.main(new String[]{TEST_MOBY_XML});
     }
 
-    public void testRDF(){
+    public MobyServlet getMobyServlet(){
 	String webXMLPath = "WEB-INF/web.xml";
 	java.net.URL webXmlURL = getClass().getClassLoader().getResource(webXMLPath);
 	assertNotNull("No \""+ webXMLPath+"\" in the resource path", webXmlURL);
@@ -125,11 +126,17 @@
 
 	try{
 	    servlet.init(servletConfig);
+	    servlet.createServiceFromConfig(null);
 	}
 	catch(Exception e){
 	    e.printStackTrace();
 	    fail("Caught exception while trying to initialize servlet: " + e);
 	}
+	return servlet;
+    }
+
+    public void testRDF(){
+	MobyServlet servlet = getMobyServlet();
 
 	TestHttpServletRequest request = new TestHttpServletRequest();
 	request.setParameter(MobyServlet.MODE_HTTP_PARAM, MobyServlet.RDF_MODE);
@@ -215,7 +222,7 @@
 	    e.printStackTrace();
 	    fail("Could not serialize (to XML) the results of ConvertAAtoFASTA_AA:" + e);
 	}
-	resultContents.clear();  // so we don't build up junk from miltiple responses
+	resultContents.clear();  // so we don't build up junk from multiple responses
 
 	// Call second service on output of previous service, the input is actually AA, not DNA as expected
 	try{
@@ -279,6 +286,19 @@
 	}
     }
 
+    public void testSoapParsing() throws Exception{
+	URL testDataURL = getClass().getClassLoader().getResource(TEST_SOAP_XML);
+	assertNotNull("Could not find test soap rerequest resource (" + TEST_SOAP_XML + 
+		      "), please make sure your class path is specified correctly", testDataURL);
+
+	TestHttpServletRequest testRequest = new TestHttpServletRequest();
+	testRequest.setInputStream(testDataURL.openStream());
+
+	MobyServlet servlet = getMobyServlet();
+	MobyContentInstance mobyContents = servlet.getMobyContents(testRequest);
+	assertNotNull("Could not retrieve the MOBY data payload from the test HTTP request", mobyContents);
+    }
+
     public void testAsync(){
 	// TODO
     }
@@ -292,11 +312,12 @@
     public static Test suite() {
 
 	TestSuite suite = new TestSuite();
- 	suite.addTest(new MobyServletTestCase("testRDF"));
- 	suite.addTest(new MobyServletTestCase("testRequestChain")); 
- 	suite.addTest(new MobyServletTestCase("testMain"));
- 	suite.addTest(new MobyServletTestCase("testSecondaryParams"));
- 	suite.addTest(new MobyServletTestCase("testServletTester"));
+      	suite.addTest(new MobyServletTestCase("testRDF"));
+ 	suite.addTest(new MobyServletTestCase("testSoapParsing"));
+  	suite.addTest(new MobyServletTestCase("testRequestChain")); 
+  	suite.addTest(new MobyServletTestCase("testMain"));
+  	suite.addTest(new MobyServletTestCase("testSecondaryParams"));
+  	suite.addTest(new MobyServletTestCase("testServletTester"));
         return suite;
     }
 




More information about the MOBY-guts mailing list