axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davidills...@apache.org
Subject svn commit: r430392 [2/2] - in /webservices/axis2/trunk/java/modules: core/src/org/apache/axis2/deployment/ core/src/org/apache/axis2/description/ core/src/org/apache/axis2/engine/ core/src/org/apache/axis2/util/ integration/ integration/test-resources...
Date Thu, 10 Aug 2006 14:27:16 GMT
Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/deployment/TargetResolverServiceTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/deployment/TargetResolverServiceTest.java?rev=430392&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/deployment/TargetResolverServiceTest.java
(added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/deployment/TargetResolverServiceTest.java
Thu Aug 10 07:27:14 2006
@@ -0,0 +1,156 @@
+/*
+* 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.
+*
+*
+*/
+
+package org.apache.axis2.deployment;
+
+import javax.xml.namespace.QName;
+
+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.addressing.EndpointReference;
+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.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.OutInAxisOperation;
+import org.apache.axis2.description.Parameter;
+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.AbstractMessageReceiver;
+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 org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+public class TargetResolverServiceTest extends UtilServerBasedTestCase implements TestConstants
{
+
+	private static final Log log = LogFactory.getLog(TargetResolverServiceTest.class);
+    protected QName transportName = new QName("http://localhost/my",
+            "NullTransport");
+    
+    // 2 special urls that the TestTargetResolver will modify into ones that can be targeted
+    EndpointReference targetEPR = new EndpointReference(
+            "trtest://" + (UtilServer.TESTING_PORT) + "/axis2/services/EchoXMLService/echoOMElement");
+
+    EndpointReference replyTo = new EndpointReference(
+            "http://ws.apache.org/new/anonymous/address");
+    
+    protected AxisConfiguration engineRegistry;
+    protected MessageContext mc;
+    protected ServiceContext serviceContext;
+    protected AxisService echoService;
+    protected AxisService rrService;
+
+    public static Test suite() {
+        return getTestSetup2(new TestSuite(TargetResolverServiceTest.class),Constants.TESTING_PATH+"deployment_repo");
+    }
+
+    protected void setUp() throws Exception {
+        echoService = Utils.createSimpleService(serviceName,
+                new RawXMLINOutMessageReceiver(),
+                Echo.class.getName(),
+                operationName);
+        UtilServer.deployService(echoService);
+    }
+    
+    protected void tearDown() throws Exception {
+        UtilServer.unDeployService(serviceName);
+        UtilServer.unDeployClientService();
+    }
+    
+    public static AxisService createSimpleServiceforClient(QName serviceName,
+            String className,
+            QName opName)
+    throws AxisFault {
+        AxisService service = new AxisService(serviceName.getLocalPart());
+        
+        service.setClassLoader(Thread.currentThread().getContextClassLoader());
+        service.addParameter(new Parameter(AbstractMessageReceiver.SERVICE_CLASS, className));
+        
+        AxisOperation axisOp = new OutInAxisOperation(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();
+            OMElement result = sender.sendReceive(operationName, method);
+            assertEquals("echoOMElementResponse", result.getLocalName());
+        } finally {
+            if (sender != null)
+                sender.finalizeInvoke();
+        }
+    }
+    
+    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 =
+            createSimpleServiceforClient(serviceName,
+                        Echo.class.getName(),
+                        operationName);
+
+        ConfigurationContext configcontext = UtilServer.createClientConfigurationContext(Constants.TESTING_PATH+"deployment_repo");
+        ServiceClient sender = null;
+        
+        Options options = new Options();
+        options.setTo(targetEPR);
+        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+        options.setAction(operationName.getLocalPart());
+        options.setReplyTo(replyTo);
+
+        sender = new ServiceClient(configcontext, service);
+        sender.setOptions(options);
+        sender.engageModule(new QName("addressing"));
+        
+        return sender;
+    }
+}

Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/deployment/TestTargetResolver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/deployment/TestTargetResolver.java?rev=430392&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/deployment/TestTargetResolver.java
(added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/deployment/TestTargetResolver.java
Thu Aug 10 07:27:14 2006
@@ -0,0 +1,34 @@
+/*
+* Copyright 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.
+*/
+package org.apache.axis2.deployment;
+
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.util.TargetResolver;
+
+public class TestTargetResolver implements TargetResolver{
+
+    public void resolveTarget(MessageContext messageContext) {
+        System.out.println("resolveTarget:" +messageContext.getTo().getAddress());
+        if(messageContext.getTo().getAddress().equals("http://ws.apache.org/new/anonymous/address")){
+            messageContext.getTo().setAddress(AddressingConstants.Final.WSA_ANONYMOUS_URL);
+        }else if(messageContext.getTo().getAddress().startsWith("trtest://")){
+            messageContext.getTo().setAddress("http://127.0.0.1:"+messageContext.getTo().getAddress().substring(9));
+        }
+        System.out.println("resolveTarget:" +messageContext.getTo().getAddress());
+    }
+
+}



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