You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by ch...@apache.org on 2006/04/06 12:52:34 UTC
svn commit: r391960 - in
/webservices/sandesha/trunk/test/src/org/apache/sandesha2: ./ scenarios/
versions/
Author: chamikara
Date: Thu Apr 6 03:52:31 2006
New Revision: 391960
URL: http://svn.apache.org/viewcvs?rev=391960&view=rev
Log:
Completed most of the test cases
Added:
webservices/sandesha/trunk/test/src/org/apache/sandesha2/MessageRetransmissionTest.java
webservices/sandesha/trunk/test/src/org/apache/sandesha2/SandeshaReportsTest.java
webservices/sandesha/trunk/test/src/org/apache/sandesha2/SandeshaUtilTest.java
webservices/sandesha/trunk/test/src/org/apache/sandesha2/SquenceOfferTest.java
webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/
webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AddressableEchoTest.java
webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AddressablePingTest.java
webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AnonymousAckEchoTest.java
webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AnonymousPingTest.java
webservices/sandesha/trunk/test/src/org/apache/sandesha2/versions/
webservices/sandesha/trunk/test/src/org/apache/sandesha2/versions/AddressingVersionTest.java
webservices/sandesha/trunk/test/src/org/apache/sandesha2/versions/RMVersionTest.java
webservices/sandesha/trunk/test/src/org/apache/sandesha2/versions/SOAPVersionTest.java
Modified:
webservices/sandesha/trunk/test/src/org/apache/sandesha2/PorpertyLoaderTest.java
Added: webservices/sandesha/trunk/test/src/org/apache/sandesha2/MessageRetransmissionTest.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/test/src/org/apache/sandesha2/MessageRetransmissionTest.java?rev=391960&view=auto
==============================================================================
--- webservices/sandesha/trunk/test/src/org/apache/sandesha2/MessageRetransmissionTest.java (added)
+++ webservices/sandesha/trunk/test/src/org/apache/sandesha2/MessageRetransmissionTest.java Thu Apr 6 03:52:31 2006
@@ -0,0 +1,136 @@
+/*
+ * Created on Nov 13, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.sandesha2;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+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.axis2.AxisFault;
+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.context.MessageContextConstants;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.sandesha2.client.RMClientAPI;
+import org.apache.sandesha2.client.RMClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+import junit.framework.TestCase;
+
+/**
+ * @author chamikara
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class MessageRetransmissionTest extends TestCase {
+
+
+ SimpleHTTPServer httpServer = null;
+ private final String applicationNamespaceName = "http://tempuri.org/";
+ private final String Ping = "Ping";
+ private final String Text = "Text";
+
+ private void startServer () throws AxisFault {
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "server";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+
+ httpServer = new SimpleHTTPServer (configContext,8060);
+ httpServer.start();
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void testMessageRetransmission () throws AxisFault,InterruptedException {
+
+ String to = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+ String transportTo = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ //clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ Options clientOptions = new Options ();
+ clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ clientOptions.setTo(new EndpointReference (to));
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+
+ String sequenceKey = "sequence1";
+ clientOptions.setProperty(RMClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ //serviceClient.
+
+ serviceClient.engageModule(new QName ("sandesha2"));
+ serviceClient.setOptions(clientOptions);
+
+ serviceClient.fireAndForget(getPingOMBlock("ping1"));
+ serviceClient.fireAndForget(getPingOMBlock("ping2"));
+
+ //starting the server after a wait
+ Thread.sleep(10000);
+
+ startServer();
+
+ clientOptions.setProperty(RMClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+
+ Thread.sleep(7000);
+
+ serviceClient.finalizeInvoke();
+
+ SequenceReport sequenceReport = RMClientAPI.getOutgoingSequenceReport(to,sequenceKey,configContext);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(2)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ }
+
+ private OMElement getPingOMBlock(String text) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement pingElem = fac.createOMElement(Ping, namespace);
+ OMElement textElem = fac.createOMElement(Text, namespace);
+
+ textElem.setText(text);
+ pingElem.addChild(textElem);
+
+ return pingElem;
+ }
+
+ public void tearDown () throws SandeshaException {
+ if (httpServer!=null)
+ httpServer.stop();
+
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+}
Modified: webservices/sandesha/trunk/test/src/org/apache/sandesha2/PorpertyLoaderTest.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/test/src/org/apache/sandesha2/PorpertyLoaderTest.java?rev=391960&r1=391959&r2=391960&view=diff
==============================================================================
--- webservices/sandesha/trunk/test/src/org/apache/sandesha2/PorpertyLoaderTest.java (original)
+++ webservices/sandesha/trunk/test/src/org/apache/sandesha2/PorpertyLoaderTest.java Thu Apr 6 03:52:31 2006
@@ -18,13 +18,11 @@
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
import java.io.InputStream;
-import org.apache.sandesha2.util.PropertyManager;
-
import junit.framework.TestCase;
+
+import org.apache.sandesha2.util.PropertyManager;
/**
* @author Chamikara Jayalath <ch...@gmail.com>
Added: webservices/sandesha/trunk/test/src/org/apache/sandesha2/SandeshaReportsTest.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/test/src/org/apache/sandesha2/SandeshaReportsTest.java?rev=391960&view=auto
==============================================================================
--- webservices/sandesha/trunk/test/src/org/apache/sandesha2/SandeshaReportsTest.java (added)
+++ webservices/sandesha/trunk/test/src/org/apache/sandesha2/SandeshaReportsTest.java Thu Apr 6 03:52:31 2006
@@ -0,0 +1,315 @@
+package org.apache.sandesha2;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+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.client.async.AsyncResult;
+import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContextConstants;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.sandesha2.client.RMClientAPI;
+import org.apache.sandesha2.client.RMClientConstants;
+import org.apache.sandesha2.client.RMReport;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.util.AcknowledgementManager;
+import org.apache.sandesha2.util.SandeshaUtil;
+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.SOAPBody;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import junit.framework.TestCase;
+
+public class SandeshaReportsTest extends TestCase {
+
+ private static Log log = LogFactory.getLog(SandeshaReportsTest.class);
+
+ SimpleHTTPServer httpServer = null;
+ private final static String applicationNamespaceName = "http://tempuri.org/";
+ private final static String echoString = "echoString";
+ private final static String Text = "Text";
+ private final static String Sequence = "Sequence";
+ private final static String echoStringResponse = "echoStringResponse";
+ private final static String EchoStringReturn = "EchoStringReturn";
+
+ private final String Ping = "Ping";
+
+
+ public void setUp () throws AxisFault {
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "server";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+
+ httpServer = new SimpleHTTPServer (configContext,8060);
+ httpServer.start();
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void tearDown () throws SandeshaException {
+ if (httpServer!=null)
+ httpServer.stop();
+
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void testSequenceReports () throws AxisFault,InterruptedException {
+
+ String to = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+ String transportTo = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+ String acksToEPR = "http://127.0.0.1:6060/axis2/services/__ANONYMOUS_SERVICE__";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ Options clientOptions = new Options ();
+
+ clientOptions.setTo(new EndpointReference (to));
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+
+ String sequenceKey = SandeshaUtil.getUUID();
+ clientOptions.setProperty(RMClientConstants.SEQUENCE_KEY,sequenceKey);
+ clientOptions.setProperty(RMClientConstants.AcksTo,acksToEPR);
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ serviceClient.setOptions(clientOptions);
+ //serviceClient.
+
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+ clientOptions.setUseSeparateListener(true);
+
+ serviceClient.setOptions(clientOptions);
+ serviceClient.engageModule(new QName ("sandesha2")); //engaging the sandesha2 module.
+
+ TestCallback callback1 = new TestCallback ("Callback 1");
+ serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo1",sequenceKey),callback1);
+
+ clientOptions.setProperty(RMClientConstants.LAST_MESSAGE, "true");
+ TestCallback callback2 = new TestCallback ("Callback 2");
+ serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo2",sequenceKey),callback2);
+
+
+ Thread.sleep(12000);
+ serviceClient.finalizeInvoke();
+
+ //testing outgoing sequence reports
+ SequenceReport sequenceReport = RMClientAPI.getOutgoingSequenceReport(to,sequenceKey,configContext);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(2)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ //testing incoming sequence reports
+ ArrayList incomingSequenceReports = RMClientAPI.getAllIncomingSequenceReports(configContext);
+ assertEquals(incomingSequenceReports.size(),1);
+ SequenceReport incomingSequenceReport = (SequenceReport) incomingSequenceReports.get(0);
+ assertEquals(incomingSequenceReport.getCompletedMessages().size(),2);
+ assertNotNull(incomingSequenceReport.getSequenceID());
+ assertEquals(incomingSequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_IN);
+ assertEquals(incomingSequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertNotNull(incomingSequenceReport.getInternalSequenceID());
+
+ assertEquals(incomingSequenceReport.getSequenceID(),incomingSequenceReport.getInternalSequenceID()); //for the incoming side, internalSequenceID==sequenceID
+ }
+
+ public void testRMReport () throws AxisFault,InterruptedException {
+
+ String to = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+ String transportTo = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ //clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ Options clientOptions = new Options ();
+ clientOptions.setProperty(Options.COPY_PROPERTIES,new Boolean (true));
+ clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ clientOptions.setTo(new EndpointReference (to));
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+
+ String sequenceKey1 = "sequence3";
+ clientOptions.setProperty(RMClientConstants.SEQUENCE_KEY,sequenceKey1);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+
+ serviceClient.engageModule(new QName ("sandesha2"));
+ serviceClient.setOptions(clientOptions);
+
+
+ serviceClient.fireAndForget(getPingOMBlock("ping1"));
+ clientOptions.setProperty(RMClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping2"));
+
+ String sequenceKey2 = "sequence4";
+ clientOptions.setProperty(RMClientConstants.SEQUENCE_KEY,sequenceKey2);
+
+ clientOptions.setProperty(RMClientConstants.LAST_MESSAGE, "false");
+ serviceClient.fireAndForget(getPingOMBlock("ping1"));
+
+ try {
+ //waiting till the messages exchange finishes.
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+
+ SequenceReport sequenceReport = null;
+ boolean complete = false;
+ while (!complete) {
+ sequenceReport = RMClientAPI.getOutgoingSequenceReport(to,sequenceKey1,configContext);
+ if (sequenceReport!=null && sequenceReport.getCompletedMessages().size()==2)
+ complete = true;
+ else {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ serviceClient.finalizeInvoke();
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ RMReport rmReport = RMClientAPI.getRMReport(configContext);
+
+ assertEquals(rmReport.getOutgoingSequenceList().size(),2);
+
+ SequenceReport sequence1Report = null;
+ SequenceReport sequence2Report = null;
+
+ Iterator iterator = rmReport.getOutgoingSequenceList().iterator();
+ while (iterator.hasNext()) {
+ String sequenceID = (String) iterator.next();
+
+ String internalSequenceID = rmReport.getInternalSequenceIdOfOutSequence(sequenceID);
+
+ if (internalSequenceID.indexOf(sequenceKey1)>=0) {
+ sequence1Report = RMClientAPI.getOutgoingSequenceReport(internalSequenceID,configContext);
+ } else if (internalSequenceID.indexOf(sequenceKey2)>=0){
+ sequence2Report = RMClientAPI.getOutgoingSequenceReport(internalSequenceID,configContext);
+ }
+ }
+
+ assertNotNull(sequence1Report);
+ assertNotNull(sequence2Report);
+
+ assertEquals(sequence1Report.getCompletedMessages().size(),2);
+ assertEquals(sequence2Report.getCompletedMessages().size(),1);
+
+ assertEquals(sequence1Report.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequence2Report.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_ESTABLISHED);
+ }
+
+ private static OMElement getEchoOMBlock(String text, String sequenceKey) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace applicationNamespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement echoStringElement = fac.createOMElement(echoString, applicationNamespace);
+ OMElement textElem = fac.createOMElement(Text,applicationNamespace);
+ OMElement sequenceElem = fac.createOMElement(Sequence,applicationNamespace);
+
+ textElem.setText(text);
+ sequenceElem.setText(sequenceKey);
+ echoStringElement.addChild(textElem);
+ echoStringElement.addChild(sequenceElem);
+
+ return echoStringElement;
+ }
+
+ class TestCallback extends Callback {
+
+ String name = null;
+ boolean completed = false;
+ boolean errorRported = false;
+ String resultStr;
+
+ public boolean isCompleted() {
+ return completed;
+ }
+
+ public boolean isErrorRported() {
+ return errorRported;
+ }
+
+ public String getResult () {
+ return resultStr;
+ }
+
+ public TestCallback (String name) {
+ this.name = name;
+ }
+
+ public void onComplete(AsyncResult result) {
+
+ SOAPBody body = result.getResponseEnvelope().getBody();
+
+ OMElement echoStringResponseElem = body.getFirstChildWithName(new QName (applicationNamespaceName,echoStringResponse));
+ if (echoStringResponseElem==null) {
+ log.error("Error: SOAPBody does not have a 'echoStringResponse' child");
+ return;
+ }
+
+ OMElement echoStringReturnElem = echoStringResponseElem.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn));
+ if (echoStringReturnElem==null) {
+ log.error("Error: 'echoStringResponse' element does not have a 'EchoStringReturn' child");
+ return;
+ }
+
+ String resultStr = echoStringReturnElem.getText();
+ this.resultStr = resultStr;
+ completed = true;
+ }
+
+ public void onError (Exception e) {
+ e.printStackTrace();
+ errorRported = true;
+ }
+ }
+
+ private OMElement getPingOMBlock(String text) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement pingElem = fac.createOMElement(Ping, namespace);
+ OMElement textElem = fac.createOMElement(Text, namespace);
+
+ textElem.setText(text);
+ pingElem.addChild(textElem);
+
+ return pingElem;
+ }
+}
Added: webservices/sandesha/trunk/test/src/org/apache/sandesha2/SandeshaUtilTest.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/test/src/org/apache/sandesha2/SandeshaUtilTest.java?rev=391960&view=auto
==============================================================================
--- webservices/sandesha/trunk/test/src/org/apache/sandesha2/SandeshaUtilTest.java (added)
+++ webservices/sandesha/trunk/test/src/org/apache/sandesha2/SandeshaUtilTest.java Thu Apr 6 03:52:31 2006
@@ -0,0 +1,84 @@
+/*
+ * Copyright 1999-2004 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.sandesha2;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.sandesha2.util.SOAPAbstractFactory;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.wsrm.AcknowledgementRange;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+
+public class SandeshaUtilTest extends TestCase {
+
+ public void testUUIDGen () {
+ String UUID1 = SandeshaUtil.getUUID();
+ String UUID2 = SandeshaUtil.getUUID();
+
+ assertTrue(UUID1!=null);
+ assertTrue(UUID2!=null);
+ assertTrue(!UUID1.equals(UUID2));
+
+ assertTrue(UUID1.startsWith("urn:uuid:"));
+ assertTrue(UUID2.startsWith("urn:uuid:"));
+ }
+
+ public void testGetAckRangeArrayList () throws SandeshaException {
+ SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(Sandesha2Constants.SOAPVersion.v1_1);
+ String msgNumberStr = "3,6,1,5,8,2";
+
+ ArrayList list = SandeshaUtil.getAckRangeArrayList(msgNumberStr,factory,Sandesha2Constants.SPEC_2005_02.NS_URI);
+ assertNotNull(list);
+ assertEquals(list.size(),3);
+
+ Iterator it = list.iterator();
+ AcknowledgementRange ackRange = null;
+
+ ackRange = (AcknowledgementRange) it.next();
+ assertNotNull(ackRange);
+ assertEquals(ackRange.getLowerValue(),1);
+ assertEquals(ackRange.getUpperValue(),3);
+
+ ackRange = null;
+ ackRange = (AcknowledgementRange) it.next();
+ assertNotNull(ackRange);
+ assertEquals(ackRange.getLowerValue(),5);
+ assertEquals(ackRange.getUpperValue(),6);
+
+ ackRange = null;
+ ackRange = (AcknowledgementRange) it.next();
+ assertNotNull(ackRange);
+ assertEquals(ackRange.getLowerValue(),8);
+ assertEquals(ackRange.getUpperValue(),8);
+
+ assertFalse(it.hasNext());
+ }
+
+
+
+
+
+}
Added: webservices/sandesha/trunk/test/src/org/apache/sandesha2/SquenceOfferTest.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/test/src/org/apache/sandesha2/SquenceOfferTest.java?rev=391960&view=auto
==============================================================================
--- webservices/sandesha/trunk/test/src/org/apache/sandesha2/SquenceOfferTest.java (added)
+++ webservices/sandesha/trunk/test/src/org/apache/sandesha2/SquenceOfferTest.java Thu Apr 6 03:52:31 2006
@@ -0,0 +1,203 @@
+package org.apache.sandesha2;
+
+import java.io.File;
+import java.util.ArrayList;
+
+import javax.xml.namespace.QName;
+
+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.SOAPBody;
+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.client.async.AsyncResult;
+import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContextConstants;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.client.RMClientAPI;
+import org.apache.sandesha2.client.RMClientConstants;
+import org.apache.sandesha2.client.RMReport;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.util.SandeshaUtil;
+
+import junit.framework.TestCase;
+
+public class SquenceOfferTest extends TestCase {
+
+ private static Log log = LogFactory.getLog(SquenceOfferTest.class);
+
+ SimpleHTTPServer httpServer = null;
+
+ private final static String applicationNamespaceName = "http://tempuri.org/";
+ private final static String echoString = "echoString";
+ private final static String Text = "Text";
+ private final static String Sequence = "Sequence";
+ private final static String echoStringResponse = "echoStringResponse";
+ private final static String EchoStringReturn = "EchoStringReturn";
+
+ public void setUp () throws AxisFault {
+ String repoPath = "target" + File.separator + "repos" + File.separator + "server";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ httpServer = new SimpleHTTPServer (configContext,8060);
+
+ httpServer.start();
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void tearDown () throws SandeshaException {
+ if (httpServer!=null)
+ httpServer.stop();
+
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void testSequenceOffer () throws AxisFault, InterruptedException {
+
+ String to = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+ String transportTo = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+ String acksToEPR = "http://127.0.0.1:9070/axis2/services/__ANONYMOUS_SERVICE__";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ Options clientOptions = new Options ();
+
+ clientOptions.setTo(new EndpointReference (to));
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+
+ String sequenceKey = SandeshaUtil.getUUID();
+ clientOptions.setProperty(RMClientConstants.SEQUENCE_KEY,sequenceKey);
+ clientOptions.setProperty(RMClientConstants.AcksTo,acksToEPR);
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+
+ String offeredSequenceID = SandeshaUtil.getUUID();
+ clientOptions.setProperty(RMClientConstants.OFFERED_SEQUENCE_ID,offeredSequenceID);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ serviceClient.setOptions(clientOptions);
+ //serviceClient.
+
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+ clientOptions.setUseSeparateListener(true);
+
+ serviceClient.setOptions(clientOptions);
+ serviceClient.engageModule(new QName ("sandesha2")); //engaging the sandesha2 module.
+
+ TestCallback callback1 = new TestCallback ("Callback 1");
+ serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo1",sequenceKey),callback1);
+
+ clientOptions.setProperty(RMClientConstants.LAST_MESSAGE, "true");
+ TestCallback callback2 = new TestCallback ("Callback 2");
+ serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo2",sequenceKey),callback2);
+
+
+ Thread.sleep(12000);
+ serviceClient.finalizeInvoke();
+
+ //assertions for the out sequence.
+ SequenceReport sequenceReport = RMClientAPI.getOutgoingSequenceReport(to,sequenceKey,configContext);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(2)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ assertTrue(callback1.isComplete());
+ assertTrue(callback2.isComplete());
+ assertEquals(callback1.getResult(),"echo1");
+ assertEquals(callback2.getResult(),"echo1echo2");
+
+ //checking weather the incomingSequenceReport has the offered sequence ID
+ RMReport rmReport = RMClientAPI.getRMReport(configContext);
+ ArrayList incomingSeqList = rmReport.getIncomingSequenceList();
+ assertEquals(incomingSeqList.size(),1);
+ assertEquals(incomingSeqList.get(0),offeredSequenceID);
+ }
+
+ private static OMElement getEchoOMBlock(String text, String sequenceKey) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace applicationNamespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement echoStringElement = fac.createOMElement(echoString, applicationNamespace);
+ OMElement textElem = fac.createOMElement(Text,applicationNamespace);
+ OMElement sequenceElem = fac.createOMElement(Sequence,applicationNamespace);
+
+ textElem.setText(text);
+ sequenceElem.setText(sequenceKey);
+ echoStringElement.addChild(textElem);
+ echoStringElement.addChild(sequenceElem);
+
+ return echoStringElement;
+ }
+
+ class TestCallback extends Callback {
+
+ String name = null;
+ boolean completed = false;
+ boolean errorRported = false;
+ String resultStr;
+
+ public boolean isCompleted() {
+ return completed;
+ }
+
+ public boolean isErrorRported() {
+ return errorRported;
+ }
+
+ public String getResult () {
+ return resultStr;
+ }
+
+ public TestCallback (String name) {
+ this.name = name;
+ }
+
+ public void onComplete(AsyncResult result) {
+
+ SOAPBody body = result.getResponseEnvelope().getBody();
+
+ OMElement echoStringResponseElem = body.getFirstChildWithName(new QName (applicationNamespaceName,echoStringResponse));
+ if (echoStringResponseElem==null) {
+ log.error("Error: SOAPBody does not have a 'echoStringResponse' child");
+ return;
+ }
+
+ OMElement echoStringReturnElem = echoStringResponseElem.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn));
+ if (echoStringReturnElem==null) {
+ log.error("Error: 'echoStringResponse' element does not have a 'EchoStringReturn' child");
+ return;
+ }
+
+ String resultStr = echoStringReturnElem.getText();
+ this.resultStr = resultStr;
+ completed = true;
+ }
+
+ public void onError (Exception e) {
+ e.printStackTrace();
+ errorRported = true;
+ }
+ }
+
+}
Added: webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AddressableEchoTest.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AddressableEchoTest.java?rev=391960&view=auto
==============================================================================
--- webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AddressableEchoTest.java (added)
+++ webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AddressableEchoTest.java Thu Apr 6 03:52:31 2006
@@ -0,0 +1,191 @@
+package org.apache.sandesha2.scenarios;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+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.client.async.AsyncResult;
+import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContextConstants;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.client.RMClientAPI;
+import org.apache.sandesha2.client.RMClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.handlers.SandeshaInHandler;
+import org.apache.sandesha2.util.SandeshaUtil;
+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.SOAPBody;
+
+public class AddressableEchoTest extends TestCase {
+
+ SimpleHTTPServer httpServer = null;
+
+ private final static String applicationNamespaceName = "http://tempuri.org/";
+ private final static String echoString = "echoString";
+ private final static String Text = "Text";
+ private final static String Sequence = "Sequence";
+ private final static String echoStringResponse = "echoStringResponse";
+ private final static String EchoStringReturn = "EchoStringReturn";
+
+ public void setUp () throws AxisFault {
+ String repoPath = "target" + File.separator + "repos" + File.separator + "server";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ httpServer = new SimpleHTTPServer (configContext,8060);
+
+ httpServer.start();
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void tearDown () throws SandeshaException {
+ if (httpServer!=null)
+ httpServer.stop();
+
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void testAsyncEcho () throws AxisFault, InterruptedException {
+
+ String to = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+ String transportTo = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+ String acksToEPR = "http://127.0.0.1:6060/axis2/services/__ANONYMOUS_SERVICE__";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ Options clientOptions = new Options ();
+
+ clientOptions.setTo(new EndpointReference (to));
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+
+ String sequenceKey = SandeshaUtil.getUUID();
+ clientOptions.setProperty(RMClientConstants.SEQUENCE_KEY,sequenceKey);
+ clientOptions.setProperty(RMClientConstants.AcksTo,acksToEPR);
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ serviceClient.setOptions(clientOptions);
+ //serviceClient.
+
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+ clientOptions.setUseSeparateListener(true);
+
+ serviceClient.setOptions(clientOptions);
+ serviceClient.engageModule(new QName ("sandesha2")); //engaging the sandesha2 module.
+
+ TestCallback callback1 = new TestCallback ("Callback 1");
+ serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo1",sequenceKey),callback1);
+
+ clientOptions.setProperty(RMClientConstants.LAST_MESSAGE, "true");
+ TestCallback callback2 = new TestCallback ("Callback 2");
+ serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo2",sequenceKey),callback2);
+
+
+ Thread.sleep(12000);
+ serviceClient.finalizeInvoke();
+
+ //assertions for the out sequence.
+ SequenceReport sequenceReport = RMClientAPI.getOutgoingSequenceReport(to,sequenceKey,configContext);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(2)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ assertTrue(callback1.isComplete());
+ assertTrue(callback2.isComplete());
+ assertEquals(callback1.getResult(),"echo1");
+ assertEquals(callback2.getResult(),"echo1echo2");
+ }
+
+ private static OMElement getEchoOMBlock(String text, String sequenceKey) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace applicationNamespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement echoStringElement = fac.createOMElement(echoString, applicationNamespace);
+ OMElement textElem = fac.createOMElement(Text,applicationNamespace);
+ OMElement sequenceElem = fac.createOMElement(Sequence,applicationNamespace);
+
+ textElem.setText(text);
+ sequenceElem.setText(sequenceKey);
+ echoStringElement.addChild(textElem);
+ echoStringElement.addChild(sequenceElem);
+
+ return echoStringElement;
+ }
+
+ class TestCallback extends Callback {
+
+ String name = null;
+ boolean completed = false;
+ boolean errorRported = false;
+ String resultStr;
+
+ public boolean isCompleted() {
+ return completed;
+ }
+
+ public boolean isErrorRported() {
+ return errorRported;
+ }
+
+ public String getResult () {
+ return resultStr;
+ }
+
+ public TestCallback (String name) {
+ this.name = name;
+ }
+
+ public void onComplete(AsyncResult result) {
+ //System.out.println("On Complete Called for " + text);
+ SOAPBody body = result.getResponseEnvelope().getBody();
+
+ OMElement echoStringResponseElem = body.getFirstChildWithName(new QName (applicationNamespaceName,echoStringResponse));
+ if (echoStringResponseElem==null) {
+ System.out.println("Error: SOAPBody does not have a 'echoStringResponse' child");
+ return;
+ }
+
+ OMElement echoStringReturnElem = echoStringResponseElem.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn));
+ if (echoStringReturnElem==null) {
+ System.out.println("Error: 'echoStringResponse' element does not have a 'EchoStringReturn' child");
+ return;
+ }
+
+ String resultStr = echoStringReturnElem.getText();
+ this.resultStr = resultStr;
+ completed = true;
+ }
+
+ public void onError (Exception e) {
+ e.printStackTrace();
+ errorRported = true;
+ }
+ }
+
+}
Added: webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AddressablePingTest.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AddressablePingTest.java?rev=391960&view=auto
==============================================================================
--- webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AddressablePingTest.java (added)
+++ webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AddressablePingTest.java Thu Apr 6 03:52:31 2006
@@ -0,0 +1,148 @@
+/*
+ * 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.sandesha2.scenarios;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.xml.namespace.QName;
+
+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.context.MessageContextConstants;
+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.axis2.transport.http.SimpleHTTPServer;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.client.RMClientAPI;
+import org.apache.sandesha2.client.RMClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+
+public class AddressablePingTest extends TestCase {
+
+ SimpleHTTPServer httpServer = null;
+
+ private final String applicationNamespaceName = "http://tempuri.org/";
+ private final String Ping = "Ping";
+ private final String Text = "Text";
+
+ public void setUp () throws AxisFault {
+ String repoPath = "target" + File.separator + "repos" + File.separator + "server";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ configContext.setProperty("test","test");
+
+ httpServer = new SimpleHTTPServer (configContext,8060);
+
+ httpServer.start();
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void tearDown () throws SandeshaException {
+ if (httpServer!=null)
+ httpServer.stop();
+
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void testAsyncPing () throws AxisFault,IOException {
+
+ String to = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+ String transportTo = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+ String acksToEPR = "http://127.0.0.1:6060/axis2/services/__ANONYMOUS_SERVICE__";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ //clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ Options clientOptions = new Options ();
+ clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ clientOptions.setTo(new EndpointReference (to));
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+
+ String sequenceKey = "sequence2";
+ clientOptions.setProperty(RMClientConstants.SEQUENCE_KEY,sequenceKey);
+ clientOptions.setProperty(RMClientConstants.AcksTo,acksToEPR);
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ //serviceClient.
+
+ serviceClient.engageModule(new QName ("sandesha2"));
+ serviceClient.setOptions(clientOptions);
+
+ serviceClient.fireAndForget(getPingOMBlock("ping1"));
+
+ clientOptions.setProperty(RMClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping2"));
+
+ try {
+ Thread.sleep(7000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ serviceClient.finalizeInvoke();
+
+ SequenceReport sequenceReport = RMClientAPI.getOutgoingSequenceReport(to,sequenceKey,configContext);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(2)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ }
+
+ private OMElement getPingOMBlock(String text) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement pingElem = fac.createOMElement(Ping, namespace);
+ OMElement textElem = fac.createOMElement(Text, namespace);
+
+ textElem.setText(text);
+ pingElem.addChild(textElem);
+
+ return pingElem;
+ }
+
+}
Added: webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AnonymousAckEchoTest.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AnonymousAckEchoTest.java?rev=391960&view=auto
==============================================================================
--- webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AnonymousAckEchoTest.java (added)
+++ webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AnonymousAckEchoTest.java Thu Apr 6 03:52:31 2006
@@ -0,0 +1,185 @@
+package org.apache.sandesha2.scenarios;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+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.SOAPBody;
+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.client.async.AsyncResult;
+import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContextConstants;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.client.RMClientAPI;
+import org.apache.sandesha2.client.RMClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.util.SandeshaUtil;
+
+public class AnonymousAckEchoTest extends TestCase {
+
+ SimpleHTTPServer httpServer = null;
+
+ private final static String applicationNamespaceName = "http://tempuri.org/";
+ private final static String echoString = "echoString";
+ private final static String Text = "Text";
+ private final static String Sequence = "Sequence";
+ private final static String echoStringResponse = "echoStringResponse";
+ private final static String EchoStringReturn = "EchoStringReturn";
+
+ public void setUp () throws AxisFault {
+ String repoPath = "target" + File.separator + "repos" + File.separator + "server";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ httpServer = new SimpleHTTPServer (configContext,8060);
+
+ httpServer.start();
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void tearDown () throws SandeshaException {
+ if (httpServer!=null)
+ httpServer.stop();
+
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void testSyncEcho () throws AxisFault, InterruptedException {
+
+ String to = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+ String transportTo = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ Options clientOptions = new Options ();
+
+ clientOptions.setTo(new EndpointReference (to));
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+
+ String sequenceKey = SandeshaUtil.getUUID();
+ clientOptions.setProperty(RMClientConstants.SEQUENCE_KEY,sequenceKey);
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ serviceClient.setOptions(clientOptions);
+ //serviceClient.
+
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+ clientOptions.setUseSeparateListener(true);
+
+ serviceClient.setOptions(clientOptions);
+ serviceClient.engageModule(new QName ("sandesha2")); //engaging the sandesha2 module.
+
+ TestCallback callback1 = new TestCallback ("Callback 1");
+ serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo1",sequenceKey),callback1);
+
+ clientOptions.setProperty(RMClientConstants.LAST_MESSAGE, "true");
+ TestCallback callback2 = new TestCallback ("Callback 2");
+ serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo2",sequenceKey),callback2);
+
+
+ Thread.sleep(10000);
+ serviceClient.finalizeInvoke();
+
+ //assertions for the out sequence.
+ SequenceReport sequenceReport = RMClientAPI.getOutgoingSequenceReport(to,sequenceKey,configContext);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(2)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ assertEquals(callback1.getResult(),"echo1");
+ assertEquals(callback2.getResult(),"echo1echo2");
+ }
+
+ private static OMElement getEchoOMBlock(String text, String sequenceKey) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace applicationNamespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement echoStringElement = fac.createOMElement(echoString, applicationNamespace);
+ OMElement textElem = fac.createOMElement(Text,applicationNamespace);
+ OMElement sequenceElem = fac.createOMElement(Sequence,applicationNamespace);
+
+ textElem.setText(text);
+ sequenceElem.setText(sequenceKey);
+ echoStringElement.addChild(textElem);
+ echoStringElement.addChild(sequenceElem);
+
+ return echoStringElement;
+ }
+
+ class TestCallback extends Callback {
+
+ String name = null;
+ boolean completed = false;
+ boolean errorRported = false;
+ String resultStr;
+
+ public boolean isCompleted() {
+ return completed;
+ }
+
+ public boolean isErrorRported() {
+ return errorRported;
+ }
+
+ public String getResult () {
+ return resultStr;
+ }
+
+ public TestCallback (String name) {
+ this.name = name;
+ }
+
+ public void onComplete(AsyncResult result) {
+ //System.out.println("On Complete Called for " + text);
+ SOAPBody body = result.getResponseEnvelope().getBody();
+
+ OMElement echoStringResponseElem = body.getFirstChildWithName(new QName (applicationNamespaceName,echoStringResponse));
+ if (echoStringResponseElem==null) {
+ System.out.println("Error: SOAPBody does not have a 'echoStringResponse' child");
+ return;
+ }
+
+ OMElement echoStringReturnElem = echoStringResponseElem.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn));
+ if (echoStringReturnElem==null) {
+ System.out.println("Error: 'echoStringResponse' element does not have a 'EchoStringReturn' child");
+ return;
+ }
+
+ String resultStr = echoStringReturnElem.getText();
+ this.resultStr = resultStr;
+ completed = true;
+ }
+
+ public void onError (Exception e) {
+ e.printStackTrace();
+ errorRported = true;
+ }
+ }
+
+}
Added: webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AnonymousPingTest.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AnonymousPingTest.java?rev=391960&view=auto
==============================================================================
--- webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AnonymousPingTest.java (added)
+++ webservices/sandesha/trunk/test/src/org/apache/sandesha2/scenarios/AnonymousPingTest.java Thu Apr 6 03:52:31 2006
@@ -0,0 +1,140 @@
+/*
+ * 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.sandesha2.scenarios;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+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.axis2.AxisFault;
+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.context.MessageContextConstants;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.client.RMClientAPI;
+import org.apache.sandesha2.client.RMClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+
+public class AnonymousPingTest extends TestCase{
+
+ SimpleHTTPServer httpServer = null;
+ private final String applicationNamespaceName = "http://tempuri.org/";
+ private final String Ping = "Ping";
+ private final String Text = "Text";
+
+ public void setUp () throws AxisFault {
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "server";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+
+ httpServer = new SimpleHTTPServer (configContext,8060);
+ httpServer.start();
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void tearDown () throws SandeshaException {
+ if (httpServer!=null)
+ httpServer.stop();
+
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void testSyncPing () throws AxisFault,InterruptedException {
+
+ String to = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+ String transportTo = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ //clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ Options clientOptions = new Options ();
+ clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ clientOptions.setTo(new EndpointReference (to));
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+
+ String sequenceKey = "sequence1";
+ clientOptions.setProperty(RMClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ //serviceClient.
+
+ serviceClient.engageModule(new QName ("sandesha2"));
+ serviceClient.setOptions(clientOptions);
+
+ serviceClient.fireAndForget(getPingOMBlock("ping1"));
+ serviceClient.fireAndForget(getPingOMBlock("ping2"));
+
+ clientOptions.setProperty(RMClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+
+ Thread.sleep(5000);
+
+
+ Thread.sleep(10000);
+ serviceClient.finalizeInvoke();
+
+ SequenceReport sequenceReport = RMClientAPI.getOutgoingSequenceReport(to,sequenceKey,configContext);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(2)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+ }
+
+ private OMElement getPingOMBlock(String text) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement pingElem = fac.createOMElement(Ping, namespace);
+ OMElement textElem = fac.createOMElement(Text, namespace);
+
+ textElem.setText(text);
+ pingElem.addChild(textElem);
+
+ return pingElem;
+ }
+
+}
Added: webservices/sandesha/trunk/test/src/org/apache/sandesha2/versions/AddressingVersionTest.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/test/src/org/apache/sandesha2/versions/AddressingVersionTest.java?rev=391960&view=auto
==============================================================================
--- webservices/sandesha/trunk/test/src/org/apache/sandesha2/versions/AddressingVersionTest.java (added)
+++ webservices/sandesha/trunk/test/src/org/apache/sandesha2/versions/AddressingVersionTest.java Thu Apr 6 03:52:31 2006
@@ -0,0 +1,159 @@
+package org.apache.sandesha2.versions;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+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.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingConstants;
+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.context.MessageContextConstants;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.client.RMClientAPI;
+import org.apache.sandesha2.client.RMClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+import junit.framework.TestCase;
+
+public class AddressingVersionTest extends TestCase {
+
+
+ SimpleHTTPServer httpServer = null;
+ private final String applicationNamespaceName = "http://tempuri.org/";
+ private final String Ping = "Ping";
+ private final String Text = "Text";
+
+ public void setUp () throws AxisFault {
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "server";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+
+ httpServer = new SimpleHTTPServer (configContext,8060);
+ httpServer.start();
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void tearDown () throws SandeshaException {
+ if (httpServer!=null)
+ httpServer.stop();
+
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void testAddressingFinal () throws AxisFault,InterruptedException {
+
+ String to = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+ String transportTo = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ //clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ Options clientOptions = new Options ();
+ clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ clientOptions.setTo(new EndpointReference (to));
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+
+ String sequenceKey = "sequence1";
+ clientOptions.setProperty(RMClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ //setting the addressing version as Final
+ clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Final.WSA_NAMESPACE);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ //serviceClient.
+
+ serviceClient.engageModule(new QName ("sandesha2"));
+ serviceClient.setOptions(clientOptions);
+
+ clientOptions.setProperty(RMClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ Thread.sleep(5000);
+ serviceClient.finalizeInvoke();
+
+ SequenceReport sequenceReport = RMClientAPI.getOutgoingSequenceReport(to,sequenceKey,configContext);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ }
+
+ public void testAddressingSubmission () throws AxisFault,InterruptedException {
+
+ String to = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+ String transportTo = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ //clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ Options clientOptions = new Options ();
+ clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ clientOptions.setTo(new EndpointReference (to));
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+
+ String sequenceKey = "sequence1";
+ clientOptions.setProperty(RMClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ //setting the addressing version as Submission
+ clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ //serviceClient.
+
+ serviceClient.engageModule(new QName ("sandesha2"));
+ serviceClient.setOptions(clientOptions);
+
+ clientOptions.setProperty(RMClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ Thread.sleep(5000);
+ serviceClient.finalizeInvoke();
+
+ SequenceReport sequenceReport = RMClientAPI.getOutgoingSequenceReport(to,sequenceKey,configContext);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ }
+
+ private OMElement getPingOMBlock(String text) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement pingElem = fac.createOMElement(Ping, namespace);
+ OMElement textElem = fac.createOMElement(Text, namespace);
+
+ textElem.setText(text);
+ pingElem.addChild(textElem);
+
+ return pingElem;
+ }
+}
Added: webservices/sandesha/trunk/test/src/org/apache/sandesha2/versions/RMVersionTest.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/test/src/org/apache/sandesha2/versions/RMVersionTest.java?rev=391960&view=auto
==============================================================================
--- webservices/sandesha/trunk/test/src/org/apache/sandesha2/versions/RMVersionTest.java (added)
+++ webservices/sandesha/trunk/test/src/org/apache/sandesha2/versions/RMVersionTest.java Thu Apr 6 03:52:31 2006
@@ -0,0 +1,160 @@
+package org.apache.sandesha2.versions;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+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.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingConstants;
+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.context.MessageContextConstants;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.client.RMClientAPI;
+import org.apache.sandesha2.client.RMClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+import junit.framework.TestCase;
+
+public class RMVersionTest extends TestCase {
+
+
+ SimpleHTTPServer httpServer = null;
+ private final String applicationNamespaceName = "http://tempuri.org/";
+ private final String Ping = "Ping";
+ private final String Text = "Text";
+
+ public void setUp () throws AxisFault {
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "server";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+
+ httpServer = new SimpleHTTPServer (configContext,8060);
+ httpServer.start();
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void tearDown () throws SandeshaException {
+ if (httpServer!=null)
+ httpServer.stop();
+
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void testRMSubmission () throws AxisFault,InterruptedException {
+
+ String to = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+ String transportTo = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ //clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ Options clientOptions = new Options ();
+ clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ clientOptions.setTo(new EndpointReference (to));
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+
+ String sequenceKey = "sequence1";
+ clientOptions.setProperty(RMClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ //setting the addressing version as submission
+ clientOptions.setProperty(RMClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.WSRM);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ //serviceClient.
+
+ serviceClient.engageModule(new QName ("sandesha2"));
+ serviceClient.setOptions(clientOptions);
+
+ clientOptions.setProperty(RMClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ Thread.sleep(5000);
+ serviceClient.finalizeInvoke();
+
+ SequenceReport sequenceReport = RMClientAPI.getOutgoingSequenceReport(to,sequenceKey,configContext);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ }
+
+ public void testRMOASIS () throws AxisFault,InterruptedException {
+
+ String to = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+ String transportTo = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ //clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ Options clientOptions = new Options ();
+ clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ clientOptions.setTo(new EndpointReference (to));
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+
+ String sequenceKey = "sequence1";
+ clientOptions.setProperty(RMClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ //setting the RM version as OASIS.
+ clientOptions.setProperty(RMClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.WSRX);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ //serviceClient.
+
+ serviceClient.engageModule(new QName ("sandesha2"));
+ serviceClient.setOptions(clientOptions);
+
+ clientOptions.setProperty(RMClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ Thread.sleep(5000);
+ serviceClient.finalizeInvoke();
+
+ SequenceReport sequenceReport = RMClientAPI.getOutgoingSequenceReport(to,sequenceKey,configContext);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ }
+
+ private OMElement getPingOMBlock(String text) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement pingElem = fac.createOMElement(Ping, namespace);
+ OMElement textElem = fac.createOMElement(Text, namespace);
+
+ textElem.setText(text);
+ pingElem.addChild(textElem);
+
+ return pingElem;
+ }
+}
Added: webservices/sandesha/trunk/test/src/org/apache/sandesha2/versions/SOAPVersionTest.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/test/src/org/apache/sandesha2/versions/SOAPVersionTest.java?rev=391960&view=auto
==============================================================================
--- webservices/sandesha/trunk/test/src/org/apache/sandesha2/versions/SOAPVersionTest.java (added)
+++ webservices/sandesha/trunk/test/src/org/apache/sandesha2/versions/SOAPVersionTest.java Thu Apr 6 03:52:31 2006
@@ -0,0 +1,157 @@
+package org.apache.sandesha2.versions;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+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.axis2.AxisFault;
+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.context.MessageContextConstants;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.client.RMClientAPI;
+import org.apache.sandesha2.client.RMClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+import junit.framework.TestCase;
+
+public class SOAPVersionTest extends TestCase {
+
+
+ SimpleHTTPServer httpServer = null;
+ private final String applicationNamespaceName = "http://tempuri.org/";
+ private final String Ping = "Ping";
+ private final String Text = "Text";
+
+ public void setUp () throws AxisFault {
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "server";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+
+ httpServer = new SimpleHTTPServer (configContext,8060);
+ httpServer.start();
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void tearDown () throws SandeshaException {
+ if (httpServer!=null)
+ httpServer.stop();
+
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ throw new SandeshaException ("sleep interupted");
+ }
+ }
+
+ public void testSOAP11 () throws AxisFault,InterruptedException {
+
+ String to = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+ String transportTo = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ Options clientOptions = new Options ();
+
+ clientOptions.setTo(new EndpointReference (to));
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+
+ String sequenceKey = "sequence1";
+ clientOptions.setProperty(RMClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ //setting the SOAP version as 1.1
+ clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ //serviceClient.
+
+ serviceClient.engageModule(new QName ("sandesha2"));
+ serviceClient.setOptions(clientOptions);
+
+ clientOptions.setProperty(RMClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ Thread.sleep(5000);
+ serviceClient.finalizeInvoke();
+
+ SequenceReport sequenceReport = RMClientAPI.getOutgoingSequenceReport(to,sequenceKey,configContext);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ }
+
+ public void testSOAP12 () throws AxisFault,InterruptedException {
+
+ String to = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+ String transportTo = "http://127.0.0.1:8060/axis2/services/RMInteropService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ Options clientOptions = new Options ();
+ clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ clientOptions.setTo(new EndpointReference (to));
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
+
+ String sequenceKey = "sequence1";
+ clientOptions.setProperty(RMClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ //setting the SOAP version as 1.2
+ clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ //serviceClient.
+
+ serviceClient.engageModule(new QName ("sandesha2"));
+ serviceClient.setOptions(clientOptions);
+
+ clientOptions.setProperty(RMClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ Thread.sleep(5000);
+ serviceClient.finalizeInvoke();
+
+ SequenceReport sequenceReport = RMClientAPI.getOutgoingSequenceReport(to,sequenceKey,configContext);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ }
+
+ private OMElement getPingOMBlock(String text) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement pingElem = fac.createOMElement(Ping, namespace);
+ OMElement textElem = fac.createOMElement(Text, namespace);
+
+ textElem.setText(text);
+ pingElem.addChild(textElem);
+
+ return pingElem;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org