axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davidills...@apache.org
Subject svn commit: r548407 - in /webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2: integration/RPCLocalTestCase.java rpc/MultirefTest.java rpc/RPCCallTest.java
Date Mon, 18 Jun 2007 16:37:55 GMT
Author: davidillsley
Date: Mon Jun 18 09:37:54 2007
New Revision: 548407

URL: http://svn.apache.org/viewvc?view=rev&rev=548407
Log:
Migrate the remaining RPC tests to the local transport.

Added:
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/RPCLocalTestCase.java
Modified:
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java

Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/RPCLocalTestCase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/RPCLocalTestCase.java?view=auto&rev=548407
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/RPCLocalTestCase.java
(added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/RPCLocalTestCase.java
Mon Jun 18 09:37:54 2007
@@ -0,0 +1,64 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.integration;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.rpc.client.RPCServiceClient;
+import org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver;
+import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
+import org.apache.axis2.transport.local.LocalTransportReceiver;
+
+/**
+ * LocalTestCase is an extendable base class which provides common functionality
+ * for building JUnit tests which exercise Axis2 using the (fast, in-process)
+ * "local" transport.
+ */
+public class RPCLocalTestCase extends LocalTestCase {
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+        ///////////////////////////////////////////////////////////////////////
+        // Set up raw message receivers for RPC based tests
+
+        serverConfig.addMessageReceiver(WSDL2Constants.MEP_URI_IN_ONLY,
+                                        new RPCInOnlyMessageReceiver());
+        serverConfig.addMessageReceiver(WSDL2Constants.MEP_URI_IN_OUT,
+                                        new RPCMessageReceiver());
+        serverConfig.addMessageReceiver(WSDL2Constants.MEP_URI_ROBUST_IN_ONLY,
+                                        new RPCMessageReceiver());
+    }
+    
+    /**
+     * Get a pre-initialized ServiceClient set up to talk to our local
+     * server.  If you want to set options, call this and then use getOptions()
+     * on the return. Clients created using this method have their To EPR
+     * preset to include the address for the service+operation.
+     *
+     * @return a ServiceClient, pre-initialized to talk using our local sender
+     * @throws AxisFault if there's a problem
+     */
+    protected RPCServiceClient getRPCClient(String serviceName, String operationName) throws
AxisFault {
+        String url = LocalTransportReceiver.CONFIG_CONTEXT.getServiceContextPath()+"/"+serviceName;
+
+        Options opts = getOptions();
+        opts.setTo(new EndpointReference(url));
+        opts.setAction(operationName);
+        RPCServiceClient client = new RPCServiceClient(clientCtx, null);
+        client.setOptions(opts);
+        return client;
+    }
+}

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.java?view=diff&rev=548407&r1=548406&r2=548407
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/MultirefTest.java
Mon Jun 18 09:37:54 2007
@@ -16,8 +16,17 @@
 
 package org.apache.axis2.rpc;
 
+import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
 import junit.framework.Test;
 import junit.framework.TestSuite;
+
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
@@ -40,62 +49,23 @@
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.DefaultObjectSupplier;
+import org.apache.axis2.integration.RPCLocalTestCase;
 import org.apache.axis2.integration.UtilServer;
-import org.apache.axis2.integration.UtilServerBasedTestCase;
 import org.apache.axis2.rpc.client.RPCServiceClient;
 import org.apache.axis2.wsdl.WSDLConstants;
 
-import javax.xml.namespace.QName;
-import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
-import java.util.ArrayList;
-
-public class MultirefTest extends UtilServerBasedTestCase {
-
-    protected EndpointReference targetEPR =
-            new EndpointReference("http://127.0.0.1:"
-                    + (UtilServer.TESTING_PORT)
-                    + "/axis2/services/EchoXMLService/concat");
-    protected QName serviceName = new QName("EchoXMLService");
-    protected QName operationName = new QName(NAMESPACE, "concat");
-    protected QName transportName = new QName(NAMESPACE,
-                                              "NullTransport");
-
-    protected AxisConfiguration engineRegistry;
-    protected MessageContext mc;
-    protected ServiceContext serviceContext;
-    protected AxisService service;
+public class MultirefTest extends RPCLocalTestCase {
 
     protected boolean finish = false;
     public static final String NAMESPACE = "http://rpc.axis2.apache.org/xsd";
 
-    public static Test suite() {
-        return getTestSetup(new TestSuite(MultirefTest.class));
-    }
-
-    protected void tearDown() throws Exception {
-        UtilServer.unDeployService(serviceName);
-        UtilServer.unDeployClientService();
-    }
-
-    private void configureSystem(String opName) throws AxisFault {
-        targetEPR =
-                new EndpointReference("http://127.0.0.1:"
-                        + (UtilServer.TESTING_PORT)
-                        + "/axis2/services/EchoXMLService/" + opName);
-        String className = "org.apache.axis2.rpc.RPCServiceClass";
-        operationName = new QName("http://rpc.axis2.apache.org/xsd", opName, "req");
-        AxisService service = AxisService.createService(
-                className, UtilServer.getConfigurationContext().getAxisConfiguration());
-        service.setName("EchoXMLService");
-        service.setClassLoader(Thread.currentThread().getContextClassLoader());
-        UtilServer.deployService(service);
-    }
-
+    protected void setUp() throws Exception {
+		super.setUp();
+		deployClassAsService("EchoXMLService", RPCServiceClass.class);
+	}
+    
     public void testMulitref1() throws AxisFault {
-        configureSystem("echoString");
+        RPCServiceClient sender = getRPCClient("EchoXMLService", "echoString");
         OMFactory fac = OMAbstractFactory.getOMFactory();
 
         OMNamespace omNs = fac.createOMNamespace(NAMESPACE, "my");
@@ -112,18 +82,9 @@
         ref.setText("hello Axis2");
         envelope.getBody().addChild(ref);
 
-        Options options = new Options();
-
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext = ConfigurationContextFactory
-                .createConfigurationContextFromFileSystem(null, null);
-        RPCServiceClient rpcClient = new RPCServiceClient(configContext, null);
-        rpcClient.setOptions(options);
-        MessageContext reqMessageContext = configContext.createMessageContext();
-        OperationClient opClinet = rpcClient.createClient(ServiceClient.ANON_OUT_IN_OP);
-        opClinet.setOptions(options);
+        MessageContext reqMessageContext = new MessageContext();
+        OperationClient opClinet = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
+      
         reqMessageContext.setEnvelope(envelope);
 
         opClinet.addMessageContext(reqMessageContext);
@@ -139,7 +100,7 @@
     }
 
     public void testadd() throws AxisFault {
-        configureSystem("add");
+        RPCServiceClient sender = getRPCClient("EchoXMLService", "add");
         OMFactory fac = OMAbstractFactory.getOMFactory();
 
         OMNamespace omNs = fac.createOMNamespace(NAMESPACE, "my");
@@ -166,17 +127,9 @@
         ref2.setText("10");
         envelope.getBody().addChild(ref2);
 
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext = ConfigurationContextFactory
-                .createConfigurationContextFromFileSystem(null, null);
-        RPCServiceClient rpcClient = new RPCServiceClient(configContext, null);
-        rpcClient.setOptions(options);
-        MessageContext reqMessageContext = configContext.createMessageContext();
-        OperationClient opClinet = rpcClient.createClient(ServiceClient.ANON_OUT_IN_OP);
-        opClinet.setOptions(options);
+        MessageContext reqMessageContext = new MessageContext();
+        OperationClient opClinet = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
+        
         reqMessageContext.setEnvelope(envelope);
 
         opClinet.addMessageContext(reqMessageContext);
@@ -192,7 +145,7 @@
     }
 
     public void testaddSameRef() throws AxisFault {
-        configureSystem("add");
+        RPCServiceClient sender = getRPCClient("EchoXMLService", "add");
         OMFactory fac = OMAbstractFactory.getOMFactory();
 
         OMNamespace omNs = fac.createOMNamespace(NAMESPACE, "my");
@@ -214,17 +167,9 @@
         ref.setText("10");
         envelope.getBody().addChild(ref);
 
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext = ConfigurationContextFactory
-                .createConfigurationContextFromFileSystem(null, null);
-        RPCServiceClient rpcClient = new RPCServiceClient(configContext, null);
-        rpcClient.setOptions(options);
-        MessageContext reqMessageContext = configContext.createMessageContext();
-        OperationClient opClinet = rpcClient.createClient(ServiceClient.ANON_OUT_IN_OP);
-        opClinet.setOptions(options);
+        MessageContext reqMessageContext = new MessageContext();
+        OperationClient opClinet = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
+        
         reqMessageContext.setEnvelope(envelope);
 
         opClinet.addMessageContext(reqMessageContext);
@@ -239,7 +184,7 @@
 
     public void testaddError() {
         try {
-            configureSystem("add");
+            RPCServiceClient sender = getRPCClient("EchoXMLService", "add");
             OMFactory fac = OMAbstractFactory.getOMFactory();
 
             OMNamespace omNs = fac.createOMNamespace(NAMESPACE, "my");
@@ -266,17 +211,9 @@
             ref2.setText("10");
             envelope.getBody().addChild(ref2);
 
-            Options options = new Options();
-            options.setTo(targetEPR);
-            options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-            ConfigurationContext configContext = ConfigurationContextFactory
-                    .createConfigurationContextFromFileSystem(null, null);
-            RPCServiceClient rpcClient = new RPCServiceClient(configContext, null);
-            rpcClient.setOptions(options);
-            MessageContext reqMessageContext = configContext.createMessageContext();;
-            OperationClient opClinet = rpcClient.createClient(ServiceClient.ANON_OUT_IN_OP);
-            opClinet.setOptions(options);
+            MessageContext reqMessageContext = new MessageContext();;
+            OperationClient opClinet = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
+            
             reqMessageContext.setEnvelope(envelope);
 
             opClinet.addMessageContext(reqMessageContext);
@@ -296,7 +233,7 @@
 
 
     public void testMulitrefBean() throws Exception {
-        configureSystem("editBean");
+        RPCServiceClient sender = getRPCClient("EchoXMLService", "editBean");
         OMFactory fac = OMAbstractFactory.getOMFactory();
 
         OMNamespace omNs = fac.createOMNamespace(NAMESPACE, "my");
@@ -328,17 +265,9 @@
         OMElement om4 = getOMElement(ref4, fac);
         envelope.getBody().addChild(om4);
 
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext = ConfigurationContextFactory
-                .createConfigurationContextFromFileSystem(null, null);
-        RPCServiceClient rpcClient = new RPCServiceClient(configContext, null);
-        rpcClient.setOptions(options);
-        MessageContext reqMessageContext = configContext.createMessageContext();
-        OperationClient opClinet = rpcClient.createClient(ServiceClient.ANON_OUT_IN_OP);
-        opClinet.setOptions(options);
+        MessageContext reqMessageContext = new MessageContext();
+        OperationClient opClinet = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
+        
         reqMessageContext.setEnvelope(envelope);
 
         opClinet.addMessageContext(reqMessageContext);
@@ -358,7 +287,7 @@
 
 
     public void testbeanOM() throws Exception {
-        configureSystem("beanOM");
+        RPCServiceClient sender = getRPCClient("EchoXMLService", "beanOM");
         OMFactory fac = OMAbstractFactory.getOMFactory();
 
         OMNamespace omNs = fac.createOMNamespace(NAMESPACE, "my");
@@ -390,17 +319,9 @@
         OMElement om4 = getOMElement(ref4, fac);
         envelope.getBody().addChild(om4);
 
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext = ConfigurationContextFactory
-                .createConfigurationContextFromFileSystem(null, null);
-        RPCServiceClient rpcClient = new RPCServiceClient(configContext, null);
-        rpcClient.setOptions(options);
-        MessageContext reqMessageContext = configContext.createMessageContext();;
-        OperationClient opClinet = rpcClient.createClient(ServiceClient.ANON_OUT_IN_OP);
-        opClinet.setOptions(options);
+        MessageContext reqMessageContext = new MessageContext();;
+        OperationClient opClinet = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
+        
         reqMessageContext.setEnvelope(envelope);
 
         opClinet.addMessageContext(reqMessageContext);
@@ -420,7 +341,7 @@
 
 
     public void testomrefs() throws Exception {
-        configureSystem("omrefs");
+        RPCServiceClient sender = getRPCClient("EchoXMLService", "omrefs");
         OMFactory fac = OMAbstractFactory.getOMFactory();
 
         OMNamespace omNs = fac.createOMNamespace(NAMESPACE, "my");
@@ -453,17 +374,10 @@
         String ref4 = "<reference id=\"4\">Colombo3</reference>";
         OMElement om4 = getOMElement(ref4, fac);
         envelope.getBody().addChild(om4);
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext = ConfigurationContextFactory
-                .createConfigurationContextFromFileSystem(null, null);
-        RPCServiceClient rpcClient = new RPCServiceClient(configContext, null);
-        rpcClient.setOptions(options);
-        MessageContext reqMessageContext = configContext.createMessageContext();;
-        OperationClient opClinet = rpcClient.createClient(ServiceClient.ANON_OUT_IN_OP);
-        opClinet.setOptions(options);
+        
+        MessageContext reqMessageContext = new MessageContext();;
+        OperationClient opClinet = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
+        
         reqMessageContext.setEnvelope(envelope);
 
         opClinet.addMessageContext(reqMessageContext);
@@ -495,7 +409,7 @@
 
 
     public void testechoEmployee() throws Exception {
-        configureSystem("echoEmployee");
+        RPCServiceClient sender = getRPCClient("EchoXMLService", "echoEmployee");
         OMFactory fac = OMAbstractFactory.getOMFactory();
 
         OMNamespace omNs = fac.createOMNamespace(NAMESPACE, "my");
@@ -523,16 +437,9 @@
                 "</reference>";
         envelope.getBody().addChild(getOMElement(str, fac));
 
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-        ConfigurationContext configContext = ConfigurationContextFactory
-                .createConfigurationContextFromFileSystem(null, null);
-        RPCServiceClient rpcClient = new RPCServiceClient(configContext, null);
-        rpcClient.setOptions(options);
-        MessageContext reqMessageContext = configContext.createMessageContext();
-        OperationClient opClinet = rpcClient.createClient(ServiceClient.ANON_OUT_IN_OP);
-        opClinet.setOptions(options);
+        MessageContext reqMessageContext = new MessageContext();
+        OperationClient opClinet = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
+        
         reqMessageContext.setEnvelope(envelope);
 
         opClinet.addMessageContext(reqMessageContext);
@@ -550,7 +457,7 @@
 
 
     public void testMulitrefArray() throws AxisFault {
-        configureSystem("handleArrayList");
+        RPCServiceClient sender = getRPCClient("EchoXMLService", "handleArrayList");
         OMFactory fac = OMAbstractFactory.getOMFactory();
 
         OMNamespace omNs = fac.createOMNamespace(NAMESPACE, "my");
@@ -589,18 +496,9 @@
         }
         envelope.getBody().addChild(staxOMBuilder.getDocumentElement());
 
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-
-        ConfigurationContext configContext = ConfigurationContextFactory
-                .createConfigurationContextFromFileSystem(null, null);
-        RPCServiceClient rpcClient = new RPCServiceClient(configContext, null);
-        rpcClient.setOptions(options);
-        MessageContext reqMessageContext = configContext.createMessageContext();
-        OperationClient opClinet = rpcClient.createClient(ServiceClient.ANON_OUT_IN_OP);
-        opClinet.setOptions(options);
+        MessageContext reqMessageContext = new MessageContext();
+        OperationClient opClinet = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
+        
         reqMessageContext.setEnvelope(envelope);
 
         opClinet.addMessageContext(reqMessageContext);

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java?view=diff&rev=548407&r1=548406&r2=548407
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
Mon Jun 18 09:37:54 2007
@@ -16,101 +16,41 @@
 */
 package org.apache.axis2.rpc;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import java.io.ByteArrayInputStream;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.databinding.utils.BeanUtil;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.InOutAxisOperation;
-import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.DefaultObjectSupplier;
-import org.apache.axis2.integration.UtilServer;
-import org.apache.axis2.integration.UtilServerBasedTestCase;
+import org.apache.axis2.integration.RPCLocalTestCase;
 import org.apache.axis2.rpc.client.RPCServiceClient;
-import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
-import org.apache.axis2.wsdl.WSDLConstants;
 
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-
-public class RPCCallTest extends UtilServerBasedTestCase {
+public class RPCCallTest extends RPCLocalTestCase {
 
     private SimpleDateFormat zulu = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
     //  0123456789 0 123456789
 
-
-    protected EndpointReference targetEPR;
-    protected QName serviceName = new QName("EchoXMLService");
-    protected QName operationName = new QName("http://org.apache.axis2/xsd", "concat");
-    protected QName transportName = new QName("http://org.apache.axis2/xsd",
-                                              "NullTransport");
-
-    protected AxisConfiguration engineRegistry;
-    protected MessageContext mc;
-    protected ServiceContext serviceContext;
-    protected AxisService service;
-
     protected boolean finish = false;
 
-    public RPCCallTest() {
-        super(RPCCallTest.class.getName());
-    }
-
-    public RPCCallTest(String testName) {
-        super(testName);
-    }
-
-    public static Test suite() {
-        return getTestSetup(new TestSuite(RPCCallTest.class));
-    }
-
-
     protected void setUp() throws Exception {
-        String className = "org.apache.axis2.rpc.RPCServiceClass";
-        UtilServer.start();
-        service = AxisService.createService(
-                className, UtilServer.getConfigurationContext().getAxisConfiguration());
-        service.setName("EchoXMLService");
-        service.setClassLoader(Thread.currentThread().getContextClassLoader());
-
-        UtilServer.deployService(service);
-    }
-
-    protected void tearDown() throws Exception {
-        UtilServer.unDeployService(serviceName);
-        UtilServer.unDeployClientService();
-    }
+		super.setUp();
+		deployClassAsService("EchoXMLService", RPCServiceClass.class);
+	}
 
     public void testEditBean() throws AxisFault {
-        configureSystem("editBean");
-
-        Options options = new Options();
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
-        options.setTo(targetEPR);
+        RPCServiceClient sender = getRPCClient("EchoXMLService", "editBean");
 
         MyBean bean = new MyBean();
         bean.setAge(100);
@@ -126,36 +66,15 @@
         args.add(bean);
         args.add("159");
 
-        OMElement response = sender.invokeBlocking(operationName, args.toArray());
+        OMElement response = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd",
"editBean", "req"), args.toArray());
         MyBean resBean = (MyBean)BeanUtil.deserialize(MyBean.class, response.getFirstElement(),
                                                       new DefaultObjectSupplier(), null);
         assertNotNull(resBean);
         assertEquals(resBean.getAge(), 159);
     }
 
-    private void configureSystem(String opName) {
-        targetEPR =
-                new EndpointReference("http://127.0.0.1:"
-                        + (UtilServer.TESTING_PORT)
-                        + "/axis2/services/EchoXMLService/" + opName);
-        operationName = new QName("http://rpc.axis2.apache.org/xsd", opName, "req");
-        AxisOperation axisOp = new InOutAxisOperation(operationName);
-        axisOp.setMessageReceiver(new RPCMessageReceiver());
-        axisOp.setStyle(WSDLConstants.STYLE_RPC);
-        service.addOperation(axisOp);
-    }
-
     public void testEchoBean() throws AxisFault {
-        configureSystem("echoBean");
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
+    	RPCServiceClient sender = getRPCClient("EchoXMLService", "echoBean");
 
         MyBean bean = new MyBean();
         bean.setAge(100);
@@ -170,7 +89,7 @@
         args.add(bean);
 
 
-        OMElement response = sender.invokeBlocking(operationName, args.toArray());
+        OMElement response = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd",
"echoBean", "req"), args.toArray());
         MyBean resBean = (MyBean)BeanUtil.deserialize(MyBean.class,
                                                       response.getFirstElement(),
                                                       new DefaultObjectSupplier(), null);
@@ -180,16 +99,7 @@
     }
 
     public void testechoMail() throws AxisFault {
-        configureSystem("echoMail");
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
+    	RPCServiceClient sender = getRPCClient("EchoXMLService", "echoMail");
 
         Mail mail = new Mail();
         mail.setBody("My Body");
@@ -203,7 +113,7 @@
         args.add(mail);
 
 
-        OMElement response = sender.invokeBlocking(operationName, args.toArray());
+        OMElement response = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd",
"echoMail", "req"), args.toArray());
         Mail resBean = (Mail)BeanUtil.deserialize(Mail.class, response.getFirstElement(),
                                                   new DefaultObjectSupplier(), null);
 //        MyBean resBean =(MyBean) new  BeanSerializer(MyBean.class,response).deserilze();
@@ -213,149 +123,79 @@
 
 
     public void testEchoString() throws AxisFault {
-        configureSystem("echoString");
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
+    	RPCServiceClient sender = getRPCClient("EchoXMLService", "echoString");
 
         ArrayList args = new ArrayList();
         args.add("foo");
-        OMElement response = sender.invokeBlocking(operationName, args.toArray());
+        OMElement response = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd",
"echoString", "req"), args.toArray());
         assertEquals(response.getFirstElement().getText(), "foo");
     }
 
     public void testEchoInt() throws AxisFault {
-        configureSystem("echoInt");
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
+    	RPCServiceClient sender = getRPCClient("EchoXMLService", "echoInt");
 
         ArrayList args = new ArrayList();
         args.add("100");
 
-        OMElement response = sender.invokeBlocking(operationName, args.toArray());
+        OMElement response = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd",
"echoInt", "req"), args.toArray());
         assertEquals(Integer.parseInt(response.getFirstElement().getText()), 100);
     }
 
     public void testAdd() throws AxisFault {
-        configureSystem("add");
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-        sender.setOptions(options);
+    	RPCServiceClient sender = getRPCClient("EchoXMLService", "add");
+    	
         ArrayList args = new ArrayList();
         args.add("100");
         args.add("200");
 
-        OMElement response = sender.invokeBlocking(operationName, args.toArray());
+        OMElement response = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd",
"add", "req"), args.toArray());
         assertEquals(Integer.parseInt(response.getFirstElement().getText()), 300);
     }
 
     public void testByteArray() throws AxisFault {
-        configureSystem("testByteArray");
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-        sender.setOptions(options);
+    	RPCServiceClient sender = getRPCClient("EchoXMLService", "testByteArray");
+    	
         ArrayList args = new ArrayList();
         String hello = "hello";
         args.add(hello.getBytes());
 
-        OMElement response = sender.invokeBlocking(operationName, args.toArray());
+        OMElement response = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd",
"testByteArray", "req"), args.toArray());
         assertEquals(response.getFirstElement().getText(), hello);
     }
 
     //
 
     public void testDivide() throws AxisFault {
-        configureSystem("divide");
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
-
+    	RPCServiceClient sender = getRPCClient("EchoXMLService", "divide");
 
         ArrayList args = new ArrayList();
         args.add("10");
         args.add("0");
-        OMElement response = sender.invokeBlocking(operationName, args.toArray());
+        OMElement response = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd",
"divide", "req"), args.toArray());
         assertEquals(response.getFirstElement().getText(), "INF");
     }
 
     public void testEchoBool() throws AxisFault {
-        configureSystem("echoBool");
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
+        RPCServiceClient sender = getRPCClient("EchoXMLService", "echoBool");
 
         ArrayList args = new ArrayList();
         args.add("true");
 
-        OMElement response = sender.invokeBlocking(operationName, args.toArray());
+        OMElement response = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd",
"echoBool", "req"), args.toArray());
         assertEquals(Boolean.valueOf(response.getFirstElement().getText()).booleanValue(),
true);
     }
 
     public void testEchoByte() throws AxisFault {
-        configureSystem("echoByte");
-
-        Options options = new Options();
-
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
+    	RPCServiceClient sender = getRPCClient("EchoXMLService", "echoByte");
 
         ArrayList args = new ArrayList();
         args.add("1");
-        OMElement response = sender.invokeBlocking(operationName, args.toArray());
+        OMElement response = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd",
"echoByte", "req"), args.toArray());
         assertEquals(Byte.parseByte(response.getFirstElement().getText()), 1);
     }
 
     public void testCompany() throws AxisFault {
-        configureSystem("echoCompany");
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
+    	RPCServiceClient sender = getRPCClient("EchoXMLService", "echoCompany");
 
         Company com = new Company();
         com.setName("MyCompany");
@@ -380,21 +220,12 @@
         com.setPersons(ps);
         ArrayList args = new ArrayList();
         args.add(com);
-        sender.invokeBlocking(operationName, args.toArray());
+        sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd", "echoCompany",
"req"), args.toArray());
     }
 
 
     public void testtestCompany() throws AxisFault {
-        configureSystem("testCompanyArray");
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
+    	RPCServiceClient sender = getRPCClient("EchoXMLService", "testCompanyArray");
 
         Company com = new Company();
         com.setName("MyCompany");
@@ -425,21 +256,12 @@
 
         ArrayList req = new ArrayList();
         req.add(args.toArray());
-        OMElement value = sender.invokeBlocking(operationName, req.toArray());
+        OMElement value = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd",
"testCompanyArray", "req"), req.toArray());
         assertEquals("4", value.getFirstElement().getText());
     }
 
     public void testCompanyArray() throws AxisFault {
-        configureSystem("CompanyArray");
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
+    	RPCServiceClient sender = getRPCClient("EchoXMLService", "CompanyArray");
 
         Company com = new Company();
         com.setName("MyCompany");
@@ -475,7 +297,7 @@
         resobj.add(Company.class);
         resobj.add(Company.class);
         resobj.add(Company.class);
-        Object [] value = sender.invokeBlocking(operationName, req.toArray(),
+        Object [] value = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd",
"CompanyArray", "req"), req.toArray(),
                                                 (Class[])resobj.toArray(new Class[resobj.size()]));
         assertEquals(4, value.length);
         assertEquals(((Company)value[0]).getName(), "MyCompany");
@@ -483,56 +305,29 @@
 
 
     public void testEchoOM() throws AxisFault {
-        configureSystem("echoOM");
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
+    	RPCServiceClient sender = getRPCClient("EchoXMLService", "echoOM");
 
         ArrayList args = new ArrayList();
         args.add("1");
-        OMElement response = sender.invokeBlocking(operationName, args.toArray());
+        OMElement response = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd",
"echoOM", "req"), args.toArray());
         assertEquals(Byte.parseByte(response.getFirstElement().getFirstElement().getText()),
1);
     }
 
     public void testCalender() throws AxisFault {
         zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
-        configureSystem("echoCalander");
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
+        RPCServiceClient sender = getRPCClient("EchoXMLService", "echoCalander");
 
         ArrayList args = new ArrayList();
         Date date = Calendar.getInstance().getTime();
         args.add(zulu.format(date));
-        OMElement response = sender.invokeBlocking(operationName, args.toArray());
+        OMElement response = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd",
"echoCalander", "req"), args.toArray());
         assertEquals(response.getFirstElement().getText(), zulu.format(date));
     }
 
 
     ////////////////////////////////////////////////// Invoking by Passing Return types //////////
     public void testechoBean2() throws AxisFault {
-        configureSystem("echoBean");
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
+    	RPCServiceClient sender = getRPCClient("EchoXMLService", "echoBean");
 
         MyBean bean = new MyBean();
         bean.setAge(100);
@@ -549,7 +344,7 @@
         ArrayList ret = new ArrayList();
         ret.add(MyBean.class);
 
-        Object [] response = sender.invokeBlocking(operationName, args.toArray(),
+        Object [] response = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd",
"echoBean", "req"), args.toArray(),
                                                    (Class[])ret.toArray(new Class[ret.size()]));
         MyBean resBean = (MyBean)response[0];
         assertNotNull(resBean);
@@ -557,16 +352,7 @@
     }
 
     public void testechoInt2() throws AxisFault {
-        configureSystem("echoInt");
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
+    	RPCServiceClient sender = getRPCClient("EchoXMLService", "echoInt");
 
         ArrayList args = new ArrayList();
         args.add("100");
@@ -574,7 +360,7 @@
         ArrayList ret = new ArrayList();
         ret.add(Integer.class);
 
-        Object [] response = sender.invokeBlocking(operationName, args.toArray(),
+        Object [] response = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd",
"echoInt", "req"), args.toArray(),
                                                    (Class[])ret.toArray(new Class[ret.size()]));
         assertEquals(((Integer)response[0]).intValue(), 100);
     }
@@ -604,40 +390,22 @@
 //    }
 
     public void testStringArray() throws AxisFault {
-        configureSystem("handleStringArray");
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
+    	RPCServiceClient sender = getRPCClient("EchoXMLService", "handleStringArray");
 
         ArrayList args = new ArrayList();
         String [] values = new String[] { "abc", "cde", "efg" };
         args.add(values);
         ArrayList ret = new ArrayList();
         ret.add(Boolean.class);
-        Object [] objs = sender.invokeBlocking(operationName, args.toArray(),
+        Object [] objs = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd",
"handleStringArray", "req"), args.toArray(),
                                                (Class[])ret.toArray(new Class[ret.size()]));
         assertNotNull(objs);
         assertEquals(Boolean.TRUE, Boolean.valueOf(objs[0].toString()));
     }
 
     public void testmultiArrays() throws AxisFault {
-        configureSystem("multiArrays");
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
-
+    	RPCServiceClient sender = getRPCClient("EchoXMLService", "multiArrays");
+    	
         ArrayList args = new ArrayList();
         String [] values = new String[] { "abc", "cde", "efg" };
         args.add(values);
@@ -650,52 +418,35 @@
 
         ArrayList ret = new ArrayList();
         ret.add(Integer.class);
-        Object [] objs = sender.invokeBlocking(operationName, args.toArray(),
+        Object [] objs = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd",
"multiArrays", "req"), args.toArray(),
                                                (Class[])ret.toArray(new Class[ret.size()]));
         assertNotNull(objs);
         assertEquals(19, Integer.parseInt(objs[0].toString()));
     }
 
     public void testmulReturn() throws AxisFault {
-        configureSystem("mulReturn");
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
+    	RPCServiceClient sender = getRPCClient("EchoXMLService", "mulReturn");
 
         ArrayList args = new ArrayList();
         args.add("foo");
 
 
-        OMElement element = sender.invokeBlocking(operationName, args.toArray());
+        OMElement element = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org/xsd",
"mulReturn", "req"), args.toArray());
         System.out.println("element = " + element);
 //        assertEquals(response.getFirstElement().getText(), "foo");
     }
 
 
     public void testhandleArrayList() throws Exception {
-        configureSystem("handleArrayList");
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
+    	RPCServiceClient sender = getRPCClient("EchoXMLService", "handleArrayList");
 
         OMElement elem = sender.sendReceive(getPayload());
         assertEquals(elem.getFirstElement().getText(), "abcdefghiklm10");
     }
 
     public void testomElementArray() throws Exception {
-        configureSystem("omElementArray");
+        RPCServiceClient sender = getRPCClient("EchoXMLService", "omElementArray");
+        
         String str = "<req:omElementArray xmlns:req=\"http://rpc.axis2.apache.org/xsd\">\n"
+
                 "    <arg0><abc>vaue1</abc></arg0>\n" +
                 "    <arg0><abc>vaue2</abc></arg0>\n" +
@@ -708,14 +459,6 @@
         OMFactory fac = OMAbstractFactory.getOMFactory();
 
         staxOMBuilder = new StAXOMBuilder(fac, xmlReader);
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
-        RPCServiceClient sender = new RPCServiceClient(configContext, null);
-        sender.setOptions(options);
 
         OMElement elem = sender.sendReceive(staxOMBuilder.getDocumentElement());
         assertEquals("4", elem.getFirstElement().getText());



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message