1 7 8 package test.wsdl.esr; 9 10 import org.apache.axis.transport.http.SimpleAxisWorker; 11 import org.apache.axis.utils.NetworkUtils; 12 13 import javax.xml.namespace.QName ; 14 15 public class EsrTestServiceTestCase extends junit.framework.TestCase { 16 public EsrTestServiceTestCase(java.lang.String name) { 17 super(name); 18 } 19 20 public void testEsrTestWSDL() throws Exception { 21 javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance(); 22 java.net.URL url = new java.net.URL (new test.wsdl.esr.EsrTestServiceLocator().getEsrTestAddress() + "?WSDL"); 23 javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.esr.EsrTestServiceLocator().getServiceName()); 24 assertTrue(service != null); 25 } 26 27 public void test1EsrTestEsrInOut() { 28 try { 30 String thisHost = NetworkUtils.getLocalHostname(); 31 String thisPort = System.getProperty("test.functional.ServicePort", "8080"); 32 33 String wsdlLocation = "http://" + thisHost + ":" + thisPort + "/axis/services/EsrTest?WSDL"; 35 javax.xml.rpc.Service svc = 36 new org.apache.axis.client.Service( 37 wsdlLocation, 38 new javax.xml.namespace.QName ("urn:esr.wsdl.test", 39 "EsrTestService") 40 ); 41 42 javax.xml.rpc.Call call = svc.createCall( 44 new javax.xml.namespace.QName ("urn:esr.wsdl.test", 45 "EsrTest"), 46 new javax.xml.namespace.QName ("urn:esr.wsdl.test", 47 "esrInOut") 48 ); 49 50 Object [] soapInParams = new Object []{new Short ((short) 5)}; 52 53 Object ret = call.invoke(soapInParams); 55 56 java.util.Map outParams = call.getOutputParams(); 58 59 68 69 assertEquals("Number of output parameters is wrong", outParams.size(), 2); 71 Object s = outParams.get(new QName ("echoVal")); 72 assertNotNull("echoVal paramter is null", s); 73 assertEquals("echoVal parameter is incorrect", (Short )s, new Short ((short) 5) ); 74 Object sq = outParams.get(new QName ("sqrtVal")); 75 assertNotNull("sqrtVal paramter is null", sq); 76 assertEquals("sqrtVal parameter is incorrect", ((Double )sq).doubleValue(), Math.sqrt(5), 0.001D ); 77 78 } catch (Exception e) { 79 e.printStackTrace(System.out); 80 throw new junit.framework.AssertionFailedError("Exception caught: " + e); 81 } 82 83 } 84 85 public void test1EsrTestEsrInOut2() { 86 try { 88 String thisHost = NetworkUtils.getLocalHostname(); 89 String thisPort = System.getProperty("test.functional.ServicePort", "8080"); 90 91 String wsdlLocation = "http://" + thisHost + ":" + thisPort + "/axis/services/EsrTest?WSDL"; 93 javax.xml.rpc.Service svc = 94 new org.apache.axis.client.Service( 95 wsdlLocation, 96 new javax.xml.namespace.QName ("urn:esr.wsdl.test", 97 "EsrTestService") 98 ); 99 100 javax.xml.rpc.Call call = svc.createCall( 102 new javax.xml.namespace.QName ("urn:esr.wsdl.test", 103 "EsrTest"), 104 new javax.xml.namespace.QName ("urn:esr.wsdl.test", 105 "esrInOut2") 106 ); 107 108 Object [] soapInParams = new Object [] { 110 "token1", 111 "token2", 112 new Short ((short)5) }; 113 114 Object ret = call.invoke(soapInParams); 116 117 java.util.Map outParams = call.getOutputParams(); 119 120 129 130 assertEquals("Number of output parameters is wrong", outParams.size(), 2); 132 Object s = outParams.get(new QName ("echoVal")); 133 assertNotNull("echoVal paramter is null", s); 134 assertEquals("echoVal parameter is incorrect", (Short )s, new Short ((short) 5) ); 135 Object sq = outParams.get(new QName ("sqrtVal")); 136 assertNotNull("sqrtVal paramter is null", sq); 137 assertEquals("sqrtVal parameter is incorrect", ((Double )sq).doubleValue(), Math.sqrt(5), 0.001D ); 138 139 } catch (Exception e) { 140 e.printStackTrace(System.out); 141 throw new junit.framework.AssertionFailedError("Exception caught: " + e); 142 } 143 144 } 145 } 146 | Popular Tags |