http://wso2.com/products/business-process-server/
Following are the steps to write a simple test case for a simple bpel process.
As an example adder.process.zip is being used to write a test case.
In this example assign activity of BPEL will be used. 2 values will be added and the input will be the result.
Since this is a Basic bpel activity, we will be including our test case inside,
../integration/org.wso2.bps.bpel.taftests/
/home/../turing/products/bps/3.2.0/modules/integration/org.wso2.bps.bpel.taftests/src/test/java/org/wso2/carbon/bps/bpelactivities/BPELBasicActivitiesTest.java
Steps :
1. First of all we should include our artifact inside the
/home/../turing/products/bps/3.2.0/modules/integration/org.wso2.bps.bpel.taftests/src/test/resources/artifacts/bpel folder.
2. Since its a Basic activity test case, I will be adding it under BPELBasicActivitiesTest.java in /home/../turing/products/bps/3.2.0/modules/integration/org.wso2.bps.bpel.taftests/src/test/java/org/wso2/carbon/bps/bpelactivities/BPELBasicActivitiesTest.java
3.
6. You can undeploy the uploaded zip file,
public class BPELBasicActivitiesTest extends BPSMasterTest {
//Extends the Test class
private static final Log log = LogFactory.getLog(BPELBasicActivitiesTest.class);
//Logs
BpelPackageManagementClient bpelPackageManagementClient;
RequestSender requestSender;
public void setEnvironment() throws LoginAuthenticationExceptionException, RemoteException {
init();
bpelPackageManagementClient = new BpelPackageManagementClient(backEndUrl, sessionCookie);
//Pass the Service endpoint and session cookie
requestSender = new RequestSender();
}
Above section will be available already since there were already written test cases.
(I assume it was being explained during the automation training. )
4. To set the environment with AdderProcess.zip we should provide the name of it to upload.
@BeforeClass(alwaysRun = true)
public void deployArtifact()
throws Exception {
setEnvironment();
uploadBpelForTest("AdderProcess");
}
5. Following is the added test case.
@Test(groups = {"wso2.bps", "wso2.bps.bpelactivities"}, description = "Adder Process case")
public void adderProcess() throws InterruptedException, RemoteException, PackageManagementException, MalformedURLException, XMLStreamException {
String payLoad = " <p:AdderProcessRequest xmlns:p=\"http://wso2.org/wso2con/2011/sample/adder\">\n" +
" <!--Exactly 1 occurrence--><p:a>1</p:a>\n" +
" <!--Exactly 1 occurrence--><p:b>2</p:b> " +
" </p:AdderProcessRequest>";
String operation = "process";
String serviceName = "AdderProcessService";
String expectedResult = "3";
requestSender.assertRequest(backEndUrl + serviceName, operation, payLoad,
1, expectedResult, true);
}
6. You can undeploy the uploaded zip file,
@AfterClass(alwaysRun = true)
public void removeArtifacts()
throws PackageManagementException, InterruptedException, RemoteException,
LogoutAuthenticationExceptionException {
bpelPackageManagementClient.undeployBPEL("AdderProcess");
this.authenticatorClient.logOut();
}
}
Explanation :
1. public void adderProcess() throws InterruptedException, RemoteException, PackageManagementException, MalformedURLException, XMLStreamException {
This above is the method written for adderProcess()
2.
String payLoad = " <p:AdderProcessRequest xmlns:p=\"http://wso2.org/wso2con/2011/sample/adder\">\n" +
" <!--Exactly 1 occurrence--><p:a>1</p:a>\n" +
" <!--Exactly 1 occurrence--><p:b>2</p:b> " +
" </p:AdderProcessRequest>";
String operation = "process";
String serviceName = "AdderProcessService";
String expectedResult = "3";
Above is the variable assignment.
payLoad is what we get from try it tool when you deploy the adderProcess in a BPS distribution.
operation can be checked by the wsdl of adderProcess when you deploy it in a BPS distribution. E.g., <operation name="process">
serviceName this can also be checked by the wsdl of adderProcess when you deploy it in a BPS distribution. E.g., <service name="AdderProcessService">
3. requestSender.assertRequest(backEndUrl + serviceName, operation, payLoad,
1, expectedResult, true);
The above is the request to be sent and assertRequest method is called.
Definition would be :
public void assertRequest(java.lang.String eprUrl, java.lang.String operation, java.lang.String payload, int numberOfInstances, java.lang.String expectedException, boolean twoWay) throws javax.xml.stream.XMLStreamException, org.apache.axis2.AxisFault { }
backEndUrl : This is the BPS backend URL