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.setTo(new EndpointReference (to));
clientOptions.setFaultTo(new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL));
String sequenceKey = SandeshaUtil.getUUID();
clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);
if (soap12)
clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
ServiceClient serviceClient = new ServiceClient (configContext,null);
serviceClient.setOptions(clientOptions);
// Send a single ping message
serviceClient.fireAndForget(getPingOMBlock("ping1"));
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
// Check that the sequence has been deleted.
StorageManager storageManager =
SandeshaUtil.getSandeshaStorageManager(serverConfigContext, serverConfigContext.getAxisConfiguration());
Transaction tran = storageManager.getTransaction();
RMDBean finderBean = new RMDBean();
finderBean.setTerminated(false);
List rmdBeans = storageManager.getRMDBeanMgr().find(finderBean);
tran.commit();
lastError = null;
if (rmdBeans.isEmpty())
lastError = new Error("rmdBeans empty " + rmdBeans);
else {
RMDBean bean = (RMDBean)rmdBeans.get(0);
if (!bean.getServerCompletedMessages().getContainedElementsAsNumbersList().contains(new Integer(1))) {
tran = storageManager.getTransaction();
if (deleteRMSBean) {
storageManager.getRMDBeanMgr().delete(bean.getSequenceID());
} else {
bean.setTerminated(true);
storageManager.getRMDBeanMgr().update(bean);
}
tran.commit();
break;
}
lastError = new Error("App message has not arrived");
}
}
if(lastError != null) throw lastError;
// Send a second application message.
serviceClient.fireAndForget(getPingOMBlock("ping2"));
while(System.currentTimeMillis() < limit) {
Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
try {
//Check that the outgoing sequence is terminated
SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
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();
}