[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Tue Jun 9 19:11:55 UTC 2009


gordonp
Tue Jun  9 15:11:55 EDT 2009
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/test
In directory dev.open-bio.org:/tmp/cvs-serv20241/src/main/ca/ucalgary/services/util/test

Modified Files:
	WSDLConfigTestCase.java 
Log Message:
Added tests for several services incl. doc/lit & rpc/encoded
moby-live/Java/src/main/ca/ucalgary/services/util/test WSDLConfigTestCase.java,1.4,1.5
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/test/WSDLConfigTestCase.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/test/WSDLConfigTestCase.java	2008/10/30 02:33:25	1.4
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/test/WSDLConfigTestCase.java	2009/06/09 19:11:55	1.5
@@ -12,7 +12,8 @@
 import java.util.Map;
 
 public class WSDLConfigTestCase extends TestCase{
-    private final static String WSDL_RESOURCE = "ca/ucalgary/services/util/test/KEGG.wsdl";
+    private final static String WSDL_RESOURCE_RPC = "ca/ucalgary/services/util/test/KEGG.wsdl";
+    private final static String WSDL_RESOURCE_DOCLIT = "ca/ucalgary/services/util/test/OntologyQuery.wsdl";
 
     private final static int NUM_SERVICES = 1;
     private final static String SERVICE_NAME = "getGenesByECNumber";
@@ -20,12 +21,17 @@
     private final static String SERVICE_AUTHORITY = "genome.jp";
     private final static String SERVICE_DESC = "Retrieves the list of genes in a given organism that " +
 	                                       "are annotated as having a particular EC (enzyme) number";
-    private final static String SERVICE_CONTACT = "ktym at hgc.jp";
+    private final static String SERVICE_CONTACT = "gordonp at ucalgary.ca";
 
     private final static String OP_NAME = "get_genes_by_enzyme";
     private final static String OP_INPUT_NAME = "get_genes_by_enzymeRequest";
     private final static String OP_OUTPUT_NAME = "get_genes_by_enzymeResponse";
 
+    private final static String SERVICE_NAME_LIT = "ebi-ols-getTermByID";
+    private final static String OP_NAME_LIT = "getTermById";
+    private final static String OP_INPUT_NAME_LIT = "getTermById";
+    private final static String OP_OUTPUT_NAME_LIT = "getTermByIdResponse";
+
     private final static int NUM_INPUTS = 1;
     private final static String INPUT_NAME1 = "enzyme_id";
     private final static String INPUT_TYPE1 = "enzyme_id:Object:EC";
@@ -43,11 +49,18 @@
     private final static String OUTPUT_XSDTYPE1 = "typens:ArrayOfstring";
     private final static String OUTPUT_SCHEMA_MAPPING1 = "urn:lsid:bioxml.info:mobyLiftingSchemaMapping:string2KEGG_GENES";
 
+    // RPC/Encoded service test
     private final static String SOAP_SERVICE_NAME = "KEGG";
     private final static String SOAP_SERVICE_URI = "SOAP/KEGG";
     private final static String SOAP_PORT_NAME = "KEGGPort";
     private final static String SOAP_PORT_URI = "SOAP/KEGG";
 
+    // Document/Literal service test
+    private final static String SOAP_SERVICE_NAME_LIT = "QueryService";
+    private final static String SOAP_SERVICE_URI_LIT = "http://www.ebi.ac.uk/ontology-lookup/OntologyQuery";
+    private final static String SOAP_PORT_NAME_LIT = "OntologyQuery";
+    private final static String SOAP_PORT_URI_LIT = "http://www.ebi.ac.uk/ontology-lookup/OntologyQuery";
+
     public WSDLConfigTestCase(String name){
 	super(name);
     }
@@ -56,12 +69,12 @@
      * See if the xhtml and moby spec class values are properly parsed
      */
     public void testParsingBasic(){
-	loadWSDL();
+	loadWSDL(WSDL_RESOURCE_RPC);
     }
 
-    private WSDLConfig loadWSDL(){
-	URL u = getClass().getClassLoader().getResource(WSDL_RESOURCE);
-	assertNotNull("Could not find the test WSDL resource ("+WSDL_RESOURCE+")", u);
+    private WSDLConfig loadWSDL(String resource){
+	URL u = getClass().getClassLoader().getResource(resource);
+	assertNotNull("Could not find the test WSDL resource ("+resource+")", u);
 
 	WSDLConfig wsdl = null;
 	try{
@@ -75,7 +88,7 @@
     }
 
     public void testMetadata(){
-	WSDLConfig wsdl = loadWSDL();
+	WSDLConfig wsdl = loadWSDL(WSDL_RESOURCE_RPC);
 
 	String[] serviceNames = wsdl.getServiceNames();
 	assertNotNull("WSDLConfig returned null instead of an array of service names for test WSDL file", 
@@ -99,8 +112,8 @@
 		   SERVICE_CONTACT.equals(wsdl.getContactEmail()));
     }
     
-    public void testIOSpecs(){
-	WSDLConfig wsdl = loadWSDL();
+    public void testIOSpecsRPCEncoded(){
+	WSDLConfig wsdl = loadWSDL(WSDL_RESOURCE_RPC);
 
 	wsdl.setCurrentService(SERVICE_NAME);
 	assertTrue("The SOAP operation name '" + wsdl.getOperationName() + "' for service " + 
@@ -222,7 +235,7 @@
 	// Verify if the service info was actually parsed properly by trying to use it with JAX-WS
 	Service service = null;
 	try{
-	    service = Service.create(getClass().getClassLoader().getResource(WSDL_RESOURCE), 
+	    service = Service.create(getClass().getClassLoader().getResource(WSDL_RESOURCE_RPC), 
 				     serviceQName);
 	} catch(Exception e){
 	    e.printStackTrace();
@@ -241,6 +254,61 @@
 	}
     }
     
+    public void testIOSpecsDocumentLiteral(){
+	WSDLConfig wsdl = loadWSDL(WSDL_RESOURCE_DOCLIT);
+
+	
+	wsdl.setCurrentService(SERVICE_NAME_LIT);
+	assertTrue("The SOAP operation name '" + wsdl.getOperationName() + "' for service " + 
+		   SERVICE_NAME_LIT + " in the test WSDL was not '" + OP_NAME_LIT + "' as expected", 
+		   OP_NAME_LIT.equals(wsdl.getOperationName()));
+	assertTrue("The SOAP operation input name '" + wsdl.getOperationInputQName().getLocalPart() + "' for service " + 
+		   SERVICE_NAME_LIT + " in the test WSDL was not '" + OP_INPUT_NAME_LIT + "' as expected", 
+		   OP_INPUT_NAME_LIT.equals(wsdl.getOperationInputQName().getLocalPart()));
+	assertTrue("The SOAP operation output name '" + wsdl.getOperationOutputQName().getLocalPart() + "' for service " + 
+		   SERVICE_NAME_LIT + " in the test WSDL was not '" + OP_OUTPUT_NAME_LIT + "' as expected", 
+		   OP_OUTPUT_NAME_LIT.equals(wsdl.getOperationOutputQName().getLocalPart()));
+
+	QName serviceQName = wsdl.getServiceQName();
+	assertNotNull("The service QName was unexpectedly null", serviceQName);
+	assertTrue("The local name of the service (" + serviceQName.getLocalPart() +
+		   ") was not the expected value (" + SOAP_SERVICE_NAME_LIT + ")",
+		   SOAP_SERVICE_NAME_LIT.equals(serviceQName.getLocalPart()));
+	assertTrue("The namespace URI of the service (" + serviceQName.getNamespaceURI() +
+		   ") was not the expected value (" + SOAP_SERVICE_URI_LIT + ")",
+		   SOAP_SERVICE_URI_LIT.equals(serviceQName.getNamespaceURI()));
+	QName portQName = wsdl.getPortQName();
+	assertNotNull("The service port QName was unexpectedly null", portQName);
+	assertTrue("The local name of the service port (" + portQName.getLocalPart() +
+		   ") was not the expected value (" + SOAP_PORT_NAME_LIT + ")",
+		   SOAP_PORT_NAME_LIT.equals(portQName.getLocalPart()));
+	assertTrue("The namespace URI of the service port (" + portQName.getNamespaceURI() +
+		   ") was not the expected value (" + SOAP_PORT_URI_LIT + ")",
+		   SOAP_PORT_URI_LIT.equals(portQName.getNamespaceURI()));
+
+
+	// Verify if the service info was actually parsed properly by trying to use it with JAX-WS
+	Service service = null;
+	try{
+	    service = Service.create(getClass().getClassLoader().getResource(WSDL_RESOURCE_DOCLIT), 
+				     serviceQName);
+	} catch(Exception e){
+	    e.printStackTrace();
+	    fail(e.getClass().getName() + " while using JAX-WS to create a handle for" +
+		 "the service, either the WSDL or the expected serviceQName is wrong");
+	}
+
+	try{
+	    Dispatch<Source> dispatch = service.createDispatch(portQName,
+							       Source.class,
+							       Service.Mode.PAYLOAD);
+	} catch(Exception e){
+	    e.printStackTrace();
+	    fail(e.getClass().getName() + " while using JAX-WS to create a dispatch a port on " +
+		 "the service " + serviceQName + ", either the WSDL or the expected portQName is wrong");
+	}
+    }
+
     /**
      * @return a test suite for all the test methods of this test case.
      */
@@ -249,7 +317,8 @@
 	TestSuite suite = new TestSuite();
  	suite.addTest(new WSDLConfigTestCase("testParsingBasic"));
  	suite.addTest(new WSDLConfigTestCase("testMetadata"));
- 	suite.addTest(new WSDLConfigTestCase("testIOSpecs"));
+ 	suite.addTest(new WSDLConfigTestCase("testIOSpecsRPCEncoded"));
+ 	suite.addTest(new WSDLConfigTestCase("testIOSpecsDocumentLiteral"));
 	
         return suite;
     }




More information about the MOBY-guts mailing list