[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Thu Aug 20 19:52:09 UTC 2009


gordonp
Thu Aug 20 15:52:09 EDT 2009
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test
In directory dev.open-bio.org:/tmp/cvs-serv10255/src/main/ca/ucalgary/services/test

Modified Files:
	SoapServletTestCase.java 
Log Message:
Moved tests from SoapServlet to Test Case class, updated and expanded tests
moby-live/Java/src/main/ca/ucalgary/services/test SoapServletTestCase.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/SoapServletTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/SoapServletTestCase.java	2009/06/09 19:39:53	1.1
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/SoapServletTestCase.java	2009/08/20 19:52:09	1.2
@@ -4,8 +4,7 @@
 import ca.ucalgary.seahawk.gui.*;
 import ca.ucalgary.seahawk.util.*;
 
-import org.biomoby.shared.MobyDataType;
-import org.biomoby.shared.data.*;
+import org.biomoby.service.test.*;
 
 import junit.framework.*;
 
@@ -17,30 +16,117 @@
  * 
  */
 public class SoapServletTestCase extends TestCase{
-    private final static String TEST_WSDL = "http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/eutils.wsdl";
+    // The class below should have a nullary c-tor
+    private final static String TEST_DATARECORDER = "ca.ucalgary.services.util.PBERecorder";
 
     public SoapServletTestCase(String name){
 	super(name);
     }
     
-    public void testWSDLLoad(){
-	URL testWSDL = null;
+    /**
+     * Checks against a KEGG service
+     */
+    public void testWSDLRpcEncExecute(){
+	SoapServlet servlet = new SoapServlet();
+	try{
+	    servlet.init(new TestServletConfig("", new TestServletContext()));
+	}catch(Exception e){
+	    e.printStackTrace();
+	    fail("Could not initialize the SoapServlet");
+	}
+
+	TestHttpServletRequest request = new TestHttpServletRequest();
+	request.setParameter(SoapServlet.WSDL_HTTP_PARAM, "http://soap.genome.jp/KEGG.wsdl");
+	request.setParameter(SoapServlet.SERVICE_SPEC_PARAM, "SOAP/KEGG KEGG SOAP/KEGG KEGGPort " +
+			     "SOAP/KEGG get_compounds_by_enzyme SOAP/KEGG#get_compounds_by_enzyme " +
+			     "get_compounds_by_enzyme rpc encoded");
+	request.setParameter("enzyme_id", "ec:1.1.1.1");
+
+	TestHttpServletResponse response = new TestHttpServletResponse();
+	StringBufferServletOutputStream out = new StringBufferServletOutputStream();
+	response.setOutputStream(out);
+	try{
+	    servlet.doPost(request, response);
+	}
+	catch(Exception e){
+	    e.printStackTrace();
+	    fail("Got exception while posting request for RPC/Encoded KEGG Web Service");
+	}
+	assertTrue("Did not find the expected data in the reponse from KEGG", 
+		   out.getBuffer().indexOf("cpd:C00001") != -1);
+    }
+    
+    /**
+     * Checks against both NCBI and EBI services.
+     */
+    public void testWSDLDocLitExecute(){
+	SoapServlet servlet = new SoapServlet();
 	try{
-	    testWSDL = new URL(TEST_WSDL);
-	} catch(Exception e){
+	    servlet.init(new TestServletConfig("", new TestServletContext()));
+	}catch(Exception e){
 	    e.printStackTrace();
-	    fail("Could not create URL from test document (" + TEST_WSDL + "): " + e);
+	    fail("Could not initialize the SoapServlet");
 	}
+
+	TestHttpServletRequest request = new TestHttpServletRequest();
+	request.setParameter(SoapServlet.WSDL_HTTP_PARAM, "http://www.ebi.ac.uk/ontology-lookup/OntologyQuery.wsdl");
+	request.setParameter(SoapServlet.SERVICE_SPEC_PARAM, "http://www.ebi.ac.uk/ontology-lookup/OntologyQuery QueryService " +
+			     "http://www.ebi.ac.uk/ontology-lookup/OntologyQuery OntologyQuery " +
+			     "http://www.ebi.ac.uk/ontology-lookup/OntologyQuery getTermsByName " +
+			     "getTermsByName getTermsByName document literal");
+	request.setParameter("partialName", "seed");
+	request.setParameter("ontologyName", "GO");
+	request.setParameter("reverseKeyOrder", "false");
+
+	TestHttpServletResponse response = new TestHttpServletResponse();
+	StringBufferServletOutputStream out = new StringBufferServletOutputStream();
+	response.setOutputStream(out);
+	try{
+	    servlet.doPost(request, response);
+	}
+	catch(Exception e){
+	    e.printStackTrace();
+	    fail("Got exception while posting request for Document/Literal EBI Web Service");
+	}
+	if(out.getBuffer().indexOf("coat") == -1){
+	    fail("Did not find the expected data in the reponse from EBI.  Response was:\n" + 
+		 out.getBuffer().toString());
+	}
+	TestHttpServletRequest request2 = new TestHttpServletRequest();
+	request2.setParameter(SoapServlet.WSDL_HTTP_PARAM, "http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/eutils.wsdl");
+	request2.setParameter(SoapServlet.SERVICE_SPEC_PARAM, "http://www.ncbi.nlm.nih.gov/soap/eutils/ eUtilsService " +
+			      "http://www.ncbi.nlm.nih.gov/soap/eutils/ eUtilsServiceSoap " +
+			      "http://www.ncbi.nlm.nih.gov/soap/eutils/espell eSpellRequest " +
+			      "espell run_eSpell document literal");
+	request2.setParameter("db:opt", "");
+	request2.setParameter("term:opt", "brest");
+	request2.setParameter("tool:opt", "");
+	request2.setParameter("email:opt", "");
 	
-	javax.swing.JOptionPane.showMessageDialog(null, "information",
-				      "information", javax.swing.JOptionPane.INFORMATION_MESSAGE);
-	System.err.println("About to load GUI");
-	MobyContentGUI gui = MobyUtils.getMobyContentGUI(null);
-	System.err.println("About to load " + TEST_WSDL);
-	gui.loadPaneFromURL(testWSDL, true);
+	TestHttpServletResponse response2 = new TestHttpServletResponse();
+	StringBufferServletOutputStream out2 = new StringBufferServletOutputStream();
+	response2.setOutputStream(out2);
 	try{
-	    Thread.sleep(100000);
-	} catch(Exception e){System.err.println("Sleep interrupted: " + e);}
+	    servlet.doPost(request2, response2);
+	}
+	catch(Exception e){
+	    e.printStackTrace();
+	    fail("Got exception while posting request for Document/Literal NCBI Web Service");
+	}
+	assertTrue("Did not find the expected data in the reponse from NCBI", 
+		   out2.getBuffer().indexOf("breast") != -1);
+    }
+
+    public void testDataRecorderAutoLoad(){
+	SoapServlet servlet = new SoapServlet();
+	try{
+	    TestServletConfig config = new TestServletConfig("", new TestServletContext());
+	    config.addInitParameter(SoapServlet.DATARECORDER_CONTEXTPARAM, TEST_DATARECORDER);
+	    servlet.init(config);
+	}catch(Exception e){
+	    e.printStackTrace();
+	    fail("Could not initialize the SoapServlet");
+	}	
     }
 
     /**
@@ -52,7 +138,9 @@
     public static Test suite() {
 
 	TestSuite suite = new TestSuite();
- 	suite.addTest(new SoapServletTestCase("testWSDLLoad"));
+	suite.addTest(new SoapServletTestCase("testWSDLRpcEncExecute"));
+	suite.addTest(new SoapServletTestCase("testWSDLDocLitExecute"));
+	suite.addTest(new SoapServletTestCase("testDataRecorderAutoLoad"));
         return suite;
     }
 




More information about the MOBY-guts mailing list