This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Using Custom Annotations

The following test class demonstrates the usage of custom annotations. For a detailed explanation of custom annotations see TestNG Custom Annotations.

public class AARServiceTestCase extends ASIntegrationTest {

    private static final Log log = LogFactory.getLog(AARServiceTestCase.class);
    private static String axis2Service = "Axis2Service";

    @SetEnvironment(executionEnvironments = {ExecutionEnvironment.PLATFORM})
    @BeforeClass(alwaysRun = true)
    public void init() throws Exception {
        super.init();
    }

    @SetEnvironment(executionEnvironments = {ExecutionEnvironment.PLATFORM})
    @Test(groups = "wso2.as", description = "Upload aar service and verify deployment")
    public void arrServiceUpload() throws Exception {
        AARServiceUploaderClient aarServiceUploaderClient
                = new AARServiceUploaderClient(backendURL,sessionCookie);

        aarServiceUploaderClient.uploadAARFile("Axis2Service.aar",
                FrameworkPathUtil.getSystemResourceLocation() + "artifacts" +
                        File.separator + "AS" + File.separator + "aar" + File.separator +
                        "Axis2Service.aar", "");

        isServiceDeployed(axis2Service);
        log.info("Axis2Service.aar service uploaded successfully");
    }

    @SetEnvironment(executionEnvironments = {ExecutionEnvironment.PLATFORM})
    @Test(groups = "wso2.as", description = "invoke aar service", dependsOnMethods = "arrServiceUpload")
    public void invokeService() throws Exception {
        AxisServiceClient axisServiceClient = new AxisServiceClient();
        String endpoint = getServiceUrl("Axis2Service");
        OMElement response = axisServiceClient.sendReceive(createPayLoad(), endpoint, "echoInt");
        log.info("Response : " + response);
        assertTrue(response.toString().contains("<ns:return>25</ns:return>"));

    }

    public static OMElement createPayLoad() {
        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMNamespace omNs = fac.createOMNamespace("http://service.carbon.wso2.org", "ns");
        OMElement getOme = fac.createOMElement("echoInt", omNs);

        OMElement getOmeTwo = fac.createOMElement("x", omNs);
        getOmeTwo.setText("25");

        getOme.addChild(getOmeTwo);
        return getOme;
    }
}