package de.tud.ao4bpel.services.reliability.test;
import java.net.MalformedURLException;
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;
import junit.framework.TestCase;
import org.apache.axis.Constants;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.sandesha.SandeshaContext;
public class SandeshaTest extends TestCase{
public void testCallTwowaySequence() throws ServiceException,
MalformedURLException, RemoteException{
int sync = 1;
String endpoint = "http://majestix:8080/axis/services/TestWebservice";
SandeshaContext ctx = new SandeshaContext();
if(org.apache.sandesha.Constants.SYNCHRONOUS == sync)
ctx = new SandeshaContext(sync);
// --------------------------- Init -------------------------//
String operationName = "testWSOneway1";
Service service1 = new Service();
Call call1;
call1 = (Call) service1.createCall();
ctx.initCall(call1, endpoint,
"urn:wsrm:"+operationName,org.apache.sandesha.Constants.ClientProperties.IN_OUT);
call1.setTargetEndpointAddress( new java.net.URL(endpoint) );
call1.setOperationName(new QName("TestWebservice", operationName));
call1.addParameter("message",
org.apache.axis.Constants.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call1.setReturnType(Constants.XSD_STRING);
//---------------------------- Service 1 -------------------------------
//
call1.setOperationName(new QName("TestWebservice", "testWS1"));
Object[] paramArray1 = new Object[] {"message1 sent by
callOnewaySequence"};
System.out.println(call1.invoke(paramArray1));
// ---------------------------- Service 2 -------------------------------
//
Call call2;
call2 = (Call) service1.createCall();
ctx.initCall(call2, endpoint,
"urn:wsrm:"+operationName,org.apache.sandesha.Constants.ClientProperties.IN_OUT);
call2.addParameter("message",
org.apache.axis.Constants.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call2.setReturnType(Constants.XSD_STRING);
call2.setTargetEndpointAddress( new java.net.URL(endpoint) );
call2.setOperationName(new QName("TestWebservice", "testWS2"));
Object[] paramArray2 = new Object[] {"message2 sent by
callOnewaySequence"};
System.out.println(call2.invoke(paramArray2));
//---------------------------- Service 3 -------------------------------
//
Call call3;
call3 = (Call) service1.createCall();
ctx.initCall(call3, endpoint,
"urn:wsrm:"+operationName,org.apache.sandesha.Constants.ClientProperties.IN_OUT);
call3.addParameter("message",
org.apache.axis.Constants.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call3.setReturnType(Constants.XSD_STRING);
call3.setTargetEndpointAddress( new java.net.URL(endpoint) );
call3.setOperationName(new QName("TestWebservice", "testWS3"));
ctx.setLastMessage(call3);
Object[] paramArray3 = new Object[] {"message3 sent by
callOnewaySequence"};
System.out.println(call3.invoke(paramArray3));
ctx.endSequence();
}
public void testCallOnewaySequence() throws ServiceException,
MalformedURLException, RemoteException{
int sync = 1;
String endpoint = "http://majestix:8080/axis/services/TestWebservice";
SandeshaContext ctx = new SandeshaContext();
if(org.apache.sandesha.Constants.SYNCHRONOUS == sync)
ctx = new SandeshaContext(sync);
// --------------------------- Init -------------------------//
String operationName = "testWSOneway1";
Service service1 = new Service();
Call call1;
call1 = (Call) service1.createCall();
ctx.initCall(call1, endpoint,
"urn:wsrm:"+operationName,org.apache.sandesha.Constants.ClientProperties.IN_ONLY);
call1.setTargetEndpointAddress( new java.net.URL(endpoint) );
call1.setOperationName(new QName("TestWebservice", operationName));
call1.addParameter("message",
org.apache.axis.Constants.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
//---------------------------- Service 1 -------------------------------
//
call1.setOperationName(new QName("TestWebservice", "testOnewayWS1"));
Object[] paramArray1 = new Object[] {"message1 sent by
callOnewaySequence"};
System.out.println(call1.invoke(paramArray1));
// ---------------------------- Service 2 -------------------------------
//
Call call2;
call2 = (Call) service1.createCall();
ctx.initCall(call2, endpoint,
"urn:wsrm:"+operationName,org.apache.sandesha.Constants.ClientProperties.IN_ONLY);
call2.addParameter("message",
org.apache.axis.Constants.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call2.setTargetEndpointAddress( new java.net.URL(endpoint) );
call2.setOperationName(new QName("TestWebservice", "testOnewayWS2"));
Object[] paramArray2 = new Object[] {"message2 sent by
callOnewaySequence"};
System.out.println(call2.invoke(paramArray2));
//---------------------------- Service 3 -------------------------------
//
Call call3;
call3 = (Call) service1.createCall();
ctx.initCall(call3, endpoint,
"urn:wsrm:"+operationName,org.apache.sandesha.Constants.ClientProperties.IN_ONLY);
call3.addParameter("message",
org.apache.axis.Constants.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call3.setTargetEndpointAddress( new java.net.URL(endpoint) );
call3.setOperationName(new QName("TestWebservice", "testOnewayWS3"));
ctx.setLastMessage(call3);
Object[] paramArray3 = new Object[] {"message3 sent by
callOnewaySequence"};
System.out.println(call3.invoke(paramArray3));
ctx.endSequence();
}
public void testCallOnewaySequenceMixed() throws ServiceException,
MalformedURLException, RemoteException{
int sync = 1;
String endpoint = "http://majestix:8080/axis/services/TestWebservice";
SandeshaContext ctx = new SandeshaContext();
if(org.apache.sandesha.Constants.SYNCHRONOUS == sync)
ctx = new SandeshaContext(sync);
// --------------------------- Init -------------------------//
String operationName = "testWSOneway1";
Service service1 = new Service();
Call call1;
call1 = (Call) service1.createCall();
ctx.initCall(call1, endpoint,
"urn:wsrm:"+operationName,org.apache.sandesha.Constants.ClientProperties.IN_ONLY);
call1.setTargetEndpointAddress( new java.net.URL(endpoint) );
call1.setOperationName(new QName("TestWebservice", operationName));
call1.addParameter("message",
org.apache.axis.Constants.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
//---------------------------- Service 1 -------------------------------
//
call1.setOperationName(new QName("TestWebservice", "testOnewayWS1"));
Object[] paramArray1 = new Object[] {"message1 sent by
callOnewaySequence"};
System.out.println(call1.invoke(paramArray1));
// ---------------------------- Service 2 -------------------------------
//
Call call2;
call2 = (Call) service1.createCall();
ctx.initCall(call2, endpoint,
"urn:wsrm:"+operationName,org.apache.sandesha.Constants.ClientProperties.IN_OUT);
call2.addParameter("message",
org.apache.axis.Constants.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call2.setReturnType(Constants.XSD_STRING);
call2.setTargetEndpointAddress( new java.net.URL(endpoint) );
call2.setOperationName(new QName("TestWebservice", "testWS2"));
Object[] paramArray2 = new Object[] {"message2 sent by
callOnewaySequence"};
System.out.println(call2.invoke(paramArray2));
//---------------------------- Service 3 -------------------------------
//
Call call3;
call3 = (Call) service1.createCall();
ctx.initCall(call3, endpoint,
"urn:wsrm:"+operationName,org.apache.sandesha.Constants.ClientProperties.IN_ONLY);
call3.addParameter("message",
org.apache.axis.Constants.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call3.setTargetEndpointAddress( new java.net.URL(endpoint) );
call3.setOperationName(new QName("TestWebservice", "testOnewayWS3"));
ctx.setLastMessage(call3);
Object[] paramArray3 = new Object[] {"message3 sent by
callOnewaySequence"};
System.out.println(call3.invoke(paramArray3));
ctx.endSequence();
}
}