org.wso2.carbon.automation.test.utils.axis2client.AxisServiceClient Java Examples

The following examples show how to use org.wso2.carbon.automation.test.utils.axis2client.AxisServiceClient. 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: CSVSampleServiceTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Test(groups = { "wso2.dss" }, invocationCount = 5)
public void selectOperation() throws AxisFault, XPathExpressionException {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://ws.wso2.org/dataservice/samples/csv_sample_service", "ns1");
    OMElement payload = fac.createOMElement("getProducts", omNs);

    OMElement result = new AxisServiceClient().sendReceive(payload, getServiceUrlHttp(serviceName), "getProducts");
    Assert.assertTrue((result.toString().indexOf("Products") == 1),
            "Expected Result not found on response message");
    Assert.assertTrue(result.toString().contains("<Product>"), "Expected Result not found on response message");
    Assert.assertTrue(result.toString().contains("<ID>"), "Expected Result not found on response message");
    Assert.assertTrue(result.toString().contains("<Category>"), "Expected Result not found on response message");
    Assert.assertTrue(result.toString().contains("<Price>"), "Expected Result not found on response message");
    Assert.assertTrue(result.toString().contains("<Name>"), "Expected Result not found on response message");
    log.info("Service invocation success");
}
 
Example #2
Source File: WhiteSpaceWithQueryParamsTest.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private void addEmployee(String serviceEndPoint, String employeeNumber) throws AxisFault {
    OMElement payload = fac.createOMElement("addEmployee", omNs);

    OMElement empNo = fac.createOMElement("employeeNumber", omNs);
    empNo.setText(employeeNumber);
    payload.addChild(empNo);

    OMElement lastName = fac.createOMElement("lastName", omNs);
    lastName.setText("BBB");
    payload.addChild(lastName);

    OMElement fName = fac.createOMElement("firstName", omNs);
    fName.setText("AAA");
    payload.addChild(fName);

    OMElement email = fac.createOMElement("email", omNs);
    email.setText("[email protected]");
    payload.addChild(email);

    OMElement salary = fac.createOMElement("salary", omNs);
    salary.setText("50000");
    payload.addChild(salary);

    new AxisServiceClient().sendRobust(payload, serviceEndPoint, "addEmployee");

}
 
Example #3
Source File: DS1031PolicyKeyWithoutPolicyPathTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.dss", description = "Check whether service is listed as a deployed service")
public void testServiceDeployment() throws Exception {

    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://ws.wso2.org/dataservice", "ns1");
    OMElement payload = fac.createOMElement("select_all_Customers_operation", omNs);
    try {
        String serviceName = "PolicyKeyWithoutPolicyPathTest";
        new AxisServiceClient()
                .sendReceive(payload, getServiceUrlHttp(serviceName), "select_all_Customers_operation");
        Assert.fail();
    } catch (Exception e) {
        Assert.assertTrue(e.getLocalizedMessage().contains("Transport error: 404 Error: Not Found"),
                "Faulty service got deployed");
    }
}
 
Example #4
Source File: ReturnRequestStatusTest.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private void deleteEmployeeById(String employeeNumber) throws AxisFault {
    OMElement result;
    OMElement payload = fac.createOMElement("deleteEmployeeById", omNs);

    OMElement empNo = fac.createOMElement("employeeNumber", omNs);
    empNo.setText(employeeNumber);
    payload.addChild(empNo);

    result = new AxisServiceClient().sendReceive(payload, serviceEndPoint, "deleteEmployeeById");

    assertTrue(result.toString().contains("SUCCESSFUL"), "Response Not Successful");
    OMNamespace nameSpace = result.getNamespace();
    Assert.assertNotNull(nameSpace.getPrefix(), "Invalid prefix. prefix value null");
    Assert.assertNotSame(nameSpace.getPrefix(), "", "Invalid prefix");
    Assert.assertEquals(nameSpace.getNamespaceURI(), "http://ws.wso2.org/dataservice", "Invalid NamespaceURI");
}
 
Example #5
Source File: DS1103DuplicateDataServiceTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.dss", description = "Testing the duplicate data service deployment fail test case.")
public void testForDuplicateDataServiceDeployment() {

    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://ws.wso2.org/dataservice", "ns1");
    OMElement payload = fac.createOMElement("select_all_Customers_operation", omNs);
    try {
        String serviceNameSecond = "H2SimpleJsonTestDuplicate";
        new AxisServiceClient()
                .sendReceive(payload, getServiceUrlHttp(serviceNameSecond), "select_all_Customers_operation");
        Assert.fail();
    } catch (Exception e) {
        Assert.assertTrue(e.getLocalizedMessage().contains("Transport error: 404 Error: Not Found"),
                "Duplicate " + "service got deployed");
    }
}
 
Example #6
Source File: GSpreadDataServiceTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Test(groups = { "wso2.dss" }, invocationCount = 5, enabled = true)
public void selectOperation() throws AxisFault, XPathExpressionException {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac
            .createOMNamespace("http://ws.wso2.org/dataservice/samples/gspread_sample_service", "ns1");
    OMElement payload = fac.createOMElement("getCustomers", omNs);

    OMElement result = new AxisServiceClient().sendReceive(payload, getServiceUrlHttp(serviceName), "getcustomers");
    log.info("Response : " + result);
    Assert.assertTrue((result.toString().indexOf("Customers") == 1),
            "Expected Result not found on response message");
    Assert.assertTrue(result.toString().contains("<customerNumber>"),
            "Expected Result not found on response message");
    Assert.assertTrue(result.toString().contains("</Customer>"), "Expected Result not found on response message");

    log.info("Service Invocation success");
}
 
Example #7
Source File: SampleDataServiceClient.java    From product-ei with Apache License 2.0 6 votes vote down vote up
public void addEmployee(String employeeNumber) throws AxisFault {
    OMElement payload = fac.createOMElement("addEmployee", omNs);

    OMElement empNo = fac.createOMElement("employeeNumber", omNs);
    empNo.setText(employeeNumber);
    payload.addChild(empNo);

    OMElement lastName = fac.createOMElement("lastName", omNs);
    lastName.setText("BBB");
    payload.addChild(lastName);

    OMElement fName = fac.createOMElement("firstName", omNs);
    fName.setText("AAA");
    payload.addChild(fName);

    OMElement email = fac.createOMElement("email", omNs);
    email.setText("[email protected]");
    payload.addChild(email);

    OMElement salary = fac.createOMElement("salary", omNs);
    salary.setText("50000");
    payload.addChild(salary);

    new AxisServiceClient().sendRobust(payload, serviceEndpoint, "addEmployee");

}
 
Example #8
Source File: InOnlyRequestsServiceTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
private void addStudent(int studentNo) throws AxisFault, XPathExpressionException {
    OMElement payload = fac.createOMElement("addStudent", omNs);

    OMElement stdNo = fac.createOMElement("studentNumber", omNs);
    stdNo.setText(studentNo + "");
    payload.addChild(stdNo);

    OMElement stdName = fac.createOMElement("name", omNs);
    stdName.setText("Student" + studentNo);
    payload.addChild(stdName);

    OMElement stdPhone = fac.createOMElement("phone", omNs);
    stdPhone.setText("+1 650 219 478" + studentNo);
    payload.addChild(stdPhone);

    new AxisServiceClient().sendRobust(payload, getServiceUrlHttp(serviceName), "addStudent");

}
 
Example #9
Source File: DeactivatedCappMPBehaviourOnRestartTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = { "wso2.esb" },
      description = "Testing whether a deactivated Message Processor from a capp is deployed successfully upon ESB server restart")
public void testDeactivatedMPUponServerRestart() throws Exception {

    // Stopping the axis2 Server before sending the client request.
    axis2Server.stop();
    AxisServiceClient client = new AxisServiceClient();
    client.sendRobust(createPlaceOrderRequest(3.141593E0, 4, "IBM"), getProxyServiceURLHttp(PROXY_SERVICE_NAME),
            "placeOrder");

    // Wait till the MP deactivates successfully. MP will try sending the message 4 times before getting deactivated.
    Thread.sleep(15000);

    axis2Server.start();

    // Restart the ESB Server after the MP is deactivated.
    serverConfigurationManager.restartGracefully();

    super.init();
    logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());

    Assert.assertFalse(Utils.checkForLog(logViewerClient, EXPECTED_ERROR_MESSAGE, 10),
            "Error occurred while deploying Carbon Application!");
    Assert.assertTrue(Utils.checkForLog(logViewerClient, SUCCESS_MESSAGE, 10),
            "Unable to deploy Carbon Application!");
}
 
Example #10
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 #11
Source File: FileServiceTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Test(groups = { "wso2.dss" })
public void createNewFile() throws AxisFault, XPathExpressionException {
    OMElement response;
    OMElement payload;

    payload = fac.createOMElement("_getcreatenewfile", omNs);

    OMElement fileName = fac.createOMElement("fileName", omNs);
    fileName.setText(txtFileName);
    payload.addChild(fileName);

    OMElement fileType = fac.createOMElement("fileType", omNs);
    fileType.setText(txtFileType);
    payload.addChild(fileType);

    new AxisServiceClient().sendRobust(payload, getServiceUrlHttp(serviceName), "_getcreatenewfile");
    response = checkFileExists();
    Assert.assertEquals("1", response.getFirstElement().getFirstElement().getText(),
            "Expected Not same .File Not Exists");
    log.info("New File Created");

}
 
Example #12
Source File: FileServiceTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Test(groups = { "wso2.dss" }, dependsOnMethods = { "addRecord" })
public void checkFileSize() throws AxisFault, XPathExpressionException {
    OMElement payload = fac.createOMElement("_getgetfilesize", omNs);

    OMElement fileName = fac.createOMElement("fileName", omNs);
    fileName.setText(txtFileName);
    payload.addChild(fileName);

    OMElement result = new AxisServiceClient()
            .sendReceive(payload, getServiceUrlHttp(serviceName), "_getgetfilesize");
    System.out.println(result);
    Assert.assertNotNull(result, "Response message null ");
    Assert.assertTrue(Integer.parseInt(result.getFirstElement().getFirstElement().getText()) > 1,
            "Expected not same");
    log.info("File Size Verified");
}
 
Example #13
Source File: JMXStatisticsTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = {"wso2.dss"}, invocationCount = 5, description = "invoke service",
      dependsOnMethods = "testServiceDeployment", enabled = false)
public void selectOperation() throws AxisFault, XPathExpressionException {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://ws.wso2.org/dataservice/samples/gspread_sample_service", "ns1");
    OMElement payload = fac.createOMElement("getCustomers", omNs);

    OMElement result = new AxisServiceClient().sendReceive(payload, getServiceUrlHttp(serviceName),
                                                           "getProducts");
    log.info("Response : " + result);
    Assert.assertTrue((result.toString().indexOf("Customers") == 1),
                      "Expected Result not found on response message");
    Assert.assertTrue(result.toString().contains("<customerNumber>"),
                      "Expected Result not found on response message");
    Assert.assertTrue(result.toString().contains("</Customer>"),
                      "Expected Result not found on response message");

    log.info("Service Invocation success");
}
 
Example #14
Source File: ReturnRequestStatusTest.java    From product-ei with Apache License 2.0 6 votes vote down vote up
private void deleteEmployeeById(String employeeNumber) throws AxisFault {
    OMElement result;
    OMElement payload = fac.createOMElement("deleteEmployeeById", omNs);

    OMElement empNo = fac.createOMElement("employeeNumber", omNs);
    empNo.setText(employeeNumber);
    payload.addChild(empNo);

    result = new AxisServiceClient().sendReceive(payload, serviceEndPoint, "deleteEmployeeById");

    Assert.assertTrue(result.toString().contains("SUCCESSFUL"), "Response Not Successful");
    OMNamespace nameSpace = result.getNamespace();
    Assert.assertNotNull(nameSpace.getPrefix(), "Invalid prefix. prefix value null");
    Assert.assertNotSame(nameSpace.getPrefix(), "", "Invalid prefix");
    Assert.assertEquals(nameSpace.getNamespaceURI(), "http://ws.wso2.org/dataservice", "Invalid NamespaceURI");
}
 
Example #15
Source File: CSVDataServiceTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = {"wso2.dss"}, invocationCount = 5)
public void selectOperation() throws AxisFault, XPathExpressionException {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://ws.wso2.org/dataservice/samples/csv_sample_service", "ns1");
    OMElement payload = fac.createOMElement("getProducts", omNs);

    OMElement result = new AxisServiceClient().sendReceive(payload, getServiceUrlHttp(serviceName), "getProducts");
    Assert.assertTrue((result.toString().indexOf("Products") == 1), "Expected Result not found on response message");
    Assert.assertTrue(result.toString().contains("<Product>"), "Expected Result not found on response message");
    Assert.assertTrue(result.toString().contains("<ID>"), "Expected Result not found on response message");
    Assert.assertTrue(result.toString().contains("<Category>"), "Expected Result not found on response message");
    Assert.assertTrue(result.toString().contains("<Price>"), "Expected Result not found on response message");
    Assert.assertTrue(result.toString().contains("<Name>"), "Expected Result not found on response message");

    log.info("Service invocation success");
}
 
Example #16
Source File: ReScheduleTaskTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private void addEmployee(String employeeNumber) throws AxisFault {
    OMElement payload = fac.createOMElement("addEmployee", omNs);

    OMElement empNo = fac.createOMElement("employeeNumber", omNs);
    empNo.setText(employeeNumber);
    payload.addChild(empNo);

    OMElement lastName = fac.createOMElement("lastName", omNs);
    lastName.setText("BBB");
    payload.addChild(lastName);

    OMElement fName = fac.createOMElement("firstName", omNs);
    fName.setText("AAA");
    payload.addChild(fName);

    OMElement email = fac.createOMElement("email", omNs);
    email.setText("[email protected]");
    payload.addChild(email);

    OMElement salary = fac.createOMElement("salary", omNs);
    salary.setText("50000");
    payload.addChild(salary);

    new AxisServiceClient().sendRobust(payload, serviceEndPoint, "addEmployee");

}
 
Example #17
Source File: ReScheduleTaskTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private OMElement getEmployeeById(String employeeNumber) throws AxisFault, InterruptedException {
    OMElement payload = fac.createOMElement("employeesByNumber", omNs);

    OMElement empNo = fac.createOMElement("employeeNumber", omNs);
    empNo.setText(employeeNumber);
    payload.addChild(empNo);
    int count = 0;
    OMElement result = null;
    while (count < 2) {
        result = new AxisServiceClient().sendReceive(payload, serviceEndPoint, "employeesByNumber");
        count++;
    }
    Assert.assertNotNull(result, "Employee record null");
    System.out.println("Employee ID " + result.toString());
    Assert.assertTrue(result.toString().contains("<first-name>AAA</first-name>"), "Expected Result Mismatched");
    return result;
}
 
Example #18
Source File: DS1189LeagyTimeStampModeTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = {"wso2.dss"}, description = "insert timestamp in America/New_York timezone and UTC timezone, retrieve all and compare whether they are different", alwaysRun = true)
public void insertAndTestTimeStampValuesInDbTest() throws Exception {
    OMElement payload = fac.createOMElement("getTimeStamps", omNs);

    OMElement result = new AxisServiceClient().sendReceive(payload, backendUrl + serviceName, "getTimeStamps");

    Iterator iterator = result.getChildrenWithLocalName("timeStamp");

    String timeStampString = null;

    while (iterator.hasNext()) {
        OMElement timeStamp = (OMElement) iterator.next();
        if (timeStampString == null) {
            timeStampString = timeStamp.getChildrenWithLocalName("testTimeStamp").next().toString();
            log.info("TimeStamp Recv:"+timeStampString);
            Assert.assertTrue(timeStampString.contains("1970-01-02T05:00:00.000+00:00"));
        } else {
            String tempTimeStamp = timeStamp.getChildrenWithLocalName("testTimeStamp").next().toString();
            log.info("Timestamp Comapre:"+timeStampString+"|"+tempTimeStamp);
            Assert.assertFalse(timeStampString.equals(tempTimeStamp));
        }
    }
    Assert.assertNotNull(result, "Response message null ");
    log.debug(result);
    log.info("data service insert different timestamp to the database when the server is in different timezones");
}
 
Example #19
Source File: InputParametersValidationTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
private void addEmployee(String employeeNumber) throws AxisFault, XPathExpressionException {
    OMElement payload = fac.createOMElement("addEmployee", omNs);

    OMElement empNo = fac.createOMElement("employeeNumber", omNs);
    empNo.setText(employeeNumber);
    payload.addChild(empNo);

    OMElement lastName = fac.createOMElement("lastName", omNs);
    lastName.setText("BBB");
    payload.addChild(lastName);

    OMElement fName = fac.createOMElement("firstName", omNs);
    fName.setText("AAA");
    payload.addChild(fName);

    OMElement email = fac.createOMElement("email", omNs);
    email.setText("[email protected]");
    payload.addChild(email);

    OMElement salary = fac.createOMElement("salary", omNs);
    salary.setText("50000");
    payload.addChild(salary);

    new AxisServiceClient().sendRobust(payload, getServiceUrlHttp(serviceName), "addEmployee");

}
 
Example #20
Source File: ExcelSampleServiceTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = {"wso2.dss"}, invocationCount = 5, dependsOnMethods = "selectOperation")
public void xsltTransformation() throws AxisFault, XPathExpressionException {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://ws.wso2.org/dataservice", "ns1");
    OMElement payload = fac.createOMElement("getProductClassifications", omNs);
    OMElement result = new AxisServiceClient().sendReceive(payload, getServiceUrlHttp(serviceName), "getProductClassifications");
    if (log.isDebugEnabled()) {
        log.debug("Response :" + result);
    }
    Assert.assertTrue((result.toString().indexOf("Products") == 1), "Expected Result Not found");
    Assert.assertTrue(result.toString().contains("<product>"), "Expected Result Not found");
    Assert.assertTrue(result.toString().contains("<Product-Name>"), "Expected Result Not found");
    Assert.assertTrue(result.toString().contains("<Product-Classification>"), "Expected Result Not found");

    log.info("XSLT Transformation Success");
}
 
Example #21
Source File: ReScheduleTaskTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
private void IncreaseEmployeeSalary(String employeeNumber)
        throws AxisFault, InterruptedException {
    OMElement payload = fac.createOMElement("incrementEmployeeSalary", omNs);

    OMElement empNo = fac.createOMElement("employeeNumber", omNs);
    empNo.setText(employeeNumber);
    payload.addChild(empNo);

    OMElement salary = fac.createOMElement("increment", omNs);
    salary.setText("10000");
    payload.addChild(salary);

    new AxisServiceClient().sendRobust(payload, serviceEndPoint, "incrementEmployeeSalary");

    OMElement result = getEmployeeById(employeeNumber);
    Assert.assertTrue(result.toString().contains("<salary>60000.0</salary>"), "Expected Result Mismatched");
}
 
Example #22
Source File: ExcelSampleServiceTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Test(groups = { "wso2.dss" }, invocationCount = 5, dependsOnMethods = "selectOperation")
public void xsltTransformation() throws AxisFault, XPathExpressionException {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://ws.wso2.org/dataservice", "ns1");
    OMElement payload = fac.createOMElement("getProductClassifications", omNs);
    OMElement result = new AxisServiceClient()
            .sendReceive(payload, getServiceUrlHttp(serviceName), "getProductClassifications");
    if (log.isDebugEnabled()) {
        log.debug("Response :" + result);
    }
    Assert.assertTrue((result.toString().indexOf("Products") == 1), "Expected Result Not found");
    Assert.assertTrue(result.toString().contains("<product>"), "Expected Result Not found");
    Assert.assertTrue(result.toString().contains("<Product-Name>"), "Expected Result Not found");
    Assert.assertTrue(result.toString().contains("<Product-Classification>"), "Expected Result Not found");

    log.info("XSLT Transformation Success");
}
 
Example #23
Source File: SampleDataServiceClient.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public void addEmployee(String employeeNumber) throws AxisFault {
    OMElement payload = fac.createOMElement("addEmployee", omNs);

    OMElement empNo = fac.createOMElement("employeeNumber", omNs);
    empNo.setText(employeeNumber);
    payload.addChild(empNo);

    OMElement lastName = fac.createOMElement("lastName", omNs);
    lastName.setText("BBB");
    payload.addChild(lastName);

    OMElement fName = fac.createOMElement("firstName", omNs);
    fName.setText("AAA");
    payload.addChild(fName);

    OMElement email = fac.createOMElement("email", omNs);
    email.setText("[email protected]");
    payload.addChild(email);

    OMElement salary = fac.createOMElement("salary", omNs);
    salary.setText("50000");
    payload.addChild(salary);

    new AxisServiceClient().sendRobust(payload, serviceEndpoint, "addEmployee");

}
 
Example #24
Source File: ESBJAVA3412EmptyStackExceptionTest.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Checks and verifies whether the EmptyStackException is NOT thrown when
 * <code>Iterate</code> and <code>Clone</code> mediators are used in
 * combination with the continueParent attribute set to <code>true</code>
 *
 * @throws InterruptedException
 * @throws RemoteException
 */
@Test(groups = "wso2.esb", description = "Checking for Empty Stack Exception when clone mediators are used with continue parent attribute set to true")
public void testForEmptyStackAfterCloned_With_ContinueParent() throws InterruptedException, RemoteException {
    final String expectedErrorMsg = "Unexpected error executing task/async inject";
    final String expectedStackTrace = "java.util.Stack.peek";

    boolean isEmptyStackError;
    OMElement request = getSecurityRequest();

    // invoking the service through the proxy service
    AxisServiceClient client = new AxisServiceClient();

    final String proxyUrl = contextUrls.getServiceUrl() + "/CloneMediatorEmptyStackProxy";

    try {
        client.sendRobust(request, proxyUrl, "mediate");
    } catch (Exception e) {
        // Ignore it.
    }
    isEmptyStackError = carbonLogReader.checkForLog(expectedErrorMsg, DEFAULT_TIMEOUT) && carbonLogReader.
            checkForLog(expectedStackTrace, DEFAULT_TIMEOUT);
    carbonLogReader.stop();
    /*
     * Asserting the results here. If there's an Empty stack error, then the
     * assertion should fail.
     */
    Assert.assertTrue(!isEmptyStackError, "Empty Stack ERROR message was found in the LOG stream.");
}
 
Example #25
Source File: EventingSampleTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Test(groups = "wso2.dss", description = "update product quantity", dependsOnMethods = "testAddProduct", enabled = false)
public void testUpdateQuantity() throws RemoteException, DataServiceFault {
    //        eventingSampleStub.updateProductQuantity(productCode, 1);
    //        getProductByCode();
    new AxisServiceClient().sendRobust(updateProductPayload(), serverEpr, "updateProductQuantity");
    OMElement result = new AxisServiceClient()
            .sendReceive(getProductByCodePayload(), serverEpr, "getProductByCode");
    assertTrue(result.toString().contains("<productCode>999</productCode>"));
    assertTrue(result.toString().contains("<quantityInStock>1</quantityInStock>"));

}
 
Example #26
Source File: DataTypesTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * Method to test insertion of timestamp value.
 *
 * @throws Exception
 */
@Test(groups = {"wso2.dss"}, description = "insert null value as timestamp value and check it's successful", alwaysRun = true)
public void insertTimestampNullTest() throws Exception {
    OMElement insertTimeStampPayload = fac.createOMElement("addDeveloper", omNs);

    OMNamespace nullNameSpace = fac.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
    insertTimeStampPayload.declareNamespace(nullNameSpace);

    OMElement devId = fac.createOMElement("devId", omNs);
    devId.setText(2 + "");
    insertTimeStampPayload.addChild(devId);

    OMElement devName = fac.createOMElement("devName", omNs);
    devName.setText("name2");
    insertTimeStampPayload.addChild(devName);

    OMElement devdob = fac.createOMElement("devdob", omNs);
    OMAttribute nullAttribute = fac.createOMAttribute("nil", nullNameSpace,"true");
    devdob.addAttribute(nullAttribute);
    insertTimeStampPayload.addChild(devdob);

    new AxisServiceClient().sendRobust(insertTimeStampPayload, getServiceUrlHttp(serviceName), "addDeveloper");

    OMElement getDeveloperByIdPayload = fac.createOMElement("select_developers_by_id_operation", omNs);
    getDeveloperByIdPayload.addChild(devId);

    //retrieve and see whether inserted correctly
    OMElement responseProduct = new AxisServiceClient().sendReceive(getDeveloperByIdPayload, getServiceUrlHttp(serviceName), "select_developers_by_id_operation");
    assertNotNull(responseProduct, "Response null " + responseProduct);
    assertTrue(responseProduct.toString().contains("<devdob"), "'devdob' should have exist in the response");
    log.info("Insert TimeStamp Operation Success");
}
 
Example #27
Source File: FileServiceTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Test(groups = { "wso2.dss" }, dependsOnMethods = { "checkFileSize" })
public void deleteFile() throws AxisFault, XPathExpressionException {
    OMElement response;
    OMElement payload = fac.createOMElement("_getdeletefile", omNs);

    OMElement fileName = fac.createOMElement("fileName", omNs);
    fileName.setText(txtFileName);
    payload.addChild(fileName);

    new AxisServiceClient().sendRobust(payload, getServiceUrlHttp(serviceName), "_getdeletefile");
    response = checkFileExists();
    Assert.assertEquals("0", response.getFirstElement().getFirstElement().getText(),
            "Expected Not same .File not deleted");
    log.info("File Deleted");
}
 
Example #28
Source File: MultipleServicesGeneratorTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = "wso2.dss", description = "invoke the generated service",
      dependsOnMethods = "testServiceDeployment")
public void testRequest() throws RemoteException {

    OMElement result = new AxisServiceClient().sendReceive(getPayloadService1(), serviceEPR_1,
                                                           "select_all_REG_PATH_operation");

    assertTrue(result.toString().contains("<REG_PATH_VALUE>/_system/config</REG_PATH_VALUE>"));

    OMElement result2 = new AxisServiceClient().sendReceive(getPayloadService2(), serviceEPR_2,
                                                            "select_with_key_REG_PROPERTY_operation");

    assertTrue(result2.toString().contains("<REG_ID>1</REG_ID>"));
}
 
Example #29
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 #30
Source File: RegexTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = "wso2.dss", description = "Invoking select operation to verify regex support with nameparams and bracket expressions")
public void performRegexTestWithBracketExpressionsAndNameParams() throws AxisFault, XPathExpressionException {
	OMElement payload = factory.createOMElement("select_regex5", omNs);
	OMElement queryElement = factory.createOMElement("name", omNs);
	queryElement.setText("name");
	payload.addChild(queryElement);
	OMElement result = new AxisServiceClient().sendReceive(payload, getServiceUrlHttp(serviceName),
	                                                       "select_regex5");
	assertNotNull("Response null " + result);
	Assert.assertEquals(result.getLocalName(), "Entries");
}