Java Code Examples for org.wso2.carbon.automation.test.utils.axis2client.AxisServiceClient#sendReceive()

The following examples show how to use org.wso2.carbon.automation.test.utils.axis2client.AxisServiceClient#sendReceive() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OutputMappingAsAttributeDataServiceTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Test(groups = { "wso2.dss" }, dependsOnMethods = { "addOffice" })
public void getOffices() throws AxisFault, XPathExpressionException {
    AxisServiceClient serviceClient = new AxisServiceClient();
    OMElement response = serviceClient
            .sendReceive(getPayloadGetOffice(), getServiceUrlHttp(serviceName), "showAllOffices");
    Assert.assertNotNull(response, "Response Message in null");
    Iterator<OMElement> itr = response.getChildrenWithName(new QName("Office"));
    int recordCount = 0;
    while (itr.hasNext()) {
        OMElement office = itr.next();
        Assert.assertNotNull(office.getAttribute(new QName("officeCode")),
                "officeCode attribute not found with response");
        Assert.assertFalse(office.getAttributeValue(new QName("officeCode")).equalsIgnoreCase(""),
                "Attribute Name officeCode value empty");

        if (office.getAttribute(new QName("country")) != null) {
            Assert.assertFalse(office.getAttributeValue(new QName("country")).equalsIgnoreCase(""),
                    "Attribute Name country value empty");
        }

        ++recordCount;
    }
    Assert.assertEquals(recordCount, 10, "All offices on the table not in response.invalid response. "
            + "because one of attribute value is null");

}
 
Example 2
Source File: FaultyDataServiceTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.dss", dependsOnMethods = {
        "serviceReDeployment" }, description = "send requests to redeployed service")
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
public void serviceInvocation() throws RemoteException, ServiceAdminException, XPathExpressionException {
    OMElement response;
    String serviceEndPoint = getServiceUrlHttp(serviceName) + "/";
    AxisServiceClient axisServiceClient = new AxisServiceClient();
    for (int i = 0; i < 5; i++) {
        response = axisServiceClient.sendReceive(getPayload(), serviceEndPoint, "showAllOffices");
        Assert.assertTrue(response.toString().contains("<Office>"), "Expected Result not Found");
        Assert.assertTrue(response.toString().contains("<officeCode>"), "Expected Result not Found");
        Assert.assertTrue(response.toString().contains("<city>"), "Expected Result not Found");
        Assert.assertTrue(response.toString().contains("<phone>"), "Expected Result not Found");
        Assert.assertTrue(response.toString().contains("</Office>"), "Expected Result not Found");
    }
    log.info("service invocation success");
}
 
Example 3
Source File: OutputMappingAsAttributeDataServiceTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = {"wso2.dss"}, dependsOnMethods = {"addOffice"})
public void getOffices() throws AxisFault, XPathExpressionException {
    AxisServiceClient serviceClient = new AxisServiceClient();
    OMElement response = serviceClient.sendReceive(getPayloadGetOffice(), getServiceUrlHttp(serviceName), "showAllOffices");
    Assert.assertNotNull(response, "Response Message in null");
    Iterator<OMElement> itr = response.getChildrenWithName(new QName("Office"));
    int recordCount = 0;
    while (itr.hasNext()) {
        OMElement office = itr.next();
        Assert.assertNotNull(office.getAttribute(new QName("officeCode")), "officeCode attribute not found with response");
        Assert.assertFalse(office.getAttributeValue(new QName("officeCode")).equalsIgnoreCase(""), "Attribute Name officeCode value empty");

        if (office.getAttribute(new QName("country")) != null) {
            Assert.assertFalse(office.getAttributeValue(new QName("country")).equalsIgnoreCase(""), "Attribute Name country value empty");
        }

        ++recordCount;
    }
    Assert.assertEquals(recordCount, 10, "All offices on the table not in response.invalid response. " +
                                         "because one of attribute value is null");

}
 
Example 4
Source File: FaultyDataServiceTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.dss", dependsOnMethods = {"serviceReDeployment"},
      description = "send requests to redeployed service")
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
public void serviceInvocation()
        throws RemoteException, ServiceAdminException, XPathExpressionException {
    OMElement response;
    String serviceEndPoint = getServiceUrlHttp(serviceName) +"/";
    AxisServiceClient axisServiceClient = new AxisServiceClient();
    for (int i = 0; i < 5; i++) {
        response = axisServiceClient.sendReceive(getPayload(), serviceEndPoint, "showAllOffices");
        Assert.assertTrue(response.toString().contains("<Office>"), "Expected Result not Found");
        Assert.assertTrue(response.toString().contains("<officeCode>"), "Expected Result not Found");
        Assert.assertTrue(response.toString().contains("<city>"), "Expected Result not Found");
        Assert.assertTrue(response.toString().contains("<phone>"), "Expected Result not Found");
        Assert.assertTrue(response.toString().contains("</Office>"), "Expected Result not Found");
    }
    log.info("service invocation success");
}
 
Example 5
Source File: PayloadFormatWithNoArgumentTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = "wso2.esb", description = "invoke service - operation echoString")
public void invokeServiceFromXmlRequest() throws AxisFault {

    AxisServiceClient axisServiceClient = new AxisServiceClient();

    OMElement response = axisServiceClient.sendReceive(createPayload(),
            contextUrls.getServiceUrl() + "/ProxyPF", "echoString");

    assertTrue(response.toString().contains("[email protected]"), "Response mismatch. " +
            "Actual Response " + response.toString());
}
 
Example 6
Source File: PayloadFormatWithArgumentsTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = "wso2.esb", description = "invoke service - operation echoString")
public void invokeServiceFromXmlRequest() throws AxisFault {

    AxisServiceClient axisServiceClient = new AxisServiceClient();
    OMElement response = axisServiceClient.sendReceive(createPayload(),
            contextUrls.getServiceUrl() + "/ProxyPF", "echoString");
    assertTrue(response.toString().contains("Wso2 Test Automation"),"Response mismatch. " +
            "Actual Response "+response.toString());
}
 
Example 7
Source File: ReturnRequestStatusTest.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
@Test(groups = "wso2.dss", dependsOnMethods = { "requestStatusNameSpaceQualifiedForDeleteOperation" }, timeOut =
        1000 * 60 * 2)
public void inOperationConcurrencyTest() throws InterruptedException, ConcurrencyTestFailedError {

    final ExceptionHandler handler = new ExceptionHandler();
    final int concurrencyNumber = 50;
    final int numberOfIterations = 1;
    Thread[] clientThread = new Thread[concurrencyNumber];
    final AxisServiceClient serviceClient = new AxisServiceClient();
    for (int i = 0; i < concurrencyNumber; i++) {
        final int empNo = i + 50;
        clientThread[i] = new Thread(() -> {
            for (int j = 0; j < numberOfIterations; j++) {
                try {
                    OMElement response = serviceClient
                            .sendReceive(getAddEmployeePayload(empNo + ""), serviceEndPoint, "addEmployee");
                    assertTrue(response.toString().contains("SUCCESSFUL"), "Response Not Successful");
                    OMNamespace nameSpace = response.getNamespace();
                    Assert.assertNotNull(nameSpace, "Response Message NameSpace not qualified");
                } catch (AxisFault axisFault) {
                    log.error(axisFault);
                    handler.setException(axisFault);
                }
            }
        });
        clientThread[i].setUncaughtExceptionHandler(handler);

    }

    for (int i = 0; i < concurrencyNumber; i++) {
        clientThread[i].start();
    }

    for (int i = 0; i < concurrencyNumber; i++) {
        try {
            clientThread[i].join();
        } catch (InterruptedException e) {
            throw new InterruptedException("Exception Occurred while joining Thread");
        }
    }

    if (!handler.isTestPass()) {
        throw new ConcurrencyTestFailedError(handler.getFailCount() + " service invocation/s failed out of "
                + concurrencyNumber * numberOfIterations + " service invocations.\n"
                + "Concurrency Test Failed for Thread Group=" + concurrencyNumber + " and loop count="
                + numberOfIterations, handler.getException());
    }
}
 
Example 8
Source File: ReturnRequestStatusTest.java    From product-ei with Apache License 2.0 4 votes vote down vote up
@Test(groups = "wso2.dss", dependsOnMethods = {"requestStatusNameSpaceQualifiedForDeleteOperation"}, timeOut = 1000 * 60 * 2)
public void inOperationConcurrencyTest() throws InterruptedException,
                                                ConcurrencyTestFailedError {

    final ExceptionHandler handler = new ExceptionHandler();
    final int concurrencyNumber = 50;
    final int numberOfIterations = 1;
    Thread[] clientThread = new Thread[concurrencyNumber];
    final AxisServiceClient serviceClient = new AxisServiceClient();
    for (int i = 0; i < concurrencyNumber; i++) {
        final int empNo = i + 50;
        clientThread[i] = new Thread(new Runnable() {
            public void run() {
                for (int j = 0; j < numberOfIterations; j++) {
                    try {
                        OMElement response = serviceClient.sendReceive(getAddEmployeePayload(empNo + ""),
                                                                       serviceEndPoint, "addEmployee");
                        Assert.assertTrue(response.toString().contains("SUCCESSFUL"), "Response Not Successful");
                        OMNamespace nameSpace = response.getNamespace();
                        Assert.assertNotNull(nameSpace, "Response Message NameSpace not qualified");
                    } catch (AxisFault axisFault) {
                        log.error(axisFault);
                        handler.setException(axisFault);
                    }
                }
            }
        });
        clientThread[i].setUncaughtExceptionHandler(handler);

    }

    for (int i = 0; i < concurrencyNumber; i++) {
        clientThread[i].start();
    }

    for (int i = 0; i < concurrencyNumber; i++) {
        try {
            clientThread[i].join();
        } catch (InterruptedException e) {
            throw new InterruptedException("Exception Occurred while joining Thread");
        }
    }

    if (!handler.isTestPass()) {
        throw new ConcurrencyTestFailedError(handler.getFailCount() + " service invocation/s failed out of "
                                             + concurrencyNumber * numberOfIterations + " service invocations.\n"
                                             + "Concurrency Test Failed for Thread Group=" + concurrencyNumber
                                             + " and loop count=" + numberOfIterations, handler.getException());
    }
}