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/.

Writing a Test Case for Axis2 Server

The test framework provides a sample axis2 server as a pluggable extension. This extension class has been registered in the automation.xml under the pluggable extensions configuration. Thus, in the ESB integration runtime, the TestNG execution listener will start the axis2 server and deploy the default web services to the server just after completion of the carbon server startup.

Test developers can assume the server is running on localhost:9000 and proceed with their test cases with the default web services. The following web services will be deployed at the axis2 server startup by default.

  • SimpleStockQuoteService

  • SecureStockQuoteService

  • LBService1

  • Axis2Service 

A sample test class depending on SimpleStockQuoteService is shown below:

public class LogMediatorAfterSendMediatorTestCase extends ESBIntegrationTest {
    @BeforeClass(alwaysRun = true)
    public void uploadSynapseConfig() throws Exception {
        super.init();
        loadESBConfigurationFrom("/artifacts/ESB/mediatorconfig/send/synapse_uncaught_exception.xml");
    }

     @Test(groups = {"wso2.esb"}, description = "use Log mediator after send mediator")
    public void logMediatorAfterSendMediatorTest() throws Exception {
        OMElement response =
                axis2Client.sendSimpleStockQuoteRequest(getProxyServiceURLHttp("testLogMediatorAfterSend"),
                        null, "WSO2");
        assertNotNull(response, "Response is null");
        assertEquals(response.getLocalName(), "getQuoteResponse", "getQuoteResponse mismatch");
        OMElement omElement = response.getFirstElement();
        String symbolResponse = omElement.getFirstChildWithName
                (new QName("http://services.samples/xsd", "symbol")).getText();
        assertEquals(symbolResponse, "WSO2", "Symbol is not match");
    }

     @AfterClass(alwaysRun = true)
    private void destroy() throws Exception {
        super.cleanup();
    }
}