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 2007/04/23 11:55:16 UTC

svn commit: r531400 [14/18] - in /webservices/sandesha/trunk/java/modules: client/ core/ core/src/ core/src/main/ core/src/main/java/ core/src/main/java/org/ core/src/main/java/org/apache/ core/src/main/java/org/apache/sandesha2/ core/src/main/java/org...

Added: webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/AsyncPingClient.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/AsyncPingClient.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/AsyncPingClient.java (added)
+++ webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/AsyncPingClient.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,135 @@
+/*
+ * 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 sandesha2.samples.userguide;
+
+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.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.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+
+public class AsyncPingClient {
+
+	private static final String applicationNamespaceName = "http://tempuri.org/"; 
+	private static final String ping = "ping";
+	private static final String Text = "Text";
+	
+	private String toIP = "127.0.0.1";
+	
+	private String toPort = "8070";
+	
+	private String toEPR = "http://" + toIP +  ":" + toPort + "/axis2/services/RMSampleService";
+	
+	private static String SANDESHA2_HOME = "<SANDESHA2_HOME>"; //Change this to ur path.
+	
+	private static String AXIS2_CLIENT_PATH = SANDESHA2_HOME + File.separator + "target" + File.separator +"repos" + File.separator + "client" + File.separator;   //this will be available after a maven build
+	
+	public static void main(String[] args) throws AxisFault {
+		
+		String axisClientRepo = null;
+		if (args!=null && args.length>0)
+			axisClientRepo = args[0];
+		
+		if (axisClientRepo!=null && !"".equals(axisClientRepo)) {
+			AXIS2_CLIENT_PATH = axisClientRepo;
+			SANDESHA2_HOME = "";
+		}
+		
+		new AsyncPingClient().run();
+	}
+	
+	private void run () throws AxisFault {
+		if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
+			System.out.println("ERROR: Please change <SANDESHA2_HOME> to your Sandesha2 installation directory.");
+			return;
+		}
+		
+		String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
+		ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
+
+		ServiceClient serviceClient = new ServiceClient (configContext,null);
+//		serviceClient.engageModule(new QName ("sandesha2"));
+		
+		Options clientOptions = new Options ();
+		
+//		clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);   //uncomment this to send messages without chunking.
+//		clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);   //uncomment this to send messages in SOAP 1.2
+//		clientOptions.setProperty(SandeshaClient.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.
+		
+		clientOptions.setTo(new EndpointReference (toEPR));
+		
+		EndpointReference endpoint = 	serviceClient.getMyEPR(Constants.TRANSPORT_HTTP);
+		clientOptions.setProperty(SandeshaClientConstants.AcksTo,endpoint.getAddress());
+		
+		clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+		clientOptions.setAction("urn:wsrm:Ping");
+		
+		String sequenceKey = "sequence2";
+		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+		
+		serviceClient.setOptions(clientOptions);
+		
+		serviceClient.fireAndForget(getPingOMBlock("ping1"));
+		serviceClient.fireAndForget(getPingOMBlock("ping2"));
+		
+		clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+		serviceClient.fireAndForget(getPingOMBlock("ping3"));
+		
+		boolean complete = false;
+		while (!complete) {
+			SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+			if (sequenceReport!=null && sequenceReport .getCompletedMessages().size()==3)
+				complete = true;
+			else {
+				try {
+					Thread.sleep(1000);
+				} catch (InterruptedException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+		
+		serviceClient.cleanup();
+	}
+	
+	private static 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/modules/samples/src/sandesha2/samples/userguide/MTOMPingClient.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/MTOMPingClient.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/MTOMPingClient.java (added)
+++ webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/MTOMPingClient.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,149 @@
+/*
+ * 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 sandesha2.samples.userguide;
+
+import java.io.File;
+
+import javax.activation.DataHandler;
+import javax.activation.FileDataSource;
+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.om.OMText;
+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.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SandeshaListener;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.util.SandeshaUtil;
+
+public class MTOMPingClient {
+
+	private static final String applicationNamespaceName = "http://tempuri.org/"; 
+	private static final String MTOMPing = "MTOMPing";
+	private static final String Text = "Text";
+	
+	private String toIP = "127.0.0.1";
+	
+	private String toPort = "8080";
+	private String transportToPort = "8070";
+	
+	private String toEPR = "http://" + toIP +  ":" + toPort + "/axis2/services/RMSampleService";
+	private String transportToEPR = "http://" + toIP +  ":" + transportToPort + "/axis2/services/RMSampleService";
+	
+	private static String SANDESHA2_HOME = "<SANDESHA2_HOME>"; //Change this to ur path.
+	
+	private static String AXIS2_CLIENT_PATH = SANDESHA2_HOME + File.separator + "target" + File.separator +"repos" + File.separator + "client" + File.separator;   //this will be available after a maven build
+	
+	public static void main(String[] args) throws AxisFault {
+		
+		String axisClientRepo = null;
+		if (args!=null && args.length>0)
+			axisClientRepo = args[0];
+		
+		if (axisClientRepo!=null && !"".equals(axisClientRepo)) {
+			AXIS2_CLIENT_PATH = axisClientRepo;
+			SANDESHA2_HOME = "";
+		}
+
+		new MTOMPingClient ().run();
+	}
+	
+	private void run () throws AxisFault {
+		
+		if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
+			System.out.println("ERROR: Please change <SANDESHA2_HOME> to your Sandesha2 installation directory.");
+			return;
+		}
+		
+		String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
+		ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
+		
+		Options clientOptions = new Options ();	
+		clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
+		clientOptions.setTo(new EndpointReference (toEPR));
+		
+		String sequenceKey = SandeshaUtil.getUUID();// "sequence2";
+		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+	    
+//		clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);   //uncomment this to send messages without chunking.
+		clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);   //uncomment this to send messages in SOAP 1.2
+//		clientOptions.setProperty(SandeshaClient.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.
+//		clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
+		
+		clientOptions.setProperty(SandeshaClientConstants.SANDESHA_LISTENER, new SandeshaListenerImpl ());
+		ServiceClient serviceClient = new ServiceClient (configContext,null);
+		serviceClient.engageModule(new QName ("sandesha2"));
+		
+		clientOptions.setAction("urn:wsrm:Ping");
+		serviceClient.setOptions(clientOptions);
+		
+		clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+
+		serviceClient.fireAndForget(getPingOMBlock());
+		SandeshaClient.waitUntilSequenceCompleted(serviceClient);
+		
+		serviceClient.cleanup();
+	}
+	
+	private static OMElement getPingOMBlock() throws AxisFault {
+		OMFactory fac = OMAbstractFactory.getOMFactory();
+		OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+		OMElement pingElem = fac.createOMElement(MTOMPing, namespace);
+		OMElement attachmentElem = fac.createOMElement("Attachment", namespace);
+		
+	    String imageName = "test-resources" + File.separator + "mtom-image.jpg";
+	    FileDataSource dataSource;
+		try {
+			dataSource = new FileDataSource (new File (imageName));
+		} catch (Exception e) {
+			throw AxisFault.makeFault (e);
+		}
+		
+	    DataHandler dataHandler = new DataHandler(dataSource);
+
+	    OMText textData = fac.createOMText(dataHandler, true);
+	    attachmentElem.addChild(textData);
+		
+		pingElem.addChild(attachmentElem);
+
+		return pingElem;
+	}
+	
+	private class SandeshaListenerImpl implements SandeshaListener {
+
+		public void onError(AxisFault fault) {
+			System.out.println("*********** RM fault callbak called");
+		}
+
+		public void onTimeOut(SequenceReport report) {
+			System.out.println("Sequence timed out");
+		} 	
+	}
+	
+}
+

Added: webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/RMSampleService.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/RMSampleService.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/RMSampleService.java (added)
+++ webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/RMSampleService.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,119 @@
+/*
+ * 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 sandesha2.samples.userguide;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.activation.DataHandler;
+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.om.OMText;
+import org.apache.axis2.AxisFault;
+
+public class RMSampleService {
+
+	private static Map sequenceStrings = new HashMap();  //TODO make this non static
+	private final String applicationNamespaceName = "http://tempuri.org/"; 
+	private final String Text = "Text";
+	private final String Sequence = "Sequence";
+	private final String echoStringResponse = "echoStringResponse";
+	private final String EchoStringReturn = "EchoStringReturn";
+	private final String Attachment = "Attachment";
+	private final String DESTINATION_IMAGE_FILE = "mtom-image1.jpg";
+
+  public void init(org.apache.axis2.context.ServiceContext serviceContext) {
+
+  }
+
+	public OMElement echoString(OMElement in) throws Exception {
+		
+		OMElement textElem = in.getFirstChildWithName(new QName (applicationNamespaceName,Text));
+		OMElement sequenceElem = in.getFirstChildWithName(new QName (applicationNamespaceName,Sequence));
+		
+		if (textElem==null)
+			throw new Exception ("'Text' element is not present as a child of the 'echoString' element");
+		if (sequenceElem==null)
+			throw new Exception ("'Sequence' element is not present as a child of the 'echoString' element");
+		
+		String textStr = textElem.getText();
+		String sequenceStr = sequenceElem.getText();
+		
+		System.out.println("'EchoString' service got text '" + textStr + "' for the sequence '" + sequenceStr + "'");
+		
+		String previousText = (String) sequenceStrings.get(sequenceStr);
+		String resultText = (previousText==null)?textStr:previousText+textStr;
+		sequenceStrings.put(sequenceStr,resultText);
+		
+		OMFactory fac = OMAbstractFactory.getOMFactory();
+		OMNamespace applicationNamespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+		OMElement echoStringResponseElem = fac.createOMElement(echoStringResponse, applicationNamespace);
+		OMElement echoStringReturnElem = fac.createOMElement(EchoStringReturn, applicationNamespace);
+		
+		echoStringReturnElem.setText(resultText);
+		echoStringResponseElem.addChild(echoStringReturnElem);
+		
+		return echoStringResponseElem;
+	}
+  
+	public void ping(OMElement in) throws Exception  {
+		OMElement textElem = in.getFirstChildWithName(new QName (applicationNamespaceName,Text));
+		if (textElem==null)
+			throw new Exception ("'Text' element is not present as a child of the 'Ping' element");
+		
+		String textValue = textElem.getText();
+		
+		System.out.println("ping service got text:" + textValue);
+	}
+	
+	public void MTOMPing(OMElement in) throws Exception  {
+		OMElement attachmentElem = in.getFirstChildWithName(new QName(applicationNamespaceName, Attachment));
+		if (attachmentElem == null)
+			throw new AxisFault("'Attachment' element is not present as a child of the 'Ping' element");
+
+		OMText binaryElem = (OMText) attachmentElem.getFirstOMChild();
+
+		binaryElem.setOptimize(true);
+		DataHandler dataHandler = (DataHandler) binaryElem.getDataHandler();
+
+		try {
+			
+			File destinationFile = new File(DESTINATION_IMAGE_FILE);
+			if (destinationFile.exists())
+				destinationFile.delete();
+
+			FileOutputStream fileOutputStream = new FileOutputStream(DESTINATION_IMAGE_FILE);
+
+			InputStream inputStream = dataHandler.getDataSource().getInputStream();
+			byte[] bytes = new byte[5000];
+			int length = inputStream.read(bytes);
+			fileOutputStream.write(bytes, 0, length);
+			fileOutputStream.close();
+
+		} catch (Exception e) {
+			throw AxisFault.makeFault(e);
+		}
+	}
+}

Added: webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/SyncEchoClient.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/SyncEchoClient.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/SyncEchoClient.java (added)
+++ webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/SyncEchoClient.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,176 @@
+/*
+ * 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 sandesha2.samples.userguide;
+
+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.SOAPBody;
+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.sandesha2.client.SandeshaClientConstants;
+
+
+public class SyncEchoClient {
+
+	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 String toIP = "127.0.0.1";
+	
+	private String toPort = "8070";
+	
+	private String toEPR = "http://" + toIP +  ":" + toPort + "/axis2/services/RMSampleService";
+
+	private static String SANDESHA2_HOME = "<SANDESHA2_HOME>"; //Change this to ur path.
+	
+	private static String AXIS2_CLIENT_PATH = SANDESHA2_HOME + File.separator + "target" + File.separator +"repos" + File.separator + "client" + File.separator;   //this will be available after a maven build
+	
+	public static void main(String[] args) throws Exception {
+		
+		String axisClientRepo = null;
+		if (args!=null && args.length>0)
+			axisClientRepo = args[0];
+		
+		if (axisClientRepo!=null && !"".equals(axisClientRepo)) {
+			AXIS2_CLIENT_PATH = axisClientRepo;
+			SANDESHA2_HOME = "";
+		}
+		
+		new SyncEchoClient().run();
+	}
+	
+	private void run () throws Exception {
+		if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
+			System.out.println("ERROR: Please change <SANDESHA2_HOME> to your Sandesha2 installation directory.");
+			return;
+		}
+		
+		String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
+		ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
+
+		ServiceClient serviceClient = new ServiceClient (configContext,null);
+		
+//		serviceClient.engageModule(new QName ("sandesha2"));
+		
+		Options clientOptions = new Options ();
+		
+		clientOptions.setTo(new EndpointReference (toEPR));
+		
+		String sequenceKey = "sequence3";
+		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+		//You must set the following two properties in the request-reply case.
+		clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+		clientOptions.setUseSeparateListener(true);
+		clientOptions.setAction("urn:wsrm:EchoString");
+		
+//		clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);   //uncomment this to send messages without chunking.
+//		clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);   //uncomment this to send messages in SOAP 1.2
+//		clientOptions.setProperty(SandeshaClient.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.
+//		clientOptions.setProperty(SandeshaClient.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID());  //Uncomment this to offer a sequenceID for the incoming sequence.
+		
+		serviceClient.setOptions(clientOptions);
+		
+		Callback callback1 = new TestCallback ("Callback 1");
+		serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo1",sequenceKey),callback1);
+		
+		clientOptions.setAction("urn:wsrm:EchoString");
+		Callback callback2 = new TestCallback ("Callback 2");
+		serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo2",sequenceKey),callback2);
+		
+		clientOptions.setAction("urn:wsrm:EchoString");
+		
+		clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+		Callback callback3 = new TestCallback ("Callback 3");
+		serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo3",sequenceKey),callback3);
+		
+        while (!callback3.isComplete()) {
+            Thread.sleep(1000);
+        }
+	}
+
+	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;
+	}
+
+	private class TestCallback extends Callback {
+
+		String name = null;
+		
+		public TestCallback (String name) {
+			this.name = name;
+		}
+		
+		public String toString () {
+			return 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();
+			System.out.println("Callback '" + name +  "' got result:" + resultStr);
+			
+		}
+
+		public void onError(Exception e) {
+			// TODO Auto-generated method stub
+			System.out.println("Error reported for test call back");
+		}
+	}
+	
+}

Added: webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/SyncPingClient.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/SyncPingClient.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/SyncPingClient.java (added)
+++ webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/SyncPingClient.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,154 @@
+/*
+ * 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 sandesha2.samples.userguide;
+
+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.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.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SandeshaListener;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.util.SandeshaUtil;
+
+
+public class SyncPingClient {
+
+	private static final String applicationNamespaceName = "http://tempuri.org/"; 
+	private static final String ping = "ping";
+	private static final String Text = "Text";
+	
+	private String toIP = "127.0.0.1";
+	
+	private String toPort = "8080";
+	private String transportToPort = "8070";
+	
+	private String toEPR = "http://" + toIP +  ":" + toPort + "/axis2/services/RMSampleService";
+	private String transportToEPR = "http://" + toIP +  ":" + transportToPort + "/axis2/services/RMSampleService";
+	
+	private static String SANDESHA2_HOME = "<SANDESHA2_HOME>"; //Change this to ur path.
+	
+	private static String AXIS2_CLIENT_PATH = SANDESHA2_HOME + File.separator + "target" + File.separator +"repos" + File.separator + "client" + File.separator;   //this will be available after a maven build
+	
+	public static void main(String[] args) throws AxisFault {
+		
+		String axisClientRepo = null;
+		if (args!=null && args.length>0)
+			axisClientRepo = args[0];
+		
+		if (axisClientRepo!=null && !"".equals(axisClientRepo)) {
+			AXIS2_CLIENT_PATH = axisClientRepo;
+			SANDESHA2_HOME = "";
+		}
+
+		
+		new SyncPingClient ().run();
+	}
+	
+	private void run () throws AxisFault {
+		
+		if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
+			System.out.println("ERROR: Please change <SANDESHA2_HOME> to your Sandesha2 installation directory.");
+			return;
+		}
+		
+		String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
+		ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
+		
+		Options clientOptions = new Options ();	
+		clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
+		clientOptions.setTo(new EndpointReference (toEPR));
+		
+		String sequenceKey = SandeshaUtil.getUUID();// "sequence2";
+		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+	    
+//		clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);   //uncomment this to send messages without chunking.
+		
+//		clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);   //uncomment this to send messages in SOAP 1.2
+		
+//		clientOptions.setProperty(SandeshaClient.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.
+		
+//		clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
+		
+		clientOptions.setProperty(SandeshaClientConstants.SANDESHA_LISTENER, new SandeshaListenerImpl ());
+		ServiceClient serviceClient = new ServiceClient (configContext,null);
+//		serviceClient.engageModule(new QName ("sandesha2"));
+		
+		clientOptions.setAction("urn:wsrm:Ping");
+		serviceClient.setOptions(clientOptions);
+		
+		serviceClient.fireAndForget(getPingOMBlock("ping1"));
+		serviceClient.fireAndForget(getPingOMBlock("ping2"));
+		
+		clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+
+		serviceClient.fireAndForget(getPingOMBlock("ping3"));
+		
+		SequenceReport sequenceReport = null;
+			
+		boolean complete = false;
+		while (!complete) {
+			sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+			if (sequenceReport!=null && sequenceReport.getCompletedMessages().size()==3)
+				complete = true;
+			else {
+				try {
+					Thread.sleep(1000);
+				} catch (InterruptedException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+		
+		serviceClient.cleanup();
+	}
+	
+	private static 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;
+	}
+	
+	private class SandeshaListenerImpl implements SandeshaListener {
+
+		public void onError(AxisFault fault) {
+			System.out.println("*********** RM fault callbak called");
+		}
+
+		public void onTimeOut(SequenceReport report) {
+			System.out.println("Sequence timed out");
+		} 	
+	}
+	
+}

Added: webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/UserguideEchoClient.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/UserguideEchoClient.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/UserguideEchoClient.java (added)
+++ webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/UserguideEchoClient.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,113 @@
+/*
+ * 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 sandesha2.samples.userguide;
+
+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.SOAPBody;
+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.sandesha2.client.SandeshaClientConstants;
+
+public class UserguideEchoClient {
+	
+	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 static String toEPR = "http://127.0.0.1:8070/axis2/services/RMSampleService";
+
+	private static String CLIENT_REPO_PATH = "Full path to the Client Repo folder";
+	
+	public static void main(String[] args) throws Exception {
+		
+		String axis2_xml = CLIENT_REPO_PATH + File.separator +"client_axis2.xml";
+        ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(CLIENT_REPO_PATH,axis2_xml);
+		ServiceClient serviceClient = new ServiceClient (configContext,null);	
+		
+		Options clientOptions = new Options ();
+		clientOptions.setTo(new EndpointReference (toEPR));
+		clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+		clientOptions.setUseSeparateListener(true);
+		serviceClient.setOptions(clientOptions);
+
+		Callback callback1 = new TestCallback ("Callback 1");
+		serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo1","sequence1"),callback1);
+		Callback callback2 = new TestCallback ("Callback 2");
+		serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo2","sequence1"),callback2);
+
+		clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+		Callback callback3 = new TestCallback ("Callback 3");
+		serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo3","sequence1"),callback3);
+		
+        while (!callback3.isComplete()) {
+            Thread.sleep(1000);
+        }
+        
+        Thread.sleep(4000); 
+	}
+
+	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;
+	}
+
+	static class TestCallback extends Callback {
+
+		String name = null;
+		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));			
+			OMElement echoStringReturnElem = echoStringResponseElem.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn));
+			
+			String resultStr = echoStringReturnElem.getText();
+			System.out.println("Callback '" + name +  "' got result:" + resultStr);
+		}
+
+		public void onError (Exception e) {
+			System.out.println("Error reported for test call back");
+			e.printStackTrace();
+		}
+	}
+}

Added: webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/UserguidePingClient.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/UserguidePingClient.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/UserguidePingClient.java (added)
+++ webservices/sandesha/trunk/java/modules/samples/src/sandesha2/samples/userguide/UserguidePingClient.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,75 @@
+/*
+ * 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 sandesha2.samples.userguide;
+
+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.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.sandesha2.client.SandeshaClientConstants;
+
+
+public class UserguidePingClient {
+
+	private static final String applicationNamespaceName = "http://tempuri.org/"; 
+	private static final String ping = "ping";
+	private static final String Text = "Text";
+	private static String toEPR = "http://127.0.0.1:8070/axis2/services/RMSampleService";
+
+	private static String CLIENT_REPO_PATH = "Full path to the Client Repo folder";
+	
+	public static void main(String[] args) throws AxisFault {
+		
+		String axis2_xml = CLIENT_REPO_PATH + File.separator + "client_axis2.xml";
+		ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(CLIENT_REPO_PATH,axis2_xml);
+		
+		Options clientOptions = new Options ();
+		clientOptions.setTo(new EndpointReference (toEPR));
+
+		ServiceClient serviceClient = new ServiceClient (configContext,null);
+		clientOptions.setAction("urn:wsrm:Ping");
+		serviceClient.setOptions(clientOptions);
+		
+		serviceClient.fireAndForget(getPingOMBlock("ping1"));
+		serviceClient.fireAndForget(getPingOMBlock("ping2"));
+		
+		clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+		serviceClient.fireAndForget(getPingOMBlock("ping3"));
+		
+		serviceClient.cleanup();
+	}
+	
+	private static 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/modules/tests/src/org/apache/sandesha2/MessageContextPropertyTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/MessageContextPropertyTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/MessageContextPropertyTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/MessageContextPropertyTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,167 @@
+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.MessageContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisOperationFactory;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+public class MessageContextPropertyTest extends SandeshaTestCase {
+
+	private final String TEST_OPERATION_NAME = "testOperation";
+	private final String applicationNamespaceName = "http://tempuri.org/"; 
+	private final String Text = "Text";
+	
+	public MessageContextPropertyTest() {
+		super("MessageContextPropertyTest");
+	}
+
+	public void setUp() throws Exception {
+		super.setUp();
+
+		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);
+
+		AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();
+		AxisService axisService = axisConfiguration.getService("RMSampleService");
+		AxisOperation operation = AxisOperationFactory.getAxisOperation(WSDLConstants.MEP_CONSTANT_IN_ONLY);
+		operation.setMessageReceiver(new TestMessageReceiver());
+		operation.setName(new QName(TEST_OPERATION_NAME));
+		axisService.addOperation(operation);
+
+		AxisOperation pingOperation = axisService.getOperation(new QName("ping"));
+		if (pingOperation == null)
+			throw new AxisFault("Cant find the ping operation");
+
+		// setting the operation specific phase chain
+		operation.setRemainingPhasesInFlow(pingOperation.getRemainingPhasesInFlow());
+
+		httpServer = new SimpleHTTPServer(configContext, serverPort);
+		httpServer.start();
+		try {
+			Thread.sleep(300);
+		} catch (InterruptedException e) {
+			throw new SandeshaException("sleep interupted");
+		}
+	}
+
+	public void testParameters () throws AxisFault,InterruptedException  {
+		
+		String to = "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.setAction(pingAction);
+		clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+		
+		clientOptions.setTo(new EndpointReference (to));
+		
+		String sequenceKey = "sequence1";
+		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+		
+		ServiceClient serviceClient = new ServiceClient (configContext,null);
+		//serviceClient.
+
+		serviceClient.setOptions(clientOptions);
+		
+		serviceClient.fireAndForget(getTestOperationOMBlock("ping1"));
+		
+		clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+		serviceClient.fireAndForget(getTestOperationOMBlock("ping2"));
+		
+		long limit = System.currentTimeMillis() + waitTime;
+		Error lastError = null;
+		while(System.currentTimeMillis() < limit) {
+			Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
+			
+			try {
+				SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+				assertTrue(sequenceReport.getCompletedMessages().contains(new Long(2)));
+				assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
+				assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+				
+				lastError = null;
+				break;
+			} catch(Error e) {
+				lastError = e;
+			}
+		}
+		if(lastError != null) throw lastError;
+
+		configContext.getListenerManager().stop();
+		serviceClient.cleanup();
+	}
+	
+	private OMElement getTestOperationOMBlock(String text) {
+		OMFactory fac = OMAbstractFactory.getOMFactory();
+		OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+		OMElement pingElem = fac.createOMElement(TEST_OPERATION_NAME, namespace);
+		OMElement textElem = fac.createOMElement(Text, namespace);
+		
+		textElem.setText(text);
+		pingElem.addChild(textElem);
+
+		return pingElem;
+	}
+
+
+
+	private class TestMessageReceiver extends RawXMLINOnlyMessageReceiver {
+
+		Long lastReceivedMessage = null;
+		String sequenceId = null;
+		
+		public void invokeBusinessLogic(MessageContext msgContext) {
+			Long msgNo = (Long) msgContext.getProperty(Sandesha2Constants.MessageContextProperties.MESSAGE_NUMBER);
+			String sequenceId = (String) msgContext.getProperty(Sandesha2Constants.MessageContextProperties.SEQUENCE_ID);
+			
+			assertNotNull(msgNo);
+			assertNotNull(sequenceId);
+			
+			if (lastReceivedMessage==null)
+				assertEquals(msgNo,new Long (1));
+			else 
+				assertEquals(msgNo, new Long (2));
+			
+			if (this.sequenceId!=null)
+				assertEquals(this.sequenceId,sequenceId);
+			
+			this.sequenceId = sequenceId;
+			lastReceivedMessage = msgNo;
+		}
+
+	}
+
+
+
+}

Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/MessageRetransmissionTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/MessageRetransmissionTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/MessageRetransmissionTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/MessageRetransmissionTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,95 @@
+/*
+ * 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;
+
+import java.io.File;
+
+import org.apache.axiom.soap.SOAP11Constants;
+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.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+public class MessageRetransmissionTest extends SandeshaTestCase {
+
+	private static final String server_repoPath = "target" + File.separator + "repos" + File.separator + "server";
+	private static final String server_axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "server_axis2.xml";
+	
+	public MessageRetransmissionTest () {
+		super ("MessageRetransmissionTest");
+	}
+	
+	public void testMessageRetransmission () throws Exception  {
+		
+		String to = "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.setAction(pingAction);
+		clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+		
+		clientOptions.setTo(new EndpointReference (to));
+		
+		String sequenceKey = "sequence1";
+		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+		
+		ServiceClient serviceClient = new ServiceClient (configContext,null);
+		//serviceClient.
+		
+		serviceClient.setOptions(clientOptions);
+		serviceClient.fireAndForget(getPingOMBlock("ping1"));
+//		serviceClient.fireAndForget(getPingOMBlock("ping2"));
+		
+		//starting the server after a wait
+		Thread.sleep(3000);
+		startServer(server_repoPath, server_axis2_xml);
+
+		serviceClient.fireAndForget(getPingOMBlock("ping2"));
+		
+		long limit = System.currentTimeMillis() + waitTime;
+		Error lastError = null;
+		while(System.currentTimeMillis() < limit) {
+			Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
+			
+			try {
+				SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+				assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+				assertTrue(sequenceReport.getCompletedMessages().contains(new Long(2)));
+				assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+				lastError = null;
+				break;
+			} catch(Error e) {
+				lastError = e;
+			}
+		}
+		if(lastError != null) throw lastError;
+		
+		configContext.getListenerManager().stop();
+		serviceClient.cleanup();
+	}
+	
+}

Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/PropertyLoaderTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/PropertyLoaderTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/PropertyLoaderTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/PropertyLoaderTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,84 @@
+/*
+ * 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;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.sandesha2.policy.SandeshaPolicyBean;
+import org.apache.sandesha2.util.PropertyManager;
+
+public class PropertyLoaderTest extends TestCase {
+	
+	SandeshaPolicyBean propertyBean = null;
+	
+	public void setUp () {
+		String fileName = "./test-resources/sandesha2.properties";
+		File file= new File (fileName);
+		if (!file.exists()) {
+			fail("'test-resources/sandesha2.properties' not found");
+		}
+		
+		try {
+			InputStream in = new FileInputStream (file);
+			propertyBean = PropertyManager.loadPropertiesFromPropertyFile(in);
+			in.close();
+		} catch (Exception e) {
+			fail (e.getMessage());
+		}
+		
+	}
+	
+	public void testRetransmissionInterval () throws SandeshaException {
+		long value = propertyBean.getRetransmissionInterval();
+		assertEquals(value,20000);
+	}
+	
+	public void testExponentialBackOff () throws SandeshaException {
+		boolean value = propertyBean.isExponentialBackoff();
+		assertEquals(value,false);
+	}
+	
+	public void testAcknowledgementInterval () throws SandeshaException {
+		long value = propertyBean.getAcknowledgementInterval();
+		assertEquals(value,8000);
+	}
+	
+	public void testInactivityTImeout () {
+		long value = propertyBean.getInactivityTimeoutInterval();
+		assertEquals(value,(60*60*3*1000));
+	}
+	
+	public void testStorageManager () {
+		String storageMgr = propertyBean.getInMemoryStorageManagerClass();
+		assertEquals(storageMgr,"org.apache.sandesha2.storage.inmemory.InMemoryStorageManager1");
+	}
+
+	public void testSecurityManager() {
+		String secMgr = propertyBean.getSecurityManagerClass();
+		assertEquals(secMgr,"org.apache.sandesha2.security.SecurityManager1");
+	}
+	
+	public void testSequenceRemovalTimeout() {
+		long value = propertyBean.getSequenceRemovalTimeoutInterval();
+		assertEquals((60*60*1*1000), value);
+	}
+	
+}

Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/SandeshaClientAckRequestWaitTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/SandeshaClientAckRequestWaitTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/SandeshaClientAckRequestWaitTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/SandeshaClientAckRequestWaitTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,126 @@
+/*
+ * 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;
+
+import java.io.File;
+
+import org.apache.axiom.soap.SOAP11Constants;
+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.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+public class SandeshaClientAckRequestWaitTest extends SandeshaTestCase {
+
+	String server_repoPath = "target" + File.separator + "repos" + File.separator + "server";
+	String server_axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "server_axis2.xml";
+
+	public SandeshaClientAckRequestWaitTest () {
+		super ("SandeshaClientTest");
+	}
+
+	public void setUp () throws Exception {
+	}
+
+    /**
+		 * Checks the following scenario
+		 * 
+		 * Don't start the server
+		 * 1) send an application message (will generate the create sequence)
+		 * 2) Send ACK Request (should not be rejected)
+		 * 3) start the server
+		 * 4) wait a bit then terminate sequence
+		 * 5) Issue wait until sequence completed (with a wait time)
+		 * 6) Ensure that the sequence was terminated
+		 * 
+		 */
+		public void testAckRequestWithWait () throws Exception {
+			String to = "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.setProperty(SandeshaClientConstants.RM_SPEC_VERSION, 
+		       Sandesha2Constants.SPEC_VERSIONS.v1_1);
+			clientOptions.setTo(new EndpointReference (to));
+			
+			ServiceClient serviceClient = new ServiceClient (configContext,null);
+			clientOptions.setAction(pingAction);
+			
+			String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
+			clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
+			clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+				//serviceClient.
+			serviceClient.setOptions(clientOptions);
+				
+			try{
+				// 1) Send the application message
+				serviceClient.fireAndForget(getPingOMBlock("ping1"));
+				
+				// 2) Send Ack request for the sequence
+				SandeshaClient.sendAckRequest(serviceClient);
+								
+				// 3) Start the server			
+				startServer(server_repoPath, server_axis2_xml);
+
+				// 4) Wait a bit then terminate
+				long limit = System.currentTimeMillis() + waitTime;
+				Error lastError = null;
+				while(System.currentTimeMillis() < limit) {
+					Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
+					
+					try {
+						//now check the sequence is running
+						SequenceReport report = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+						assertEquals(report.getSequenceStatus(), SequenceReport.SEQUENCE_STATUS_ESTABLISHED);
+
+						lastError = null;
+						break;
+					} catch(Error e) {
+						lastError = e;
+					}
+				}
+				if(lastError != null) throw lastError;
+				
+				SandeshaClient.terminateSequence(serviceClient);
+				
+				// 5) wait for the sequence completion (30 second wait)
+				SandeshaClient.waitUntilSequenceCompleted(serviceClient, 30000);
+				
+				// 6) Check that the sequence has terminated
+				SequenceReport report = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+				assertNotNull(report);
+				assertEquals(SequenceReport.SEQUENCE_STATUS_TERMINATED, report.getSequenceStatus());
+
+			}
+			finally {
+				configContext.getListenerManager().stop();
+				serviceClient.cleanup();			
+			}
+			
+		}
+	
+}

Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/SandeshaClientCloseWaitTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/SandeshaClientCloseWaitTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/SandeshaClientCloseWaitTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/SandeshaClientCloseWaitTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,131 @@
+/*
+ * 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;
+
+import java.io.File;
+
+import org.apache.axiom.soap.SOAP11Constants;
+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.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+public class SandeshaClientCloseWaitTest extends SandeshaTestCase {
+
+	String server_repoPath = "target" + File.separator + "repos" + File.separator + "server";
+	String server_axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "server_axis2.xml";
+
+	public SandeshaClientCloseWaitTest () {
+		super ("SandeshaClientTest");
+	}
+
+		/**
+		 * Checks the following scenario
+		 * 
+		 * Don't start the server
+		 * 1) send an application message (will generate the create sequence)
+		 * 2) close the sequence
+		 * 3) send another application message (this should fail)
+		 * 4) start the server
+		 * 5) wait a bit then terminate sequence
+		 * 6) Issue wait until sequence completed (with a wait time)
+		 * 7) Ensure that the sequence was terminated
+		 * 
+		 */
+		public void testCloseSequenceWithWait () throws Exception {
+			String to = "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.setAction(pingAction);
+			clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+		   clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION, 
+		       Sandesha2Constants.SPEC_VERSIONS.v1_1);
+			clientOptions.setTo(new EndpointReference (to));
+			
+			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);
+				
+			try{
+				// 1) Send the application message
+				serviceClient.fireAndForget(getPingOMBlock("ping1"));
+				
+				// 2) Close the sequence
+				SandeshaClient.closeSequence(serviceClient);
+				
+				// 3) Send the second application message (this should fail)
+				try{
+					serviceClient.fireAndForget(getPingOMBlock("ping2"));
+					fail(); //this should have failed
+				}
+				catch(Exception e){
+					//good
+				}
+				
+				// 4) Start the server			
+				startServer(server_repoPath, server_axis2_xml);
+
+				// 5) Wait a bit then terminate
+				long limit = System.currentTimeMillis() + waitTime;
+				Error lastError = null;
+				while(System.currentTimeMillis() < limit) {
+					Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
+					
+					try {
+						//now check the sequence is running
+						SequenceReport report = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+						assertEquals(report.getSequenceStatus(), SequenceReport.SEQUENCE_STATUS_ESTABLISHED);
+
+						lastError = null;
+						break;
+					} catch(Error e) {
+						lastError = e;
+					}
+				}
+				if(lastError != null) throw lastError;
+				SandeshaClient.terminateSequence(serviceClient);
+				
+				// 6) wait for the sequence completion (30 second wait)
+				SandeshaClient.waitUntilSequenceCompleted(serviceClient, 30000);
+				
+				// 7) Check that the sequence has terminated
+				SequenceReport report = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+				assertNotNull(report);
+				assertEquals(SequenceReport.SEQUENCE_STATUS_TERMINATED, report.getSequenceStatus());
+
+			}
+			finally {
+				configContext.getListenerManager().stop();
+				serviceClient.cleanup();			
+			}
+			
+		}
+}

Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/SandeshaClientLastErrorTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/SandeshaClientLastErrorTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/SandeshaClientLastErrorTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/SandeshaClientLastErrorTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,123 @@
+/*
+ * 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;
+
+import java.io.File;
+
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axis2.Constants.Configuration;
+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.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+public class SandeshaClientLastErrorTest extends SandeshaTestCase {
+
+	String server_repoPath = "target" + File.separator + "repos" + File.separator + "server";
+	String server_axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "server_axis2.xml";
+
+	public SandeshaClientLastErrorTest () {
+		super ("SandeshaClientTest");
+	}
+	
+	/**
+	 * Tests that the last error and timestamp are set for the simple case of the target service not being available
+	 */
+	public void testLastErrorAndTimestamp() throws Exception
+	{
+		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.setAction(pingAction);
+		clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+		
+		clientOptions.setTo(new EndpointReference (to));
+		clientOptions.setProperty(Configuration.TRANSPORT_URL,transportTo);
+		
+		String sequenceKey = "sequence1";
+		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+		
+		ServiceClient serviceClient = new ServiceClient (configContext,null);
+		
+		serviceClient.setOptions(clientOptions);
+	
+		serviceClient.fireAndForget(getPingOMBlock("ping1"));
+		
+		// Let an error occur before we start the server
+		long limit = System.currentTimeMillis() + waitTime;
+		Error lastError = null;
+		while(System.currentTimeMillis() < limit) {
+			Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
+			
+			try {
+				// Check that the last error and last error time stamp have been set
+				Exception lastSendError = SandeshaClient.getLastSendError(serviceClient);
+				long lastSendErrorTime = SandeshaClient.getLastSendErrorTimestamp(serviceClient);
+				
+				// Check the values are valid
+				assertNotNull(lastSendError);
+				assertTrue(lastSendErrorTime > -1);
+
+				lastError = null;
+				break;
+			} catch(Error e) {
+				lastError = e;
+			}
+		}
+		if(lastError != null) throw lastError;
+		
+		startServer(server_repoPath, server_axis2_xml);
+
+		serviceClient.fireAndForget(getPingOMBlock("ping2"));
+		
+		
+		limit = System.currentTimeMillis() + waitTime;
+		while(System.currentTimeMillis() < limit) {
+			Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
+			
+			try {
+				SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+				assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
+				assertTrue(sequenceReport.getCompletedMessages().contains(new Long(2)));
+				assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
+
+				lastError = null;
+				break;
+			} catch(Error e) {
+				lastError = e;
+			}
+		}
+		if(lastError != null) throw lastError;
+	
+		SandeshaClient.terminateSequence(serviceClient, sequenceKey);
+		
+		configContext.getListenerManager().stop();
+		serviceClient.cleanup();
+	}
+	
+}

Added: webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/SandeshaClientTerminateWaitTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/SandeshaClientTerminateWaitTest.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/SandeshaClientTerminateWaitTest.java (added)
+++ webservices/sandesha/trunk/java/modules/tests/src/org/apache/sandesha2/SandeshaClientTerminateWaitTest.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,109 @@
+/*
+ * 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;
+
+import java.io.File;
+
+import org.apache.axiom.soap.SOAP11Constants;
+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.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+public class SandeshaClientTerminateWaitTest extends SandeshaTestCase {
+
+	String server_repoPath = "target" + File.separator + "repos" + File.separator + "server";
+	String server_axis2_xml = "target" + File.separator + "repos" + File.separator + "server" + File.separator + "server_axis2.xml";
+
+	public SandeshaClientTerminateWaitTest () {
+		super ("SandeshaClientTest");
+	}
+
+  /**
+	 * Checks the following scenario
+	 * 
+	 * Don't start the server
+	 * 1) send an application message (will generate the create sequence)
+	 * 2) terminate the sequence
+	 * 3) send another application message (this should fail)
+	 * 4) start the server
+	 * 5) Issue wait until sequence completed (with a wait time)
+	 * 6) Ensure that the sequence was terminated
+	 * 
+	 */
+	public void testTerminateSequenceWithWait () throws Exception {
+		String to = "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.setAction(pingAction);
+		clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+	   clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION, 
+	       Sandesha2Constants.SPEC_VERSIONS.v1_1);
+		clientOptions.setTo(new EndpointReference (to));
+		
+		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);
+			
+		try{
+			// 1) Send the application message
+			serviceClient.fireAndForget(getPingOMBlock("ping1"));
+			
+			// 2) Terminate the sequence
+			SandeshaClient.terminateSequence(serviceClient);
+			
+			// 3) Send the second application message (this should fail)
+			try{
+				serviceClient.fireAndForget(getPingOMBlock("ping2"));
+				fail(); //this should have failed
+			}
+			catch(Exception e){
+				//good
+			}
+			
+			// 4) Start the server			
+			startServer(server_repoPath, server_axis2_xml);
+
+			// 5) wait for the sequence completion (30 second wait)
+			SandeshaClient.waitUntilSequenceCompleted(serviceClient, 30000);
+			
+			// 6) Check that the sequence has terminated
+			SequenceReport report = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+			assertNotNull(report);
+			assertEquals(SequenceReport.SEQUENCE_STATUS_TERMINATED, report.getSequenceStatus());
+
+		}
+		finally {
+			configContext.getListenerManager().stop();
+			serviceClient.cleanup();			
+		}		
+	}
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org