You are viewing a plain text version of this content. The canonical link for it is here.
Posted to sandesha-dev@ws.apache.org by ch...@apache.org on 2006/06/15 07:51:24 UTC
svn commit: r414476 [13/15] - in /webservices/sandesha/trunk: ./ c/ config/
interop/ java/ java/config/ java/interop/ java/interop/conf/
java/interop/src/ java/interop/src/org/ java/interop/src/org/apache/
java/interop/src/org/apache/sandesha2/ java/in...
Added: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/scenarios/AddressableEchoTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/scenarios/AddressableEchoTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/scenarios/AddressableEchoTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/scenarios/AddressableEchoTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,261 @@
+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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.util.SandeshaUtil;
+
+public class AddressableEchoTest extends SandeshaTestCase {
+
+ 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";
+ int serverPort = DEFAULT_SERVER_TEST_PORT;
+ private Log log = LogFactory.getLog(getClass());
+
+ public AddressableEchoTest () {
+ super ("AddressableEchoTest");
+ }
+
+ 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 + "server_axis2.xml";
+
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ String serverPortStr = getTestProperty("test.server.port");
+ if (serverPortStr!=null) {
+
+ try {
+ serverPort = Integer.parseInt(serverPortStr);
+ } catch (NumberFormatException e) {
+ log.error(e);
+ }
+ }
+
+ httpServer = new SimpleHTTPServer (configContext,serverPort);
+ 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:" + serverPort + "/axis2/services/RMSampleService";
+ String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_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(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+
+ String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+ clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+
+ serviceClient.setOptions(clientOptions);
+ //serviceClient.
+
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+ clientOptions.setUseSeparateListener(true);
+
+ serviceClient.setOptions(clientOptions);
+
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ TestCallback callback1 = new TestCallback ("Callback 1");
+ serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo1",sequenceKey),callback1);
+
+
+ Thread.sleep(40000);
+
+ //assertions for the out sequence.
+ SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ assertTrue(callback1.isComplete());
+ assertEquals(callback1.getResult(),"echo1");
+
+ serviceClient.finalizeInvoke();
+ }
+
+ public void testAsyncEchoWithOffer () throws AxisFault, InterruptedException {
+
+ String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+ String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_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(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+
+ String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+ clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+
+ String offeredSequeiceId = SandeshaUtil.getUUID();
+ clientOptions.setProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID,offeredSequeiceId);
+
+ serviceClient.setOptions(clientOptions);
+ //serviceClient.
+
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+ clientOptions.setUseSeparateListener(true);
+
+ serviceClient.setOptions(clientOptions);
+
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ TestCallback callback1 = new TestCallback ("Callback 1");
+ serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo1",sequenceKey),callback1);
+
+
+ Thread.sleep(40000);
+
+ //assertions for the out sequence.
+ SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ assertTrue(callback1.isComplete());
+ assertEquals(callback1.getResult(),"echo1");
+
+ serviceClient.finalizeInvoke();
+ }
+
+ 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/java/test/src/org/apache/sandesha2/scenarios/AddressablePingTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/scenarios/AddressablePingTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/scenarios/AddressablePingTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/scenarios/AddressablePingTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,160 @@
+/*
+ * 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 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.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.axis2.transport.http.SimpleHTTPServer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+
+public class AddressablePingTest extends SandeshaTestCase {
+
+ SimpleHTTPServer httpServer = null;
+
+ private final String applicationNamespaceName = "http://tempuri.org/";
+ private final String ping = "ping";
+ private final String Text = "Text";
+ int serverPort = DEFAULT_SERVER_TEST_PORT;
+ private Log log = LogFactory.getLog(getClass());
+
+ public AddressablePingTest () {
+ super ("AddressablePingTest");
+ }
+
+ 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 + "server_axis2.xml";
+
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ String serverPortStr = getTestProperty("test.server.port");
+ if (serverPortStr!=null) {
+
+ try {
+ serverPort = Integer.parseInt(serverPortStr);
+ } catch (NumberFormatException e) {
+ log.error(e);
+ }
+ }
+
+ httpServer = new SimpleHTTPServer (configContext,serverPort);
+ 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:" + serverPort + "/axis2/services/RMSampleService";
+ String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_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(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+
+ String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+ clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+
+ //serviceClient.
+ serviceClient.setOptions(clientOptions);
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping2"));
+
+ try {
+ Thread.sleep(30000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ serviceClient.finalizeInvoke();
+ }
+
+ 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/java/test/src/org/apache/sandesha2/scenarios/AnonymousAckEchoTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/scenarios/AnonymousAckEchoTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/scenarios/AnonymousAckEchoTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/scenarios/AnonymousAckEchoTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,200 @@
+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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.util.SandeshaUtil;
+
+public class AnonymousAckEchoTest extends SandeshaTestCase {
+
+ 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";
+ int serverPort = DEFAULT_SERVER_TEST_PORT;
+ private Log log = LogFactory.getLog(getClass());
+
+ public AnonymousAckEchoTest () {
+ super ("AnonymousAckEchoTest");
+ }
+
+ 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 + "server_axis2.xml";
+
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ String serverPortStr = getTestProperty("test.server.port");
+ if (serverPortStr!=null) {
+
+ try {
+ serverPort = Integer.parseInt(serverPortStr);
+ } catch (NumberFormatException e) {
+ log.error(e);
+ }
+ }
+
+ httpServer = new SimpleHTTPServer (configContext,serverPort);
+ 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:" + serverPort + "/axis2/services/RMSampleService";
+ String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_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(SandeshaClientConstants.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);
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ TestCallback callback1 = new TestCallback ("Callback 1");
+ serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo1",sequenceKey),callback1);
+
+
+ Thread.sleep(40000);
+
+ //assertions for the out sequence.
+ SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ assertEquals(callback1.getResult(),"echo1");
+
+ serviceClient.finalizeInvoke();
+ }
+
+ 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/java/test/src/org/apache/sandesha2/scenarios/AnonymousPingTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/scenarios/AnonymousPingTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/scenarios/AnonymousPingTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/scenarios/AnonymousPingTest.java Wed Jun 14 22:51:15 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 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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+
+public class AnonymousPingTest extends SandeshaTestCase {
+
+ SimpleHTTPServer httpServer = null;
+ private final String applicationNamespaceName = "http://tempuri.org/";
+ private final String ping = "ping";
+ private final String Text = "Text";
+
+ private Log log = LogFactory.getLog(getClass());
+ int serverPort = DEFAULT_SERVER_TEST_PORT;
+
+ public AnonymousPingTest () {
+ super ("AnonymousPingTest");
+ }
+
+ 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 + "server_axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+
+ String serverPortStr = getTestProperty("test.server.port");
+ if (serverPortStr!=null) {
+ try {
+ serverPort = Integer.parseInt(serverPortStr);
+ } catch (NumberFormatException e) {
+ log.error(e);
+ }
+ }
+
+ httpServer = new SimpleHTTPServer (configContext,serverPort);
+ 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:" + serverPort + "/axis2/services/RMSampleService";
+ String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_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(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ //serviceClient.
+
+ serviceClient.setOptions(clientOptions);
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping1"));
+
+ Thread.sleep(10000);
+
+ SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ serviceClient.finalizeInvoke();
+ }
+
+ 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/java/test/src/org/apache/sandesha2/storage/CreateSeqBeanMgrTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/CreateSeqBeanMgrTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/CreateSeqBeanMgrTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/CreateSeqBeanMgrTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,115 @@
+package org.apache.sandesha2.storage;
+
+import org.apache.sandesha2.storage.beanmanagers.CreateSeqBeanMgr;
+import org.apache.sandesha2.storage.beans.CreateSeqBean;
+import org.apache.sandesha2.util.PropertyManager;
+import org.apache.sandesha2.util.SandeshaPropertyBean;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.context.ConfigurationContext;
+
+import java.util.Iterator;
+/*
+ * 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.
+ */
+
+public class CreateSeqBeanMgrTest extends SandeshaTestCase {
+ private CreateSeqBeanMgr mgr;
+ Transaction transaction;
+
+ public CreateSeqBeanMgrTest() {
+ super("CreateSeqBeanMgrTest");
+ }
+
+ public void setUp() throws Exception {
+
+ AxisConfiguration axisConfig = new AxisConfiguration();
+ SandeshaPropertyBean propertyBean = PropertyManager.loadPropertiesFromDefaultValues();
+ Parameter parameter = new Parameter ();
+ parameter.setName(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
+ parameter.setValue(propertyBean);
+ axisConfig.addParameter(parameter);
+
+ ConfigurationContext configCtx = new ConfigurationContext(axisConfig);
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ configCtx.setProperty(Sandesha2Constants.MODULE_CLASS_LOADER,classLoader);
+
+ StorageManager storageManager = SandeshaUtil.getInMemoryStorageManager(configCtx);
+ transaction = storageManager.getTransaction();
+ mgr = storageManager.getCreateSeqBeanMgr();
+ }
+
+ public void tearDown() throws Exception {
+ transaction.commit();
+ }
+
+ public void testDelete() throws SandeshaStorageException {
+ mgr.insert(new CreateSeqBean("TmpSeqId1", "CreateSeqMsgId1", "SeqId1"));
+ mgr.delete("CreateSeqMsgId1");
+ assertNull(mgr.retrieve("CreateSeqMsgId1"));
+ }
+
+ public void testFind() throws SandeshaStorageException {
+ mgr.insert(new CreateSeqBean("TmpSeqId2", "CreateSeqMsgId2", "SeqId2"));
+ mgr.insert(new CreateSeqBean("TmpSeqId2", "CreateSeqMsgId3", "SeqId3"));
+
+ CreateSeqBean target = new CreateSeqBean();
+ target.setInternalSequenceID("TmpSeqId2");
+
+ Iterator iter = mgr.find(target).iterator();
+ CreateSeqBean tmp = (CreateSeqBean) iter.next();
+ if (tmp.getCreateSeqMsgID().equals("CreateSeqMsgId1")) {
+ tmp = (CreateSeqBean) iter.next();
+ assertTrue(tmp.getCreateSeqMsgID().equals("CreateSeqMsgId2"));
+
+ } else {
+ tmp = (CreateSeqBean) iter.next();
+ assertTrue(tmp.getCreateSeqMsgID().equals("CreateSeqMsgId3"));
+ }
+ }
+
+ public void testInsert() throws SandeshaStorageException{
+ CreateSeqBean bean = new CreateSeqBean("TmpSeqId4", "CreateSeqMsgId4", "SeqId4");
+ mgr.insert(bean);
+ CreateSeqBean tmpbean = mgr.retrieve("CreateSeqMsgId4");
+ assertTrue(tmpbean.getCreateSeqMsgID().equals("CreateSeqMsgId4"));
+ assertTrue(tmpbean.getSequenceID().equals("SeqId4"));
+ assertTrue(tmpbean.getInternalSequenceID().equals("TmpSeqId4"));
+ }
+
+
+ public void testRetrieve() throws SandeshaStorageException{
+ assertNull(mgr.retrieve("CreateSeqMsgId5"));
+
+ CreateSeqBean bean = new CreateSeqBean("TmpSeqId5", "CreateSeqMsgId5", "SeqId5");
+ mgr.insert(bean);
+ CreateSeqBean tmp = mgr.retrieve("CreateSeqMsgId5");
+ assertTrue(tmp.getCreateSeqMsgID().equals("CreateSeqMsgId5"));
+ }
+
+ public void testUpdate() throws SandeshaStorageException {
+
+ CreateSeqBean bean = new CreateSeqBean("TmpSeqId6", "CreateSeqMsgId6", "SeqId6");
+ mgr.insert(bean);
+ bean.setInternalSequenceID("TmpSeqId7");
+ mgr.update(bean);
+ CreateSeqBean tmp = mgr.retrieve("CreateSeqMsgId6");
+ assertTrue(tmp.getInternalSequenceID().equals("TmpSeqId7"));
+ }
+}
Added: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/NextMsgBeanMgrTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/NextMsgBeanMgrTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/NextMsgBeanMgrTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/NextMsgBeanMgrTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,114 @@
+package org.apache.sandesha2.storage;
+
+import org.apache.sandesha2.storage.beanmanagers.NextMsgBeanMgr;
+import org.apache.sandesha2.storage.beans.NextMsgBean;
+import org.apache.sandesha2.util.PropertyManager;
+import org.apache.sandesha2.util.SandeshaPropertyBean;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.context.ConfigurationContext;
+
+import java.util.Iterator;
+/*
+ * 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.
+ */
+
+public class NextMsgBeanMgrTest extends SandeshaTestCase {
+
+ private NextMsgBeanMgr mgr;
+ Transaction transaction;
+
+ public NextMsgBeanMgrTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ AxisConfiguration axisConfig = new AxisConfiguration();
+ SandeshaPropertyBean propertyBean = PropertyManager.loadPropertiesFromDefaultValues();
+ Parameter parameter = new Parameter ();
+ parameter.setName(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
+ parameter.setValue(propertyBean);
+ axisConfig.addParameter(parameter);
+
+ ConfigurationContext configCtx = new ConfigurationContext(axisConfig);
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ configCtx.setProperty(Sandesha2Constants.MODULE_CLASS_LOADER,classLoader);
+
+
+ StorageManager storageManager = SandeshaUtil.getInMemoryStorageManager(configCtx);
+ transaction = storageManager.getTransaction();
+ mgr = storageManager.getNextMsgBeanMgr();
+
+ }
+
+ public void tearDown() throws Exception {
+ transaction.commit();
+ }
+
+ public void testDelete() throws SandeshaStorageException{
+ mgr.insert(new NextMsgBean("SeqId1", 1001));
+ mgr.delete("SeqId1");
+ assertNull(mgr.retrieve("SeqId1"));
+ }
+
+ public void testFind() throws SandeshaStorageException {
+ mgr.insert(new NextMsgBean("SeqId2", 1002));
+ mgr.insert(new NextMsgBean("SeqId3", 1002));
+
+ NextMsgBean target = new NextMsgBean();
+ target.setNextMsgNoToProcess(1002);
+
+ Iterator iterator = mgr.find(target).iterator();
+ NextMsgBean tmp = (NextMsgBean) iterator.next();
+
+ if (tmp.getSequenceID().equals("SeqId2")) {
+ tmp = (NextMsgBean) iterator.next();
+ tmp.getSequenceID().equals("SeqId3");
+ } else {
+ tmp = (NextMsgBean) iterator.next();
+ tmp.getSequenceID().equals("SeqId2");
+ }
+
+ }
+
+ public void testInsert() throws SandeshaStorageException {
+ NextMsgBean bean = new NextMsgBean("SeqId4", 1004);
+ mgr.insert(bean);
+ NextMsgBean tmp = mgr.retrieve("SeqId4");
+ assertTrue(tmp.getNextMsgNoToProcess() == 1004);
+ }
+
+ public void testRetrieve() throws SandeshaStorageException {
+ assertNull(mgr.retrieve("SeqId5"));
+ mgr.insert(new NextMsgBean("SeqId5", 1005));
+
+ NextMsgBean tmp = mgr.retrieve("SeqId5");
+ assertTrue(tmp.getNextMsgNoToProcess() == 1005);
+ }
+
+ public void testUpdate() throws SandeshaStorageException {
+ NextMsgBean bean = new NextMsgBean("SeqId6", 1006);
+ mgr.insert(bean);
+ bean.setNextMsgNoToProcess(1007);
+ mgr.update(bean);
+ NextMsgBean tmp = mgr.retrieve("SeqId6");
+ assertTrue(tmp.getNextMsgNoToProcess() ==1007);
+ }
+
+}
Added: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/RetransmitterBeanMgrTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/RetransmitterBeanMgrTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/RetransmitterBeanMgrTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/RetransmitterBeanMgrTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,143 @@
+package org.apache.sandesha2.storage;
+
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.storage.beanmanagers.SenderBeanMgr;
+import org.apache.sandesha2.storage.beans.SenderBean;
+import org.apache.sandesha2.util.PropertyManager;
+import org.apache.sandesha2.util.SandeshaPropertyBean;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.context.ConfigurationContext;
+
+import java.util.Iterator;
+/*
+ * 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.
+ */
+
+public class RetransmitterBeanMgrTest extends SandeshaTestCase {
+
+ private SenderBeanMgr mgr;
+ Transaction transaction;
+
+ public RetransmitterBeanMgrTest() {
+ super("RetransmitterBeanMgrTest");
+ }
+
+ public void setUp() throws Exception {
+ AxisConfiguration axisConfig = new AxisConfiguration();
+ SandeshaPropertyBean propertyBean = PropertyManager.loadPropertiesFromDefaultValues();
+ Parameter parameter = new Parameter ();
+ parameter.setName(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
+ parameter.setValue(propertyBean);
+ axisConfig.addParameter(parameter);
+
+ ConfigurationContext configCtx = new ConfigurationContext(axisConfig);
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ configCtx.setProperty(Sandesha2Constants.MODULE_CLASS_LOADER,classLoader);
+
+ StorageManager storageManager = SandeshaUtil.getInMemoryStorageManager(configCtx);
+ transaction = storageManager.getTransaction();
+ mgr = storageManager.getRetransmitterBeanMgr();
+ }
+
+ public void tearDown() throws Exception {
+ transaction.commit();
+ }
+
+ public void testDelete() throws SandeshaStorageException {
+ assertNull(mgr.retrieve(""));
+ try {
+ mgr.insert(new SenderBean("MsgId1", "Key1", false , 1001 , "TmpSeqId1", 1001));
+ } catch (Exception ex) {
+ fail("should not throw an exception");
+ }
+ assertNotNull(mgr.retrieve("MsgId1"));
+ }
+
+ public void testFind() throws SandeshaStorageException {
+ try {
+ mgr.insert(new SenderBean("MsgId2", "Key2", false , 1001 , "TmpSeqId2", 1002));
+ mgr.insert(new SenderBean("MsgId3", "Key3", false , 1001 , "TmpSeqId2", 1003));
+
+ SenderBean target = new SenderBean();
+ target.setInternalSequenceID("TmpSeqId2");
+
+ Iterator iterator = mgr.find(target).iterator();
+ SenderBean tmp = (SenderBean) iterator.next();
+
+ if (tmp.getMessageID().equals("MsgId2")) {
+ tmp = (SenderBean) iterator.next();
+ assertTrue(tmp.getMessageID().equals("MsgId3"));
+ } else {
+ tmp = (SenderBean) iterator.next();
+ assertTrue(tmp.getMessageID().equals("MsgId2"));
+ }
+
+
+ } catch (SandeshaException e) {
+ fail("should not throw an exception");
+ }
+
+
+ }
+
+ public void testInsert() throws SandeshaStorageException {
+// try {
+// mgr.insert(new SenderBean());
+// fail("should throw an exception");
+//
+// } catch (SandeshaException ex) {
+// }
+
+ try {
+ mgr.insert(new SenderBean("MsgId4","Key4", false , 1001 , "TmpSeqId4", 1004));
+ SenderBean tmp = mgr.retrieve("MsgId4");
+ assertTrue(tmp.getMessageContextRefKey().equals("Key4"));
+
+
+ } catch (SandeshaException e) {
+ fail("should not throw an exception");
+ }
+
+ }
+
+ public void testRetrieve() throws SandeshaStorageException {
+ assertNull(mgr.retrieve("MsgId5"));
+ try {
+ mgr.insert(new SenderBean("MsgId5", "Key5", false , 1001 , "TmpSeqId5", 1005));
+ } catch (SandeshaException e) {
+ fail("this should not throw an exception");
+ }
+ assertNotNull(mgr.retrieve("MsgId5"));
+ }
+
+ public void testUpdate() throws SandeshaStorageException {
+ SenderBean bean = new SenderBean("MsgId6", "Key6", false , 1001 , "TmpSeqId6", 1006);
+ try {
+ mgr.insert(bean);
+ } catch (SandeshaException e) {
+ fail("should not throw an exception");
+ }
+ bean.setSend(true);
+ mgr.update(bean);
+
+ SenderBean tmp = mgr.retrieve("MsgId6");
+ assertTrue(tmp.isSend());
+ }
+}
Added: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/SequencePropertyBeanMgrTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/SequencePropertyBeanMgrTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/SequencePropertyBeanMgrTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/SequencePropertyBeanMgrTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,107 @@
+package org.apache.sandesha2.storage;
+
+import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
+import org.apache.sandesha2.storage.beans.SequencePropertyBean;
+import org.apache.sandesha2.util.PropertyManager;
+import org.apache.sandesha2.util.SandeshaPropertyBean;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.context.ConfigurationContext;
+
+import java.util.Iterator;
+/*
+ * 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.
+ */
+
+public class SequencePropertyBeanMgrTest extends SandeshaTestCase {
+ SequencePropertyBeanMgr mgr;
+ Transaction transaction;
+
+ public SequencePropertyBeanMgrTest() {
+ super("SequencePropertyBeanMgrTest");
+ }
+
+ public void setUp() throws Exception {
+ AxisConfiguration axisConfig = new AxisConfiguration();
+ SandeshaPropertyBean propertyBean = PropertyManager.loadPropertiesFromDefaultValues();
+ Parameter parameter = new Parameter ();
+ parameter.setName(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
+ parameter.setValue(propertyBean);
+ axisConfig.addParameter(parameter);
+
+ ConfigurationContext configCtx = new ConfigurationContext(axisConfig);
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ configCtx.setProperty(Sandesha2Constants.MODULE_CLASS_LOADER,classLoader);
+
+ StorageManager storageManager = SandeshaUtil.getInMemoryStorageManager(configCtx);
+ transaction = storageManager.getTransaction();
+ mgr = storageManager.getSequencePropretyBeanMgr();
+
+ }
+
+ public void tearDown() throws Exception {
+ transaction.commit();
+ }
+
+ public void testDelete() throws SandeshaStorageException {
+ mgr.insert(new SequencePropertyBean("SeqId1", "Name1", "Value1"));
+ mgr.delete("SeqId1", "Name1");
+ assertNull(mgr.retrieve("SeqId1", "Name1"));
+ }
+
+ public void testFind() throws SandeshaStorageException {
+ mgr.insert(new SequencePropertyBean("SeqId2", "Name2", "Value2"));
+ mgr.insert(new SequencePropertyBean("SeqId3", "Name3", "Value2"));
+
+ SequencePropertyBean bean = new SequencePropertyBean();
+ bean.setValue("Value2");
+ Iterator iter = mgr.find(bean).iterator();
+ SequencePropertyBean tmp = (SequencePropertyBean) iter.next();
+ if (tmp.getSequenceID().equals("SeqId2")) {
+ tmp = (SequencePropertyBean) iter.next();
+ assertTrue(tmp.getSequenceID().equals("SeqId3"));
+ } else {
+ tmp = (SequencePropertyBean) iter.next();
+ assertTrue(tmp.getSequenceID().equals("SeqId2"));
+ }
+ }
+
+ public void testInsert() throws SandeshaStorageException {
+ mgr.insert(new SequencePropertyBean("SeqId4", "Name4", "Value4"));
+ SequencePropertyBean tmp = mgr.retrieve("SeqId4", "Name4");
+ assertTrue(tmp.getValue().equals("Value4"));
+
+ }
+
+ public void testRetrieve() throws SandeshaStorageException {
+ assertNull(mgr.retrieve("SeqId5", "Name5"));
+ mgr.insert(new SequencePropertyBean("SeqId5", "Name5", "Value5"));
+ assertNotNull(mgr.retrieve("SeqId5", "Name5"));
+ }
+
+
+ public void testUpdate() throws SandeshaStorageException {
+ SequencePropertyBean bean = new SequencePropertyBean("SeqId6", "Name6", "Value6");
+ mgr.insert(bean);
+ bean.setValue("Value7");
+ mgr.update(bean);
+ SequencePropertyBean tmp = mgr.retrieve("SeqId6", "Name6");
+ assertTrue(tmp.getValue().equals("Value7"));
+ }
+}
Added: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/StorageMapBeanMgrTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/StorageMapBeanMgrTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/StorageMapBeanMgrTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/StorageMapBeanMgrTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,108 @@
+package org.apache.sandesha2.storage;
+
+import org.apache.sandesha2.storage.beanmanagers.InvokerBeanMgr;
+import org.apache.sandesha2.storage.beans.InvokerBean;
+import org.apache.sandesha2.util.PropertyManager;
+import org.apache.sandesha2.util.SandeshaPropertyBean;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.context.ConfigurationContext;
+
+import java.util.Iterator;
+/*
+ * 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.
+ */
+
+public class StorageMapBeanMgrTest extends SandeshaTestCase {
+
+ InvokerBeanMgr mgr;
+ Transaction transaction;
+
+ public StorageMapBeanMgrTest() {
+ super ("StorageMapBeanMgrTest");
+ }
+
+ public void setUp() throws Exception {
+ AxisConfiguration axisConfig = new AxisConfiguration();
+ SandeshaPropertyBean propertyBean = PropertyManager.loadPropertiesFromDefaultValues();
+ Parameter parameter = new Parameter ();
+ parameter.setName(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
+ parameter.setValue(propertyBean);
+ axisConfig.addParameter(parameter);
+
+ ConfigurationContext configCtx = new ConfigurationContext(axisConfig);
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ configCtx.setProperty(Sandesha2Constants.MODULE_CLASS_LOADER,classLoader);
+
+ StorageManager storageManager = SandeshaUtil.getInMemoryStorageManager(configCtx);
+ transaction = storageManager.getTransaction();
+ mgr = storageManager.getStorageMapBeanMgr();
+ }
+
+ public void tearDown() throws Exception {
+ transaction.commit();
+ }
+
+ public void testDelete() throws SandeshaStorageException {
+ mgr.insert(new InvokerBean("Key1", 1001, "SeqId1"));
+ mgr.delete("Key1");
+ assertNull(mgr.retrieve("Key1"));
+ }
+
+ public void testFind() throws SandeshaStorageException {
+ mgr.insert(new InvokerBean("Key2", 1002, "SeqId2"));
+ mgr.insert(new InvokerBean("Key3", 1003, "SeqId2"));
+
+ InvokerBean bean = new InvokerBean();
+ bean.setSequenceID("SeqId2");
+
+ Iterator iter = mgr.find(bean).iterator();
+ InvokerBean tmp = (InvokerBean) iter.next();
+
+ if (tmp.getMessageContextRefKey().equals("Key2")) {
+ tmp = (InvokerBean) iter.next();
+ assertTrue(tmp.getMessageContextRefKey().equals("Key3"));
+ } else {
+ tmp = (InvokerBean) iter.next();
+ assertTrue(tmp.getMessageContextRefKey().equals("Key2"));
+
+ }
+ }
+
+ public void testInsert() throws SandeshaStorageException {
+ mgr.insert(new InvokerBean("Key4", 1004, "SeqId4"));
+ InvokerBean tmp = mgr.retrieve("Key4");
+ assertTrue(tmp.getMessageContextRefKey().equals("Key4"));
+ }
+
+ public void testRetrieve() throws SandeshaStorageException {
+ assertNull(mgr.retrieve("Key5"));
+ mgr.insert(new InvokerBean("Key5", 1004, "SeqId5"));
+ assertNotNull(mgr.retrieve("Key5"));
+ }
+
+ public void testUpdate() throws SandeshaStorageException {
+ InvokerBean bean = new InvokerBean("Key6", 1006, "SeqId6");
+ mgr.insert(bean);
+ bean.setMsgNo(1007);
+ mgr.update(bean);
+ InvokerBean tmp = mgr.retrieve("Key6");
+ assertTrue(tmp.getMsgNo() == 1007);
+ }
+}
Added: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/AddressingVersionTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/AddressingVersionTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/AddressingVersionTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/AddressingVersionTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,171 @@
+package org.apache.sandesha2.versions;
+
+import java.io.File;
+
+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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+public class AddressingVersionTest extends SandeshaTestCase {
+
+
+ SimpleHTTPServer httpServer = null;
+ private final String applicationNamespaceName = "http://tempuri.org/";
+ private final String ping = "ping";
+ private final String Text = "Text";
+ int serverPort = DEFAULT_SERVER_TEST_PORT;
+ private Log log = LogFactory.getLog(getClass());
+
+ public AddressingVersionTest () {
+ super ("AddressingVersionTest");
+ }
+
+ 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 + "server_axis2.xml";
+
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+ String serverPortStr = getTestProperty("test.server.port");
+ if (serverPortStr!=null) {
+
+ try {
+ serverPort = Integer.parseInt(serverPortStr);
+ } catch (NumberFormatException e) {
+ log.error(e);
+ }
+ }
+
+ httpServer = new SimpleHTTPServer (configContext,serverPort);
+ 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:" + serverPort + "/axis2/services/RMSampleService";
+ String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_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(SandeshaClientConstants.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.setOptions(clientOptions);
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ Thread.sleep(15000);
+
+ SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ serviceClient.finalizeInvoke();
+ }
+
+ public void testAddressingSubmission () throws AxisFault,InterruptedException {
+
+ String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+ String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_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(SandeshaClientConstants.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.setOptions(clientOptions);
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ Thread.sleep(15000);
+
+ SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ serviceClient.finalizeInvoke();
+ }
+
+ 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/java/test/src/org/apache/sandesha2/versions/RMVersionTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/RMVersionTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/RMVersionTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/RMVersionTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,171 @@
+package org.apache.sandesha2.versions;
+
+import java.io.File;
+
+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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+public class RMVersionTest extends SandeshaTestCase {
+
+
+ SimpleHTTPServer httpServer = null;
+ private final String applicationNamespaceName = "http://tempuri.org/";
+ private final String ping = "ping";
+ private final String Text = "Text";
+ int serverPort = DEFAULT_SERVER_TEST_PORT;
+ private Log log = LogFactory.getLog(getClass());
+
+ public RMVersionTest () {
+ super ("RMVersionTest");
+ }
+
+ 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 + "server_axis2.xml";
+
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+ String serverPortStr = getTestProperty("test.server.port");
+ if (serverPortStr!=null) {
+
+ try {
+ serverPort = Integer.parseInt(serverPortStr);
+ } catch (NumberFormatException e) {
+ log.error(e);
+ }
+ }
+
+ httpServer = new SimpleHTTPServer (configContext,serverPort);
+ 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:" + serverPort + "/axis2/services/RMSampleService";
+ String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_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(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ //setting the addressing version as submission
+ clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_0);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ //serviceClient.
+
+ serviceClient.setOptions(clientOptions);
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ Thread.sleep(10000);
+
+ SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ serviceClient.finalizeInvoke();
+ }
+
+ public void testRMOASIS () throws AxisFault,InterruptedException {
+
+ String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+ String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_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(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ //setting the RM version as OASIS.
+ clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ //serviceClient.
+
+ serviceClient.setOptions(clientOptions);
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ Thread.sleep(10000);
+
+ SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ serviceClient.finalizeInvoke();
+ }
+
+ 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/java/test/src/org/apache/sandesha2/versions/SOAPVersionTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/SOAPVersionTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/SOAPVersionTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/versions/SOAPVersionTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,168 @@
+package org.apache.sandesha2.versions;
+
+import java.io.File;
+
+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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+public class SOAPVersionTest extends SandeshaTestCase {
+
+
+ SimpleHTTPServer httpServer = null;
+ private final String applicationNamespaceName = "http://tempuri.org/";
+ private final String ping = "ping";
+ private final String Text = "Text";
+ int serverPort = DEFAULT_SERVER_TEST_PORT;
+ private Log log = LogFactory.getLog(getClass());
+
+ public SOAPVersionTest () {
+ super ("SOAPVersionTest");
+ }
+
+ 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 + "server_axis2.xml";
+
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
+ String serverPortStr = getTestProperty("test.server.port");
+ if (serverPortStr!=null) {
+
+ try {
+ serverPort = Integer.parseInt(serverPortStr);
+ } catch (NumberFormatException e) {
+ log.error(e);
+ }
+ }
+
+ httpServer = new SimpleHTTPServer (configContext,serverPort);
+ 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:" + serverPort + "/axis2/services/RMSampleService";
+ String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_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(SandeshaClientConstants.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.setOptions(clientOptions);
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ Thread.sleep(10000);
+
+ SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ serviceClient.finalizeInvoke();
+ }
+
+ public void testSOAP12 () throws AxisFault,InterruptedException {
+
+ String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+ String transportTo = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
+
+ String repoPath = "target" + File.separator + "repos" + File.separator + "client";
+ String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_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(SandeshaClientConstants.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.setOptions(clientOptions);
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ Thread.sleep(10000);
+
+ SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+ assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+ assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+ serviceClient.finalizeInvoke();
+ }
+
+ 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/java/test/src/org/apache/sandesha2/wsrm/AckRequestedTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/wsrm/AckRequestedTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/wsrm/AckRequestedTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/wsrm/AckRequestedTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,27 @@
+package org.apache.sandesha2.wsrm;
+
+import junit.framework.TestCase;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+
+public class AckRequestedTest extends TestCase {
+
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ String rmNamespaceValue = Sandesha2Constants.SPEC_2005_02.NS_URI;
+ String addressingNamespaceValue = AddressingConstants.Final.WSA_NAMESPACE;
+
+ public AckRequestedTest() {
+// super("CreateSequenceResponseTest");
+
+ }
+
+ public void testFromOMElement() throws SandeshaException {
+
+ }
+
+ public void testToSOAPEnvelope() throws SandeshaException {}
+}
Added: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/wsrm/CloseSequenceResponseTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/wsrm/CloseSequenceResponseTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/wsrm/CloseSequenceResponseTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/wsrm/CloseSequenceResponseTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,27 @@
+package org.apache.sandesha2.wsrm;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+
+import junit.framework.TestCase;
+
+public class CloseSequenceResponseTest extends TestCase {
+
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ String rmNamespaceValue = Sandesha2Constants.SPEC_2005_02.NS_URI;
+ String addressingNamespaceValue = AddressingConstants.Final.WSA_NAMESPACE;
+
+ public CloseSequenceResponseTest() {
+// super("CreateSequenceResponseTest");
+
+ }
+
+ public void testFromOMElement() throws SandeshaException {
+
+ }
+
+ public void testToSOAPEnvelope() throws SandeshaException {}
+}
Added: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/wsrm/CloseSequenceTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/wsrm/CloseSequenceTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/wsrm/CloseSequenceTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/wsrm/CloseSequenceTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,27 @@
+package org.apache.sandesha2.wsrm;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+
+import junit.framework.TestCase;
+
+public class CloseSequenceTest extends TestCase {
+
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ String rmNamespaceValue = Sandesha2Constants.SPEC_2005_02.NS_URI;
+ String addressingNamespaceValue = AddressingConstants.Final.WSA_NAMESPACE;
+
+ public CloseSequenceTest() {
+// super("CreateSequenceResponseTest");
+
+ }
+
+ public void testFromOMElement() throws SandeshaException {
+
+ }
+
+ public void testToSOAPEnvelope() throws SandeshaException {}
+}
Added: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/wsrm/CreateSequenceResponseTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/wsrm/CreateSequenceResponseTest.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/wsrm/CreateSequenceResponseTest.java (added)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/wsrm/CreateSequenceResponseTest.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,73 @@
+package org.apache.sandesha2.wsrm;
+
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.SandeshaTestCase;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+
+import javax.xml.namespace.QName;
+
+public class CreateSequenceResponseTest extends SandeshaTestCase {
+
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ String rmNamespaceValue = Sandesha2Constants.SPEC_2005_02.NS_URI;
+ String addressingNamespaceValue = AddressingConstants.Final.WSA_NAMESPACE;
+
+ public CreateSequenceResponseTest() {
+ super("CreateSequenceResponseTest");
+
+ }
+
+ public void testFromOMElement() throws SandeshaException {
+ CreateSequenceResponse res = new CreateSequenceResponse(factory,rmNamespaceValue,addressingNamespaceValue);
+ SOAPEnvelope env = getSOAPEnvelope("", "CreateSequenceResponse.xml");
+ res.fromOMElement(env.getBody());
+
+ Identifier identifier = res.getIdentifier();
+ assertEquals("uuid:88754b00-161a-11da-b6d6-8198de3c47c5", identifier.getIdentifier());
+
+ Accept accept = res.getAccept();
+ AcksTo acksTo = accept.getAcksTo();
+ Address address = acksTo.getAddress();
+ assertEquals("http://localhost:8070/axis/services/TestService", address.getEpr().getAddress());
+
+ }
+
+ public void testToSOAPEnvelope() throws SandeshaException {
+ CreateSequenceResponse res = new CreateSequenceResponse(factory,rmNamespaceValue,addressingNamespaceValue);
+
+ Identifier identifier = new Identifier(factory,rmNamespaceValue);
+ identifier.setIndentifer("uuid:88754b00-161a-11da-b6d6-8198de3c47c5");
+ res.setIdentifier(identifier);
+
+ Accept accept = new Accept(factory,rmNamespaceValue,addressingNamespaceValue);
+ AcksTo acksTo = new AcksTo(factory,rmNamespaceValue,addressingNamespaceValue);
+ Address address = new Address(factory,addressingNamespaceValue);
+ address.setEpr(new EndpointReference("http://localhost:8070/axis/services/TestService"));
+ acksTo.setAddress(address);
+ accept.setAcksTo(acksTo);
+ res.setAccept(accept);
+
+ SOAPEnvelope env = getEmptySOAPEnvelope();
+ res.toSOAPEnvelope(env);
+
+ OMElement createSeqResponsePart = env.getBody().getFirstChildWithName(
+ new QName(rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.CREATE_SEQUENCE_RESPONSE));
+ OMElement identifierPart = createSeqResponsePart.getFirstChildWithName(
+ new QName(rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.IDENTIFIER));
+ assertEquals("uuid:88754b00-161a-11da-b6d6-8198de3c47c5", identifierPart.getText());
+
+ OMElement acceptPart = createSeqResponsePart.getFirstChildWithName(
+ new QName(rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.ACCEPT));
+ OMElement acksToPart = acceptPart.getFirstChildWithName(
+ new QName(rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.ACKS_TO));
+ OMElement addressPart = acksToPart.getFirstChildWithName(new QName(
+ addressingNamespaceValue, Sandesha2Constants.WSA.ADDRESS));
+ assertEquals("http://localhost:8070/axis/services/TestService", addressPart.getText());
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org