axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prad...@apache.org
Subject svn commit: r518353 - in /webservices/axis2/trunk/java/modules: integration/test/org/apache/axis2/addressing/ kernel/src/org/apache/axis2/util/
Date Wed, 14 Mar 2007 22:09:10 GMT
Author: pradine
Date: Wed Mar 14 15:09:09 2007
New Revision: 518353

URL: http://svn.apache.org/viewvc?view=rev&rev=518353
Log:
Fix for AXIS2-2301.

Added:
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/addressing/AddressingFinalServiceTest.java
      - copied, changed from r511992, webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/addressing/AddressingServiceTest.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/addressing/AddressingSubmissionServiceTest.java
Removed:
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/addressing/AddressingServiceTest.java
Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/MessageContextBuilder.java

Copied: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/addressing/AddressingFinalServiceTest.java
(from r511992, webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/addressing/AddressingServiceTest.java)
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/addressing/AddressingFinalServiceTest.java?view=diff&rev=518353&p1=webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/addressing/AddressingServiceTest.java&r1=511992&p2=webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/addressing/AddressingFinalServiceTest.java&r2=518353
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/addressing/AddressingServiceTest.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/addressing/AddressingFinalServiceTest.java
Wed Mar 14 15:09:09 2007
@@ -8,7 +8,6 @@
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.AddressingConstants.Final;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.context.ConfigurationContext;
@@ -44,7 +43,7 @@
 *
 */
 
-public class AddressingServiceTest extends UtilServerBasedTestCase implements TestConstants
{
+public class AddressingFinalServiceTest extends UtilServerBasedTestCase implements TestConstants
{
 
     protected QName transportName = new QName("http://localhost/my",
             "NullTransport");
@@ -64,7 +63,7 @@
     protected AxisService rrService;
 
     public static Test suite() {
-        return getTestSetup(new TestSuite(AddressingServiceTest.class));
+        return getTestSetup(new TestSuite(AddressingFinalServiceTest.class));
     }
 
     protected void setUp() throws Exception {
@@ -248,5 +247,44 @@
         sender.setOptions(options);
 
         return sender;
+    }
+
+    private ServiceClient createSyncResponseServiceClient() throws AxisFault {
+        AxisService service =
+                Utils.createSimpleServiceforClient(serviceName,
+                        Echo.class.getName(),
+                        operationName);
+
+        ConfigurationContext configcontext = UtilServer.createClientConfigurationContext();
+        ServiceClient sender;
+
+        Options options = new Options();
+        options.setTo(targetEPR);
+        options.setAction(operationName.getLocalPart());
+
+        sender = new ServiceClient(configcontext, service);
+        sender.setOptions(options);
+        sender.engageModule(new QName("addressing"));
+
+        return sender;
+    }
+
+    public void testSyncResponseAddressing() throws Exception {
+        String test = "hello.";
+        OMElement method = createEchoOMElement(test);
+        ServiceClient sender = null;
+
+        try {
+            sender = createSyncResponseServiceClient();
+            OMElement result = sender.sendReceive(operationName, method);
+            System.out.println("echoOMElementResponse: "+result);
+            QName name = new QName("http://localhost/my", "myValue");
+            String value = result.getFirstChildWithName(name).getText();
+            
+            assertEquals(test, value);
+        } finally {
+            if (sender != null)
+                sender.cleanup();
+        }
     }
 }

Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/addressing/AddressingSubmissionServiceTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/addressing/AddressingSubmissionServiceTest.java?view=auto&rev=518353
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/addressing/AddressingSubmissionServiceTest.java
(added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/addressing/AddressingSubmissionServiceTest.java
Wed Mar 14 15:09:09 2007
@@ -0,0 +1,250 @@
+package org.apache.axis2.addressing;
+
+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;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.description.*;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.Echo;
+import org.apache.axis2.engine.util.TestConstants;
+import org.apache.axis2.integration.UtilServer;
+import org.apache.axis2.integration.UtilServerBasedTestCase;
+import org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver;
+import org.apache.axis2.receivers.RawXMLINOutMessageReceiver;
+import org.apache.axis2.util.Utils;
+import org.apache.axis2.wsdl.WSDLConstants;
+
+import javax.xml.namespace.QName;
+/*
+* Copyright 2004,2005,2006 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.
+*
+*
+*/
+
+public class AddressingSubmissionServiceTest extends UtilServerBasedTestCase implements TestConstants
{
+
+    protected QName transportName = new QName("http://localhost/my",
+            "NullTransport");
+    EndpointReference targetEPR = new EndpointReference(
+            "http://127.0.0.1:" + (UtilServer.TESTING_PORT) + "/axis2/services/EchoXMLService/echoOMElement");
+
+    EndpointReference replyTo = new EndpointReference(
+            "http://127.0.0.1:" + (UtilServer.TESTING_PORT) + "/axis2/services/RedirectReceiverService/echoOMElementResponse");
+
+    EndpointReference faultTo = new EndpointReference(
+            "http://127.0.0.1:" + (UtilServer.TESTING_PORT) + "/axis2/services/RedirectReceiverService/fault");
+
+    protected AxisConfiguration engineRegistry;
+    protected MessageContext mc;
+    protected ServiceContext serviceContext;
+    protected AxisService echoService;
+    protected AxisService rrService;
+
+    public static Test suite() {
+        return getTestSetup(new TestSuite(AddressingSubmissionServiceTest.class));
+    }
+
+    protected void setUp() throws Exception {
+        echoService = Utils.createSimpleService(serviceName,
+                new RawXMLINOutMessageReceiver(),
+                Echo.class.getName(),
+                operationName);
+        echoService.getOperation(operationName).setOutputAction("echoOMElementResponse");
+        UtilServer.deployService(echoService);
+
+        rrService = createRedirectReceiverService();
+        UtilServer.deployService(rrService);
+    }
+
+    AxisService createRedirectReceiverService() throws AxisFault {
+        AxisService service = new AxisService("RedirectReceiverService");
+
+        service.setClassLoader(Thread.currentThread().getContextClassLoader());
+        service.addParameter(new Parameter(Constants.SERVICE_CLASS, RedirectReceiver.class.getName()));
+
+        AxisOperation axisOp = new InOnlyAxisOperation(new QName("echoOMElementResponse"));
+
+        axisOp.setMessageReceiver(new RawXMLINOnlyMessageReceiver());
+        axisOp.setStyle(WSDLConstants.STYLE_RPC);
+        service.addOperation(axisOp);
+        service.mapActionToOperation(Constants.AXIS2_NAMESPACE_URI + "/" + "echoOMElementResponse",
axisOp);
+
+        AxisOperation axisOp2 = new InOnlyAxisOperation(new QName("fault"));
+
+        axisOp2.setMessageReceiver(new RawXMLINOnlyMessageReceiver());
+        axisOp2.setStyle(WSDLConstants.STYLE_RPC);
+        service.addOperation(axisOp2);
+        service.mapActionToOperation(Constants.AXIS2_NAMESPACE_URI + "/" + "fault", axisOp2);
+
+        return service;
+    }
+
+    protected void tearDown() throws Exception {
+        UtilServer.unDeployService(serviceName);
+        UtilServer.unDeployService(new QName("RedirectReceiverService"));
+        UtilServer.unDeployClientService();
+    }
+
+    public static AxisService createSimpleOneWayServiceforClient(QName serviceName,
+                                                                 String className,
+                                                                 QName opName)
+            throws AxisFault {
+        AxisService service = new AxisService(serviceName.getLocalPart());
+
+        service.setClassLoader(Thread.currentThread().getContextClassLoader());
+        service.addParameter(new Parameter(Constants.SERVICE_CLASS, className));
+
+        AxisOperation axisOp = new OutOnlyAxisOperation(opName);
+
+        axisOp.setMessageReceiver(new RawXMLINOnlyMessageReceiver());
+        axisOp.setStyle(WSDLConstants.STYLE_RPC);
+        service.addOperation(axisOp);
+
+        return service;
+    }
+
+    public void testEchoToReplyTo() throws Exception {
+        OMElement method = createEchoOMElement("this message should not cause a fault.");
+        ServiceClient sender = null;
+
+        try {
+            sender = createServiceClient();
+            sender.fireAndForget(operationName, method);
+            System.out.println("send the reqest");
+            int index = 0;
+            while (!RedirectReceiver.hasReceivedResponse()) {
+                Thread.sleep(100);
+                index++;
+                if (index > 45) {
+                    throw new AxisFault(
+                            "Tests was failed as redirected response not received in time");
+                }
+            }
+        } finally {
+            if (sender != null)
+                sender.cleanup();
+        }
+    }
+
+    public void testFaultToFaultTo() throws Exception {
+        OMElement method = createEchoOMElement("fault");
+        ServiceClient sender = null;
+
+        try {
+            sender = createServiceClient();
+            sender.fireAndForget(operationName, method);
+            System.out.println("send the reqest");
+            int index = 0;
+            while (!RedirectReceiver.hasReceivedFault()) {
+                Thread.sleep(100);
+                index++;
+                if (index > 45) {
+                    throw new AxisFault(
+                            "Tests was failed as redirected fault not received in time");
+                }
+            }
+        } finally {
+            if (sender != null)
+                sender.cleanup();
+        }
+    }
+
+    private OMElement createEchoOMElement(String text) {
+        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(text);
+        method.addChild(value);
+
+        return method;
+    }
+
+    private ServiceClient createServiceClient() throws AxisFault {
+        AxisService service =
+                createSimpleOneWayServiceforClient(serviceName,
+                        Echo.class.getName(),
+                        operationName);
+
+        ConfigurationContext configcontext = UtilServer.createClientConfigurationContext();
+
+        ServiceClient sender;
+
+        Options options = new Options();
+        options.setTo(targetEPR);
+        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+        options.setAction(operationName.getLocalPart());
+        options.setReplyTo(replyTo);
+        options.setFaultTo(faultTo);
+        options.setProperty(AddressingConstants.WS_ADDRESSING_VERSION, AddressingConstants.Submission.WSA_NAMESPACE);
+
+        sender = new ServiceClient(configcontext, service);
+        sender.setOptions(options);
+        sender.engageModule(new QName("addressing"));
+
+        return sender;
+    }
+
+    private ServiceClient createSyncResponseServiceClient() throws AxisFault {
+        AxisService service =
+                Utils.createSimpleServiceforClient(serviceName,
+                        Echo.class.getName(),
+                        operationName);
+
+        ConfigurationContext configcontext = UtilServer.createClientConfigurationContext();
+        ServiceClient sender;
+
+        Options options = new Options();
+        options.setTo(targetEPR);
+        options.setAction(operationName.getLocalPart());
+        options.setProperty(AddressingConstants.WS_ADDRESSING_VERSION, AddressingConstants.Submission.WSA_NAMESPACE);
+
+        sender = new ServiceClient(configcontext, service);
+        sender.setOptions(options);
+        sender.engageModule(new QName("addressing"));
+
+        return sender;
+    }
+
+    public void testSyncResponseAddressing() throws Exception {
+        String test = "hello.";
+        OMElement method = createEchoOMElement(test);
+        ServiceClient sender = null;
+
+        try {
+            sender = createSyncResponseServiceClient();
+            OMElement result = sender.sendReceive(operationName, method);
+            System.out.println("echoOMElementResponse: "+result);
+            QName name = new QName("http://localhost/my", "myValue");
+            String value = result.getFirstChildWithName(name).getText();
+            
+            assertEquals(test, value);
+        } finally {
+            if (sender != null)
+                sender.cleanup();
+        }
+    }
+}

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/MessageContextBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/MessageContextBuilder.java?view=diff&rev=518353&r1=518352&r2=518353
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/MessageContextBuilder.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/MessageContextBuilder.java
Wed Mar 14 15:09:09 2007
@@ -136,13 +136,13 @@
             targetResolver.resolveTarget(newmsgCtx);
         }
 
-        // Determine ReplyTo for respome message.
+        // Determine ReplyTo for response message.
         AxisService axisService = inMessageContext.getAxisService();
         if (axisService != null && Constants.SCOPE_SOAP_SESSION.equals(axisService.getScope()))
{
             //If the wsa 2004/08 (submission) spec is in effect use the wsa anonymous URI
as the default replyTo value.
             //This is necessary because the wsa none URI is not available in that spec.
-            if (AddressingConstants.Submission.WSA_NAMESPACE.equals(inMessageContext.getProperty(
-                    AddressingConstants.WS_ADDRESSING_VERSION))) {
+            Object version = inMessageContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
+            if (AddressingConstants.Submission.WSA_NAMESPACE.equals(version)) {
                 newmsgCtx.setReplyTo(
                         new EndpointReference(AddressingConstants.Submission.WSA_ANONYMOUS_URL));
             } else {
@@ -161,9 +161,10 @@
                                                  serviceGroupContextId);
             }
         } else {
-            // Only set a ReplyTo and a MessageId on async response messages. 
             EndpointReference outboundToEPR = newmsgCtx.getTo();
-            if (outboundToEPR != null && !outboundToEPR.hasAnonymousAddress()) {
+            Object version = newmsgCtx.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
+            if (AddressingConstants.Submission.WSA_NAMESPACE.equals(version) ||
+                (outboundToEPR != null && !outboundToEPR.hasAnonymousAddress()))
{
                 newmsgCtx.setMessageID(UUIDGenerator.getUUID());
                 newmsgCtx.setReplyTo(new EndpointReference(AddressingConstants.Final.WSA_NONE_URI));
             }
@@ -284,9 +285,10 @@
         }
 
         // Not worth setting up the session information on a fault flow
-        // Only set a ReplyTo and a MessageId on async response messages. 
         EndpointReference outboundToEPR = faultContext.getTo();
-        if (outboundToEPR != null && !outboundToEPR.hasAnonymousAddress()) {
+        Object version = faultContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
+        if (AddressingConstants.Submission.WSA_NAMESPACE.equals(version) ||
+            (outboundToEPR != null && !outboundToEPR.hasAnonymousAddress())) {
             faultContext.setMessageID(UUIDGenerator.getUUID());
             faultContext.setReplyTo(new EndpointReference(AddressingConstants.Final.WSA_NONE_URI));
         }



---------------------------------------------------------------------
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