Skip to content

Instantly share code, notes, and snippets.

@herrfz
Created July 16, 2013 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save herrfz/6006875 to your computer and use it in GitHub Desktop.
Save herrfz/6006875 to your computer and use it in GitHub Desktop.
DMS test case example
package com.triagnosys.dms.tester;
import one_thousand_things;
public class TestCases extends TestCase {
private static final String SOME_CONSTANTS;
public void testGetSession() throws AxisFault {
System.out.println("Testing DMS getSession");
DMServicesStub stub = createReliableDMSStub();
try {
GetSessionOptions SessionOptions = new GetSessionOptions();
GetSessionOptionsResponse Response = stub.getSessionOptions(SessionOptions);
System.out.println("DMS session information received");
assertEquals("PassThrough", true, Response.getModule()[0].getOption().getEnabled());
assertEquals("RM", true, Response.getModule()[1].getOption().getEnabled());
assertEquals("Compression", true, Response.getModule()[2].getOption().getEnabled());
assertEquals("Validation", false, Response.getModule()[3].getOption().getEnabled());
assertEquals("Filtering", true, Response.getModule()[4].getOption().getEnabled());
assertEquals("Prioritization", false, Response.getModule()[5].getOption().getEnabled());
} catch (RemoteException e) {
e.printStackTrace();
} finally {
// Close and terminate the RM sequence after sending the message
SandeshaClient.closeSequence(stub._getServiceClient());
SandeshaClient.terminateSequence(stub._getServiceClient());
}
}
//------ Other test cases ----
// ----- Helper methods -----
private DMServicesStub createReliableDMSStub() throws AxisFault {
// Create the service stub object and configure its parameters
//open service with the correct axis2.xml configuration file
ConfigurationContext cc = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_REPOSITORY, CLIENT_AXIS2_XML);
DMServicesStub stub = new DMServicesStub(cc, DMS);
//Setting the correct addressing , soap and rm versions
stub._getServiceClient().getOptions().setProperty(AddressingConstants.WS_ADDRESSING_VERSION, AddressingConstants.Submission.WSA_NAMESPACE);
stub._getServiceClient().getOptions().setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
stub._getServiceClient().getOptions().setProperty(SandeshaClientConstants.RM_SPEC_VERSION, Sandesha2Constants.SPEC_VERSIONS.v1_1);
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.MESSAGE_TYPE, "application/soap+fastinfoset");
//Set timeout for client side
long timeout = 300 * 1000; //300 seconds
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(timeout);
//Engage Addressing and RM modules
stub._getServiceClient().engageModule("addressing");
stub._getServiceClient().engageModule("sandesha2");
return(stub);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment