You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by he...@apache.org on 2005/05/25 07:51:42 UTC

svn commit: r178379 - in /webservices/axis/trunk/java/modules: core/src/org/apache/axis/Constants.java core/src/org/apache/axis/clientapi/InOutMEPClient.java samples/test/org/apache/axis/engine/EchoRawXMLOnTwoChannelsSyncTest.java samples/test/org/apache/axis/engine/EchoRawXMLOnTwoChannelsTest.java

Author: hemapani
Date: Tue May 24 22:51:41 2005
New Revision: 178379

URL: http://svn.apache.org/viewcvs?rev=178379&view=rev
Log:
add a test cases for two channel, Sync

Added:
    webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLOnTwoChannelsSyncTest.java
Modified:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/Constants.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java
    webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLOnTwoChannelsTest.java

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/Constants.java?rev=178379&r1=178378&r2=178379&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/Constants.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/Constants.java Tue May 24 22:51:41 2005
@@ -107,7 +107,7 @@
 
 
 
-
+    public static final String MODULE_ADDRESSING = "addressing";
 
 
     /**

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java?rev=178379&r1=178378&r2=178379&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java Tue May 24 22:51:41 2005
@@ -111,9 +111,7 @@
     //        throw new UnsupportedOperationException();
     //    }
 
-    public MessageContext invokeBlocking(
-        OperationDescription axisop,
-        final MessageContext msgctx)
+    public MessageContext invokeBlocking(OperationDescription axisop, final MessageContext msgctx)
         throws AxisFault {
         verifyInvocation(axisop);
         if (useSeparateListener) {
@@ -133,12 +131,7 @@
             }
             if (callback.envelope != null) {
                 MessageContext resMsgctx =
-                    new MessageContext(
-                        serviceContext.getEngineContext(),
-                        null,
-                        null,
-                        null,
-                        null);
+                    new MessageContext(serviceContext.getEngineContext(), null, null, null, null);
                 resMsgctx.setEnvelope(callback.envelope);
                 return resMsgctx;
             } else {
@@ -164,13 +157,11 @@
                     false,
                     axisop,
                     serviceContext));
-            MessageContext response =
-                TwoChannelBasedSender.send(msgctx, listenerTransport);
+            MessageContext response = TwoChannelBasedSender.send(msgctx, listenerTransport);
 
             SOAPEnvelope resenvelope = response.getEnvelope();
             if (resenvelope.getBody().hasFault()) {
-                throw new AxisFault(
-                    resenvelope.getBody().getFault().getException());
+                throw new AxisFault(resenvelope.getBody().getFault().getException());
             }
             return response;
         }
@@ -184,8 +175,7 @@
         verifyInvocation(axisop);
         msgctx.setTo(to);
         try {
-            final ConfigurationContext syscontext =
-                serviceContext.getEngineContext();
+            final ConfigurationContext syscontext = serviceContext.getEngineContext();
 
             AxisEngine engine = new AxisEngine(syscontext);
             //TODO
@@ -198,10 +188,7 @@
                 callbackReceiver.addCallback(messageID, callback);
                 msgctx.setReplyTo(
                     ListenerManager.replyToEPR(
-                        serviceContext
-                            .getServiceConfig()
-                            .getName()
-                            .getLocalPart()
+                        serviceContext.getServiceConfig().getName().getLocalPart()
                             + "/"
                             + axisop.getName().getLocalPart(),
                         listenerTransport));
@@ -223,9 +210,7 @@
                                     serviceContext));
                             msgctx.setServiceContext(serviceContext);
                             MessageContext response =
-                                TwoChannelBasedSender.send(
-                                    msgctx,
-                                    listenerTransport);
+                                TwoChannelBasedSender.send(msgctx, listenerTransport);
                             SOAPEnvelope resenvelope = response.getEnvelope();
                             AsyncResult asyncResult = new AsyncResult();
                             asyncResult.setResult(resenvelope);
@@ -334,27 +319,19 @@
         }
 
         if (useSeparateListener == true) {
-            ListenerManager.makeSureStarted(
-                listenerTransport,
-                serviceContext.getEngineContext());
+            ListenerManager.makeSureStarted(listenerTransport, serviceContext.getEngineContext());
         }
     }
 
-    private SOAPEnvelope checkReturnChannel(MessageContext response)
-        throws AxisFault {
+    private SOAPEnvelope checkReturnChannel(MessageContext response) throws AxisFault {
         SOAPEnvelope resenvelope = null;
         try {
             //TODO Fix this we support only the HTTP Sync cases, so we hardcode this
             if (Constants.TRANSPORT_HTTP.equals(listenerTransport)) {
                 HTTPTransportReceiver receiver = new HTTPTransportReceiver();
-                resenvelope =
-                    receiver.checkForMessage(
-                        response,
-                        serviceContext.getEngineContext());
+                resenvelope = receiver.checkForMessage(response, serviceContext.getEngineContext());
             } else if (Constants.TRANSPORT_TCP.equals(listenerTransport)) {
-                Reader in =
-                    (Reader) response.getProperty(
-                        MessageContext.TRANSPORT_READER);
+                Reader in = (Reader) response.getProperty(MessageContext.TRANSPORT_READER);
                 if (in != null) {
                     XMLStreamReader xmlreader =
                         XMLInputFactory.newInstance().createXMLStreamReader(in);
@@ -385,10 +362,7 @@
 
         if (msgctx.getTransportIn() == null) {
             final TransportInDescription transportIn =
-                serviceContext
-                    .getEngineContext()
-                    .getEngineConfig()
-                    .getTransportIn(
+                serviceContext.getEngineContext().getEngineConfig().getTransportIn(
                     new QName(senderTransport));
             if (transportIn != null) {
                 msgctx.setTransportIn(transportIn);
@@ -399,10 +373,7 @@
         }
         if (msgctx.getTransportOut() == null) {
             final TransportOutDescription transportOut =
-                serviceContext
-                    .getEngineContext()
-                    .getEngineConfig()
-                    .getTransportOut(
+                serviceContext.getEngineContext().getEngineConfig().getTransportOut(
                     new QName(listenerTransport));
             if (transportOut != null) {
                 msgctx.setTransportOut(transportOut);
@@ -426,6 +397,10 @@
         public boolean hasResult() {
             return envelope != null || error != null;
         }
+    }
+
+    public void engageModule(QName moduleName) throws AxisFault {
+        serviceContext.getEngineContext().getEngineConfig().engageModule(moduleName);
     }
 
 }

Added: webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLOnTwoChannelsSyncTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLOnTwoChannelsSyncTest.java?rev=178379&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLOnTwoChannelsSyncTest.java (added)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLOnTwoChannelsSyncTest.java Tue May 24 22:51:41 2005
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * 
+ * 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.axis.engine;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.axis.Constants;
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.context.ServiceContext;
+import org.apache.axis.description.ServiceDescription;
+import org.apache.axis.integration.UtilServer;
+import org.apache.axis.om.OMAbstractFactory;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.soap.SOAPEnvelope;
+import org.apache.axis.soap.SOAPFactory;
+import org.apache.axis.transport.http.SimpleHTTPServer;
+import org.apache.axis.util.Utils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class EchoRawXMLOnTwoChannelsSyncTest extends TestCase {
+    private EndpointReference targetEPR =
+        new EndpointReference(
+            AddressingConstants.WSA_TO,
+            "http://127.0.0.1:"
+                + (UtilServer.TESTING_PORT)
+                + "/axis/services/EchoXMLService/echoOMElement");
+    private Log log = LogFactory.getLog(getClass());
+    private QName serviceName = new QName("EchoXMLService");
+    private QName operationName = new QName("echoOMElement");
+    private QName transportName = new QName("http://localhost/my", "NullTransport");
+
+    private AxisConfiguration engineRegistry;
+    private MessageContext mc;
+    private Thread thisThread;
+    private SimpleHTTPServer sas;
+    private ServiceContext serviceContext;
+
+    private boolean finish = false;
+
+    public EchoRawXMLOnTwoChannelsSyncTest() {
+        super(EchoRawXMLOnTwoChannelsSyncTest.class.getName());
+    }
+
+    public EchoRawXMLOnTwoChannelsSyncTest(String testName) {
+        super(testName);
+    }
+
+    protected void setUp() throws Exception {
+        UtilServer.start();
+        UtilServer.getConfigurationContext().getEngineConfig().engageModule(
+            new QName("addressing"));
+
+        ServiceDescription service =
+            Utils.createSimpleService(
+                serviceName,
+                org.apache.axis.engine.Echo.class.getName(),
+                operationName);
+        UtilServer.deployService(service);
+        serviceContext =
+            UtilServer.getConfigurationContext().createServiceContext(service.getName());
+
+    }
+
+    protected void tearDown() throws Exception {
+        UtilServer.unDeployService(serviceName);
+        UtilServer.stop();
+    }
+
+    private SOAPEnvelope createEnvelope(SOAPFactory fac) {
+        SOAPEnvelope reqEnv = fac.getDefaultEnvelope();
+        OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
+        OMElement method = fac.createOMElement("echoOMElement", omNs);
+        OMElement value = fac.createOMElement("myValue", omNs);
+        value.addChild(fac.createText(value, "Isaac Assimov, the foundation Sega"));
+        method.addChild(value);
+        reqEnv.getBody().addChild(method);
+        return reqEnv;
+    }
+
+
+
+    public void testEchoXMLCompleteSync() throws Exception {
+        ServiceDescription service =
+            Utils.createSimpleService(
+                serviceName,
+                org.apache.axis.engine.Echo.class.getName(),
+                operationName);
+
+        ServiceContext serviceContext = UtilServer.createAdressedEnabledClientSide(service);
+
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+
+        OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
+        OMElement method = fac.createOMElement("echoOMElement", omNs);
+        OMElement value = fac.createOMElement("myValue", omNs);
+        value.setText("Isaac Assimov, the foundation Sega");
+        method.addChild(value);
+
+        org.apache.axis.clientapi.Call call = new org.apache.axis.clientapi.Call(serviceContext);
+        call.setTo(targetEPR);
+        call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, true);
+
+        OMElement result = (OMElement) call.invokeBlocking(operationName.getLocalPart(), method);
+        result.serializeWithCache(XMLOutputFactory.newInstance().createXMLStreamWriter(System.out));
+
+    }
+
+}

Modified: webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLOnTwoChannelsTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLOnTwoChannelsTest.java?rev=178379&r1=178378&r2=178379&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLOnTwoChannelsTest.java (original)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLOnTwoChannelsTest.java Tue May 24 22:51:41 2005
@@ -16,8 +16,6 @@
 
 package org.apache.axis.engine;
 
-import java.io.File;
-
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamException;
@@ -29,12 +27,8 @@
 import org.apache.axis.addressing.EndpointReference;
 import org.apache.axis.clientapi.AsyncResult;
 import org.apache.axis.clientapi.Callback;
-import org.apache.axis.context.ConfigurationContext;
-import org.apache.axis.context.ConfigurationContextFactory;
 import org.apache.axis.context.MessageContext;
 import org.apache.axis.context.ServiceContext;
-import org.apache.axis.deployment.DeploymentEngine;
-import org.apache.axis.description.ModuleDescription;
 import org.apache.axis.description.ServiceDescription;
 import org.apache.axis.integration.UtilServer;
 import org.apache.axis.om.OMAbstractFactory;
@@ -109,27 +103,14 @@
     }
 
     public void testEchoXMLCompleteASync() throws Exception {
-//        DeploymentEngine deploymentEngine = new DeploymentEngine();
-//        File file = new File(UtilServer.TESTING_REPOSITORY + "/addressing.mar");
-//        assertTrue(file.exists());
-//        ModuleDescription moduleDesc = deploymentEngine.buildModule(file);
-//
-//        ConfigurationContextFactory efac = new ConfigurationContextFactory();
-//        ConfigurationContext sysContext = efac.buildClientEngineContext(null);
-//        new ConfigurationContext(new AxisConfigurationImpl());
-//        sysContext.getEngineConfig().addMdoule(moduleDesc);
-//        sysContext.getEngineConfig().engageModule(moduleDesc.getName());
         ServiceDescription service =
             Utils.createSimpleService(
                 serviceName,
                 org.apache.axis.engine.Echo.class.getName(),
                 operationName);
-//        sysContext.getEngineConfig().addService(service);
-//        Utils.resolvePhases(sysContext.getEngineConfig(), service);
-//        ServiceContext serviceContext = sysContext.createServiceContext(service.getName());
+
         ServiceContext serviceContext = UtilServer.createAdressedEnabledClientSide(service);
-        
-        
+
         OMFactory fac = OMAbstractFactory.getOMFactory();
 
         OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
@@ -139,6 +120,7 @@
         method.addChild(value);
 
         org.apache.axis.clientapi.Call call = new org.apache.axis.clientapi.Call(serviceContext);
+        // call.engageModule(new QName(Constants.MODULE_ADDRESSING));
 
         call.setTo(targetEPR);
         call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, true);
@@ -174,4 +156,5 @@
 
     }
 
+ 
 }