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 21:58:51 UTC
svn commit: r541762 - in
/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2:
engine/ integration/ processingModel/
Author: davidillsley
Date: Fri May 25 12:58:49 2007
New Revision: 541762
URL: http://svn.apache.org/viewvc?view=rev&rev=541762
Log:
More local transport changes for the integraton suite
Modified:
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CallUnregisteredServiceTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/Echo.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/OneWayRawXMLTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/SOAPversionTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/LocalTestCase.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/processingModel/SoapProcessingModelTest.java
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CallUnregisteredServiceTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CallUnregisteredServiceTest.java?view=diff&rev=541762&r1=541761&r2=541762
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CallUnregisteredServiceTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CallUnregisteredServiceTest.java Fri May 25 12:58:49 2007
@@ -1,6 +1,4 @@
/*
- * 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
@@ -13,79 +11,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.axis2.engine;
-//todo
-
-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.OMNamespace;
-import org.apache.axiom.soap.SOAPFactory;
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.ConfigurationContextFactory;
-import org.apache.axis2.integration.UtilServer;
-import org.apache.axis2.integration.UtilServerBasedTestCase;
-
-public class CallUnregisteredServiceTest extends UtilServerBasedTestCase {
-
- public CallUnregisteredServiceTest() {
- super(CallUnregisteredServiceTest.class.getName());
- }
-
- public CallUnregisteredServiceTest(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return getTestSetup(new TestSuite(CallUnregisteredServiceTest.class));
- }
-
- public void testEchoXMLSync() throws Exception {
- try {
- SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
-
- OMNamespace omNs = fac.createOMNamespace("http://localhost/my",
- "my");
- OMElement method = fac.createOMElement("echoOMElement", omNs);
- OMElement value = fac.createOMElement("myValue", omNs);
- value.addChild(
- fac.createOMText(value,
- "Isaac Asimov, The Foundation Trilogy"));
- method.addChild(value);
-
- EndpointReference targetEPR =
- new EndpointReference("http://127.0.0.1:"
- + (UtilServer.TESTING_PORT)
- + "/axis2/services/EchoXMLService1");
-
- Options options = new Options();
- options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
- options.setTo(targetEPR);
-
- ConfigurationContext configContext =
- ConfigurationContextFactory.createConfigurationContextFromFileSystem(
- "target/test-resources/integrationRepo", null);
- ServiceClient sender = new ServiceClient(configContext, null);
- sender.setOptions(options);
-
- sender.sendReceive(method);
- fail("The test must fail due to wrong service Name");
+import org.apache.axis2.integration.LocalTestCase;
+import org.apache.axis2.integration.TestingUtils;
- } catch (AxisFault e) {
-// e.printStackTrace();
- System.out.println(e.getMessage());
- assertTrue(e.getMessage().indexOf("The service cannot be found for the") >= 0);
- tearDown();
- return;
- }
+public class CallUnregisteredServiceTest extends LocalTestCase {
- }
+ protected void setUp() throws Exception {
+ super.setUp();
+ deployClassAsService(Echo.SERVICE_NAME, Echo.class);
+ }
+
+ public void testEchoXMLSync() throws Exception {
+ try {
+ ServiceClient sender = getClient(Echo.SERVICE_NAME + "-fail", Echo.ECHO_OM_ELEMENT_OP_NAME);
+ sender.sendReceive(TestingUtils.createDummyOMElement());
+ fail("The test must fail due to wrong service Name");
+ } catch (AxisFault e) {
+ assertTrue(e.getMessage().indexOf("The service cannot be found for the") >= 0);
+ }
+ }
}
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/Echo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/Echo.java?view=diff&rev=541762&r1=541761&r2=541762
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/Echo.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/Echo.java Fri May 25 12:58:49 2007
@@ -1,6 +1,4 @@
/*
- * 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
@@ -13,20 +11,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.axis2.engine;
+import javax.xml.namespace.QName;
+
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMText;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-/** @version $Rev: $ $Date: $ */
-
public class Echo {
private static final Log log = LogFactory.getLog(Echo.class);
-
+ public static final String SERVICE_NAME = "EchoXMLService";
+ public static final String ECHO_OM_ELEMENT_OP_NAME = "echoOMElement";
+
public Echo() {
}
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/OneWayRawXMLTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/OneWayRawXMLTest.java?view=diff&rev=541762&r1=541761&r2=541762
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/OneWayRawXMLTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/OneWayRawXMLTest.java Fri May 25 12:58:49 2007
@@ -1,6 +1,4 @@
/*
- * 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
@@ -16,81 +14,37 @@
package org.apache.axis2.engine;
-//todo
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.apache.axiom.om.OMElement;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.OutInAxisOperation;
-import org.apache.axis2.engine.util.TestConstants;
+import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.integration.LocalTestCase;
import org.apache.axis2.integration.TestingUtils;
-import org.apache.axis2.integration.UtilServer;
-import org.apache.axis2.integration.UtilServerBasedTestCase;
-
-public class OneWayRawXMLTest extends UtilServerBasedTestCase implements TestConstants {
- private SOAPEnvelope envelope;
-
-
- public OneWayRawXMLTest() {
- super(OneWayRawXMLTest.class.getName());
- }
-
- public OneWayRawXMLTest(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return getTestSetup(new TestSuite(OneWayRawXMLTest.class));
- }
+public class OneWayRawXMLTest extends LocalTestCase {
+ private boolean received;
protected void setUp() throws Exception {
- AxisService service = new AxisService(serviceName.getLocalPart());
- AxisOperation axisOperation = new OutInAxisOperation(
- operationName);
- axisOperation.setMessageReceiver(new MessageReceiver() {
- public void receive(MessageContext messageCtx) {
- envelope = messageCtx.getEnvelope();
- TestingUtils.compareWithCreatedOMElement(
- envelope.getBody().getFirstElement());
- }
- });
- service.addOperation(axisOperation);
- UtilServer.deployService(service);
- }
-
-
- protected void tearDown() throws Exception {
- UtilServer.unDeployService(serviceName);
+ super.setUp();
+ serverConfig.addMessageReceiver(WSDL2Constants.MEP_URI_IN_ONLY, new MessageReceiver(){
+ public void receive(MessageContext messageCtx) throws AxisFault {
+ SOAPEnvelope envelope = messageCtx.getEnvelope();
+ TestingUtils.compareWithCreatedOMElement(envelope.getBody().getFirstElement());
+ received = true;
+ }
+ });
+ deployClassAsService(Echo.SERVICE_NAME, Echo.class);
}
-
- public void testEchoXMLSync() throws Exception {
-
- OMElement payload = TestingUtils.createDummyOMElement();
-
- ConfigurationContext configContext =
- ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
- ServiceClient sender = new ServiceClient(configContext, null);
-
- Options options = new Options();
- sender.setOptions(options);
- options.setTo(targetEPR);
- sender.fireAndForget(payload);
+ public void testOneWay() throws Exception {
+ ServiceClient sender = getClient(Echo.SERVICE_NAME, "echoOMElementNoResponse");
+ sender.fireAndForget(TestingUtils.createDummyOMElement());
int index = 0;
- while (envelope == null) {
- Thread.sleep(1000);
+ while (!received) {
+ Thread.sleep(10);
index++;
- if (index == 5) {
+ if (index == 20) {
throw new AxisFault("error Occured");
}
}
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/SOAPversionTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/SOAPversionTest.java?view=diff&rev=541762&r1=541761&r2=541762
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/SOAPversionTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/SOAPversionTest.java Fri May 25 12:58:49 2007
@@ -1,6 +1,4 @@
/*
- * 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
@@ -16,161 +14,45 @@
package org.apache.axis2.engine;
-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.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.client.OperationClient;
-import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.engine.util.TestConstants;
-import org.apache.axis2.integration.UtilServer;
-import org.apache.axis2.integration.UtilServerBasedTestCase;
-import org.apache.axis2.util.Utils;
+import org.apache.axis2.integration.LocalTestCase;
+import org.apache.axis2.integration.TestingUtils;
import org.apache.axis2.wsdl.WSDLConstants;
-import javax.xml.namespace.QName;
-
-public class SOAPversionTest extends UtilServerBasedTestCase implements TestConstants {
-
- QName assumedServiceName = new QName("AnonymousService");
-
-
- private AxisService service;
-
-
- public static Test suite() {
- return getTestSetup(new TestSuite(SOAPversionTest.class));
- }
-
+public class SOAPversionTest extends LocalTestCase {
+
protected void setUp() throws Exception {
- service =
- Utils.createSimpleService(serviceName,
- Echo.class.getName(),
- operationName);
- UtilServer.deployService(service);
- }
-
- protected void tearDown() throws Exception {
- UtilServer.unDeployService(serviceName);
- UtilServer.unDeployClientService();
+ super.setUp();
+ deployClassAsService(Echo.SERVICE_NAME, Echo.class);
}
-
public void testSOAP11() throws AxisFault {
- OMElement payload = createEnvelope();
- ConfigurationContext configCtx = ConfigurationContextFactory.
- createConfigurationContextFromFileSystem(null, null);
- ServiceClient client = new ServiceClient(configCtx, null);
-
-
- Options options = new Options();
- client.setOptions(options);
- options.setSoapVersionURI(
+ ServiceClient serviceClient = getClient(Echo.SERVICE_NAME, Echo.ECHO_OM_ELEMENT_OP_NAME);
+ serviceClient.getOptions().setSoapVersionURI(
SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
- options.setTo(targetEPR);
- options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
- OperationClient opClinet = client.createClient(ServiceClient.ANON_OUT_IN_OP);
- opClinet.addMessageContext(prepareTheSOAPEnvelope(payload, options));
- opClinet.execute(true);
+ serviceClient.setCachingOperationContext(true);
+ serviceClient.sendReceive(TestingUtils.createDummyOMElement());
+ SOAPEnvelope result = serviceClient.getLastOperationContext().getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE).getEnvelope();
- SOAPEnvelope result =
- opClinet.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE).getEnvelope();
assertEquals("SOAP Version received is not compatible",
SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI,
result.getNamespace().getNamespaceURI());
}
public void testSOAP12() throws AxisFault {
- OMElement payload = createEnvelope();
- ConfigurationContext configCtx = ConfigurationContextFactory.
- createConfigurationContextFromFileSystem(null, null);
- ServiceClient client = new ServiceClient(configCtx, null);
- Options options = new Options();
- options.setSoapVersionURI(
- SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
- options.setTo(targetEPR);
- options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
- client.setOptions(options);
-
- OperationClient opClinet = client.createClient(ServiceClient.ANON_OUT_IN_OP);
- opClinet.addMessageContext(prepareTheSOAPEnvelope(payload, options));
- opClinet.execute(true);
-
- SOAPEnvelope result =
- opClinet.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE).getEnvelope();
+ ServiceClient serviceClient = getClient(Echo.SERVICE_NAME, Echo.ECHO_OM_ELEMENT_OP_NAME);
+ serviceClient.getOptions().setSoapVersionURI(
+ SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ serviceClient.setCachingOperationContext(true);
+ serviceClient.sendReceive(TestingUtils.createDummyOMElement());
+ SOAPEnvelope result = serviceClient.getLastOperationContext().getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE).getEnvelope();
+
assertEquals("SOAP Version received is not compatible",
SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI,
result.getNamespace().getNamespaceURI());
}
-
- private MessageContext prepareTheSOAPEnvelope(OMElement toSend, Options options)
- throws AxisFault {
- MessageContext msgctx = new MessageContext();
- SOAPFactory sf = getSOAPFactory(options);
- SOAPEnvelope se = sf.getDefaultEnvelope();
- if (toSend != null) {
- se.getBody().addChild(toSend);
- }
- msgctx.setEnvelope(se);
- return msgctx;
- }
-
- private SOAPFactory getSOAPFactory(Options options) {
- String soapVersionURI = options.getSoapVersionURI();
- if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(soapVersionURI)) {
- return OMAbstractFactory.getSOAP12Factory();
- } else {
- // if its not SOAP 1.2 just assume SOAP 1.1
- return OMAbstractFactory.getSOAP11Factory();
- }
- }
-
- public void testSOAPfault() throws AxisFault {
- OMElement payload = createEnvelope();
- ConfigurationContext configCtx = ConfigurationContextFactory.
- createConfigurationContextFromFileSystem(null, null);
- ServiceClient client = new ServiceClient(configCtx, null);
- Options options = new Options();
- client.setOptions(options);
- options.setSoapVersionURI(
- SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
-
- options.setTo(targetEPR);
- options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
- OperationClient opClinet = client.createClient(ServiceClient.ANON_OUT_IN_OP);
- opClinet.addMessageContext(prepareTheSOAPEnvelope(payload, options));
- opClinet.execute(true);
-
- opClinet.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE).getEnvelope();
-// assertEquals("SOAP Version received is not compatible", SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI, result.getNamespace().getName());
-
- }
-
- private OMElement createEnvelope() {
- 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.addChild(
- fac.createOMText(value, "Isaac Asimov, The Foundation Trilogy"));
- method.addChild(value);
-
- return method;
- }
-
-
}
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/LocalTestCase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/LocalTestCase.java?view=diff&rev=541762&r1=541761&r2=541762
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/LocalTestCase.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/LocalTestCase.java Fri May 25 12:58:49 2007
@@ -17,12 +17,15 @@
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.rpc.client.RPCServiceClient;
+import org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver;
import org.apache.axis2.receivers.RawXMLINOutMessageReceiver;
+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.ConfigurationContextFactory;
import org.apache.axis2.deployment.util.Utils;
+import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.TransportOutDescription;
import org.apache.axis2.description.WSDL2Constants;
@@ -77,8 +80,8 @@
///////////////////////////////////////////////////////////////////////
// Set up raw message receivers for OMElement based tests
- serverConfig.addMessageReceiver(WSDL2Constants.MEP_URI_IN_OUT,
- new RawXMLINOutMessageReceiver());
+ serverConfig.addMessageReceiver(WSDL2Constants.MEP_URI_IN_ONLY,
+ new RawXMLINOnlyMessageReceiver());
serverConfig.addMessageReceiver(WSDL2Constants.MEP_URI_IN_OUT,
new RawXMLINOutMessageReceiver());
@@ -162,6 +165,31 @@
opts.setTransportOut(td);
RPCServiceClient client = new RPCServiceClient(clientCtx, null);
+ client.setOptions(opts);
+ return client;
+ }
+
+ /**
+ * 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 ServiceClient getClient(String serviceName, String operationName) throws AxisFault {
+ TransportOutDescription td = new TransportOutDescription("local");
+ td.setSender(sender);
+
+ Options opts = new Options();
+ opts.setTransportOut(td);
+
+ String url = LocalTransportReceiver.CONFIG_CONTEXT.getServiceContextPath()+"/"+serviceName;
+
+ opts.setTo(new EndpointReference(url));
+ opts.setAction(operationName);
+ ServiceClient client = new ServiceClient(clientCtx, null);
client.setOptions(opts);
return client;
}
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/processingModel/SoapProcessingModelTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/processingModel/SoapProcessingModelTest.java?view=diff&rev=541762&r1=541761&r2=541762
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/processingModel/SoapProcessingModelTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/processingModel/SoapProcessingModelTest.java Fri May 25 12:58:49 2007
@@ -1,6 +1,4 @@
/*
- * 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
@@ -13,107 +11,50 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.axis2.processingModel;
-// todo
-
-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.OMNamespace;
import org.apache.axiom.soap.SOAP12Constants;
-import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPHeaderBlock;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.client.OperationClient;
-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.description.AxisService;
import org.apache.axis2.engine.Echo;
-import org.apache.axis2.engine.util.TestConstants;
+import org.apache.axis2.integration.LocalTestCase;
import org.apache.axis2.integration.TestingUtils;
-import org.apache.axis2.integration.UtilServer;
-import org.apache.axis2.integration.UtilServerBasedTestCase;
-import org.apache.axis2.util.Utils;
-
-public class SoapProcessingModelTest extends UtilServerBasedTestCase implements TestConstants {
-
- private AxisService clientService;
-
- public SoapProcessingModelTest() {
- super(SoapProcessingModelTest.class.getName());
- }
-
- public SoapProcessingModelTest(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return getTestSetup(new TestSuite(SoapProcessingModelTest.class));
- }
+public class SoapProcessingModelTest extends LocalTestCase {
+
protected void setUp() throws Exception {
- AxisService service = Utils.createSimpleService(serviceName, Echo.class.getName(),
- operationName);
- clientService = Utils.createSimpleServiceforClient(serviceName, Echo.class.getName(),
- operationName);
- UtilServer.deployService(service);
-
- }
-
- protected void tearDown() throws Exception {
- UtilServer.unDeployService(serviceName);
+ super.setUp();
+ deployClassAsService(Echo.SERVICE_NAME, Echo.class);
}
- public void sendMessageWithHeader(SOAPEnvelope envelope) throws Exception {
- ServiceClient serviceClient;
+ public void testSendingMustUnderstandWithNextRole() throws Exception {
+ ServiceClient serviceClient = getClient(Echo.SERVICE_NAME, Echo.ECHO_OM_ELEMENT_OP_NAME);
+
+ SOAPFactory fac = OMAbstractFactory.getSOAP12Factory();
+ OMNamespace headerNs = fac.createOMNamespace("http://dummyHeader", "dh");
+ SOAPHeaderBlock h1 = fac.createSOAPHeaderBlock("DummyHeader", headerNs);
+ h1.setMustUnderstand(true);
+ h1.addChild(fac.createOMText("Dummy String"));
+ h1.setRole(SOAP12Constants.SOAP_ROLE_NEXT);
+
+ serviceClient.addHeader(h1);
+
+ OMElement payload = TestingUtils.createDummyOMElement();
+ serviceClient.getOptions().setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
try {
- ConfigurationContext configContext = Utils
- .getNewConfigurationContext(Constants.TESTING_REPOSITORY);
- serviceClient = new ServiceClient(configContext, clientService);
-
- MessageContext msgctx = configContext.createMessageContext();
-
- msgctx.setEnvelope(envelope);
-
- Options options = new Options();
- serviceClient.setOptions(options);
- options.setTo(targetEPR);
- options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
- options.setAction(Constants.AXIS2_NAMESPACE_URI + "/" + operationName.getLocalPart());
-
- OperationClient opClient = serviceClient.createClient(operationName);
- opClient.addMessageContext(msgctx);
- opClient.setOptions(options);
- opClient.execute(true);
-
+ serviceClient.sendReceive(payload);
} catch (AxisFault fault) {
// This should be a MustUnderstand fault
assertEquals(fault.getFaultCode(), SOAP12Constants.QNAME_MU_FAULTCODE);
return;
}
fail("MU header was processed");
- }
-
- public void testSendingMustUnderstandWithNextRole() throws Exception {
- SOAPFactory fac = OMAbstractFactory.getSOAP12Factory();
- SOAPEnvelope envelope = fac.getDefaultEnvelope();
- OMNamespace headerNs = fac
- .createOMNamespace("http://dummyHeader", "dh");
- SOAPHeaderBlock h1 = fac.createSOAPHeaderBlock("DummyHeader", headerNs,
- envelope.getHeader());
- h1.setMustUnderstand(true);
- h1.addChild(fac.createOMText("Dummy String"));
- h1.setRole(SOAP12Constants.SOAP_ROLE_NEXT);
- OMElement payload = TestingUtils.createDummyOMElement();
- envelope.getBody().addChild(payload);
- sendMessageWithHeader(envelope);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org