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 da...@apache.org on 2007/05/25 22:32:57 UTC
svn commit: r541773 - in
/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/deployment:
TargetResolverServiceTest.java TestTargetResolver.java
Author: davidillsley
Date: Fri May 25 13:32:57 2007
New Revision: 541773
URL: http://svn.apache.org/viewvc?view=rev&rev=541773
Log:
Update targetresolver test to use local transport
Modified:
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/deployment/TargetResolverServiceTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/deployment/TestTargetResolver.java
Modified: 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?view=diff&rev=541773&r1=541772&r2=541773
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/deployment/TargetResolverServiceTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/deployment/TargetResolverServiceTest.java Fri May 25 13:32:57 2007
@@ -1,154 +1,55 @@
/*
-* 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.
-*
-*
-*/
-
+ * 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 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.description.WSDL2Constants;
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.engine.MessageReceiver;
+import org.apache.axis2.integration.LocalTestCase;
+import org.apache.axis2.integration.TestingUtils;
import org.apache.axis2.receivers.RawXMLINOutMessageReceiver;
-import org.apache.axis2.util.Utils;
-import org.apache.axis2.wsdl.WSDLConstants;
-
-import javax.xml.namespace.QName;
-
-
-public class TargetResolverServiceTest extends UtilServerBasedTestCase implements TestConstants {
-
- 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");
- }
+public class TargetResolverServiceTest extends LocalTestCase {
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(Constants.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.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;
+ super.setUp();
+ serverConfig.addMessageReceiver(WSDL2Constants.MEP_URI_IN_OUT, new MessageReceiver(){
+ public void receive(MessageContext msgContext) throws AxisFault {
+ // Set the reply to on the server side to test server side
+ // target resolvers
+ msgContext.setReplyTo(new EndpointReference(
+ "http://ws.apache.org/new/anonymous/address"));
+ new RawXMLINOutMessageReceiver().receive(msgContext);
+ }
+ });
+ deployClassAsService(Echo.SERVICE_NAME, Echo.class);
+ clientCtx.getAxisConfiguration().addTargetResolver(new TestTargetResolver());
+ serverConfig.getAxisConfiguration().addTargetResolver(new TestTargetResolver());
+ }
+
+ public void testTargetRsolver() throws Exception {
+ ServiceClient sender = getClient(Echo.SERVICE_NAME, Echo.ECHO_OM_ELEMENT_OP_NAME);
+ String oldAddress = sender.getOptions().getTo().getAddress();
+ String newAddress = "trtest"+oldAddress.substring(5);
+ sender.getOptions().getTo().setAddress(newAddress);
+ OMElement response = sender.sendReceive(TestingUtils.createDummyOMElement());
+ TestingUtils.compareWithCreatedOMElement(response);
}
- private ServiceClient createServiceClient() throws AxisFault {
- AxisService service =
- createSimpleServiceforClient(serviceName,
- Echo.class.getName(),
- operationName);
-
- ConfigurationContext configcontext = UtilServer
- .createClientConfigurationContext(Constants.TESTING_PATH + "deployment_repo");
- ServiceClient sender;
-
- 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("addressing");
-
- return sender;
- }
}
Modified: 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?view=diff&rev=541773&r1=541772&r2=541773
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/deployment/TestTargetResolver.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/deployment/TestTargetResolver.java Fri May 25 13:32:57 2007
@@ -1,6 +1,4 @@
/*
-* 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
@@ -28,7 +26,7 @@
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));
+ "local" + messageContext.getTo().getAddress().substring(6));
}
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