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

The following examples show how to use org.wso2.carbon.automation.test.utils.axis2client.AxisServiceClient. These examples are extracted from open source projects. 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 Project: micro-integrator   Source File: SampleDataServiceClient.java    License: 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 2
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = "wso2.esb", description = "<property name=\"RETRY_ON_SOAPFAULT\" value=\"false\"/>")
public void testRetryOnSOAPFaultWithInOutFalse() throws Exception {

    loadESBConfigurationFromClasspath(File.separator + "artifacts" + File.separator + "ESB" + File.separator
                                      + "synapseconfig" + File.separator + "processor" + File.separator +
                                      "forwarding" + File.separator + "Retry_On_SOAPFault_In_Out.xml");

    AxisServiceClient serviceClient = new AxisServiceClient();
    serviceClient.fireAndForget(clearCountRequest(), getBackEndServiceUrl(), "clearRequestCount");
    OMElement requestCount = serviceClient.sendReceive(getCountRequest(), getBackEndServiceUrl(), "getRequestCount");
    Assert.assertEquals(requestCount.getFirstElement().getText(), "0", "Request Cunt not clear");

    serviceClient.sendRobust(getThrowAxisFaultRequest(), getMainSequenceURL(), "urn:throwAxisFault");
    Thread.sleep(5000);
    requestCount = serviceClient.sendReceive(getCountRequest(), getBackEndServiceUrl(), "getRequestCount");
    Assert.assertEquals(requestCount.getFirstElement().getText(), "1", "Request Count mismatched. Sent more than one request");

}
 
Example 3
@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 4
@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 5
Source Project: micro-integrator   Source File: ReturnRequestStatusTest.java    License: 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 6
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 7
@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 8
Source Project: product-ei   Source File: SampleDataServiceClient.java    License: 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 9
Source Project: product-ei   Source File: InOnlyRequestsServiceTestCase.java    License: 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 10
@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 11
Source Project: product-ei   Source File: FaultyDataServiceTestCase.java    License: 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 12
Source Project: micro-integrator   Source File: FileServiceTestCase.java    License: 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 13
Source Project: micro-integrator   Source File: FileServiceTestCase.java    License: 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 14
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 15
Source Project: product-ei   Source File: JMXStatisticsTestCase.java    License: 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 16
Source Project: product-ei   Source File: ReturnRequestStatusTest.java    License: 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 17
Source Project: product-ei   Source File: CSVDataServiceTestCase.java    License: 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 18
Source Project: micro-integrator   Source File: ReScheduleTaskTestCase.java    License: 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 19
Source Project: micro-integrator   Source File: ReScheduleTaskTestCase.java    License: 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 20
@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 21
Source Project: product-ei   Source File: ExcelSampleServiceTestCase.java    License: 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 22
Source Project: product-ei   Source File: ReScheduleTaskTestCase.java    License: 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 23
@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 24
Source Project: micro-integrator   Source File: CSVSampleServiceTestCase.java    License: 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 25
Source Project: micro-integrator   Source File: SampleDataServiceClient.java    License: Apache License 2.0 5 votes vote down vote up
public OMElement getEmployeeById(String employeeNumber) throws AxisFault {
    OMElement payload = fac.createOMElement("employeesByNumber", omNs);

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

    OMElement result = new AxisServiceClient().sendReceive(payload, serviceEndpoint, "employeesByNumber");
    return result;
}
 
Example 26
Source Project: product-ei   Source File: ReturnGeneratedKeysTestCase.java    License: Apache License 2.0 5 votes vote down vote up
@Test(groups = "wso2.dss", description = "Invoking insert operation with Return Generated Keys" , dependsOnMethods = "performConcurrencyTest")
public void performInsertWithReturnGeneratedKeysTest() throws AxisFault, XPathExpressionException {
	OMElement payload = factory.createOMElement("insertBalance", omNs);
	OMElement queryElement = factory.createOMElement("balance", omNs);
	queryElement.setText("22.184");
	payload.addChild(queryElement);
	OMElement result = new AxisServiceClient().sendReceive(payload, getServiceUrlHttp(serviceName), "insertBalance");
	/* id should be 26 because concurrency test has been performed before this method */
	boolean id = "26".equals(result.getFirstElement().getFirstChildWithName(
			new QName("http://ws.wso2.org/dataservice/samples/returnGeneratedKeysSample", "ID")).getText());
	Assert.assertTrue(id, "Insert operation with return generated keys is failed");
}
 
Example 27
/**
 * helper method to insert timestamp values to the database
 *
 * @param idString
 * @param timeStamp
 * @throws org.apache.axis2.AxisFault
 */
private void insertTimeStampToDb(String idString, String timeStamp) throws Exception {
    OMElement payload = fac.createOMElement("insertTimeStamp", omNs);

    OMElement idStringElmnt = fac.createOMElement("idString", omNs);
    idStringElmnt.setText(idString + "");
    payload.addChild(idStringElmnt);

    OMElement timeStampElmnt = fac.createOMElement("testTimeStamp", omNs);
    timeStampElmnt.setText(timeStamp + "");
    payload.addChild(timeStampElmnt);

    new AxisServiceClient().sendRobust(payload, backendUrl + serviceName, "insertTimeStamp");
}
 
Example 28
Source Project: product-ei   Source File: GSpreadDataServiceTestCase.java    License: Apache License 2.0 5 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 29
Source Project: product-ei   Source File: FileServiceTestCase.java    License: 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 30
Source Project: product-ei   Source File: ConcurrencyThrottleTestClient.java    License: Apache License 2.0 5 votes vote down vote up
public ConcurrencyThrottleTestClient(String endpointUri, List list,
                                     ThrottleTestCounter counter) {
    this.endpointUri = endpointUri;
    this.list = list;
    this.counter = counter;
    axis2Client = new AxisServiceClient();
}