Java Code Examples for org.wso2.carbon.automation.test.utils.http.client.HttpResponse#getData()

The following examples show how to use org.wso2.carbon.automation.test.utils.http.client.HttpResponse#getData() . 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: LastQueryParamEmptyTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * This test method verify last query param empty return expected response for given resource template
 * <p>
 * Resource - /pattern3/*
 *
 * @throws Exception
 */
@Test(groups = { "wso2.esb" })
public void testResourcePattern3WithLastParameterEmpty() throws Exception {
    HttpResponse response = HttpRequestUtil.sendGetRequest(
            getApiInvocationURL("last-query-param-empty/pattern3/sample?latitude=10&longitude=20&floor="), null);
    Assert.assertNotNull(response);
    int responseCode = response.getResponseCode();
    String responseData = response.getData();
    Assert.assertEquals(responseCode, 200);
    Assert.assertEquals(responseData, "<m:checkQueryParam xmlns:m=\"http://services.samples/xsd\">"
            + "<m:latitude>10</m:latitude><m:longitude>20</m:longitude><m:floor/></m:checkQueryParam>");
}
 
Example 2
Source File: LastQueryParamEmptyTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * This test method verify last query param empty return expected response for given resource template
 *
 * Resource - /pattern3/*
 *
 * @throws Exception
 */
@Test(groups = { "wso2.esb" })
public void testResourcePattern3WithLastParameterEmpty() throws Exception {
    HttpResponse response = HttpRequestUtil.sendGetRequest(
            getApiInvocationURL("last-query-param-empty/pattern3/sample?latitude=10&longitude=20&floor="),
            null);
    Assert.assertNotNull(response);
    int responseCode = response.getResponseCode();
    String responseData = response.getData();
    Assert.assertEquals(responseCode, 200);
    Assert.assertEquals(responseData, "<m:checkQueryParam xmlns:m=\"http://services.samples/xsd\">" +
            "<m:latitude>10</m:latitude><m:longitude>20</m:longitude><m:floor/></m:checkQueryParam>");
}
 
Example 3
Source File: LastQueryParamEmptyTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * This test method verify last query param empty and missing equal sign return expected response for given
 * resource template
 * <p>
 * Resource - /pattern1?latitude={+latitude}&longitude={+longitude}&floor={+floor}
 *
 * @throws Exception
 */
@Test(groups = { "wso2.esb" })
public void testResourcePattern1WithLastParameterEmptyAndMissingEqualSign() throws Exception {
    HttpResponse response = HttpRequestUtil
            .sendGetRequest(getApiInvocationURL("last-query-param-empty/pattern1?latitude=10&longitude=20&floor"),
                    null);
    Assert.assertNotNull(response);
    int responseCode = response.getResponseCode();
    String responseData = response.getData();
    Assert.assertEquals(responseCode, 404);
}
 
Example 4
Source File: LastQueryParamEmptyTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * This test method verify second query param empty return expected response for given resource template
 * <p>
 * Resource - /pattern1?latitude={+latitude}&longitude={+longitude}&floor={+floor}
 *
 * @throws Exception
 */
@Test(groups = { "wso2.esb" })
public void testResourcePattern1WithSecondtParameterEmpty() throws Exception {
    HttpResponse response = HttpRequestUtil
            .sendGetRequest(getApiInvocationURL("last-query-param-empty/pattern1?latitude=10&longitude=&floor=30"),
                    null);
    Assert.assertNotNull(response);
    int responseCode = response.getResponseCode();
    String responseData = response.getData();
    Assert.assertEquals(responseCode, 200);
    Assert.assertEquals(responseData, "<m:checkQueryParam xmlns:m=\"http://services.samples/xsd\">"
            + "<m:latitude>10</m:latitude><m:longitude/><m:floor>30</m:floor></m:checkQueryParam>");
}
 
Example 5
Source File: LastQueryParamEmptyTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * This test method verify last query param empty and missing equal sign return expected response for given
 * resource template
 *
 * Resource - /pattern2*
 *
 * @throws Exception
 */
@Test(groups = { "wso2.esb" })
public void testResourcePattern2WithLastParameterEmptyAndMissingEqualSign() throws Exception {
    HttpResponse response = HttpRequestUtil.sendGetRequest(
            getApiInvocationURL("last-query-param-empty/pattern2?latitude=10&longitude=20&floor"),
            null);
    Assert.assertNotNull(response);
    int responseCode = response.getResponseCode();
    String responseData = response.getData();
    Assert.assertEquals(responseCode, 200);
    Assert.assertEquals(responseData, "<m:checkQueryParam xmlns:m=\"http://services.samples/xsd\">" +
            "<m:latitude>10</m:latitude><m:longitude>20&amp;floor</m:longitude><m:floor/></m:checkQueryParam>",
            "Query Parameter isn't evaluated according the standard");
}
 
Example 6
Source File: LastQueryParamEmptyTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * This test method verify last query param empty return expected response for given resource template
 * <p>
 * Resource - /pattern1?latitude={+latitude}&longitude={+longitude}&floor={+floor}
 *
 * @throws Exception
 */
@Test(groups = { "wso2.esb" })
public void testResourcePattern1WithLastParameterEmpty() throws Exception {
    HttpResponse response = HttpRequestUtil
            .sendGetRequest(getApiInvocationURL("last-query-param-empty/pattern1?latitude=10&longitude=20&floor="),
                    null);
    Assert.assertNotNull(response);
    int responseCode = response.getResponseCode();
    String responseData = response.getData();
    Assert.assertEquals(responseCode, 200);
    Assert.assertEquals(responseData, "<m:checkQueryParam xmlns:m=\"http://services.samples/xsd\">"
            + "<m:latitude>10</m:latitude><m:longitude>20</m:longitude><m:floor/></m:checkQueryParam>");
}
 
Example 7
Source File: LastQueryParamEmptyTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * This test method verify all query params return expected response for given resource template
 * <p>
 * Resource - /pattern1?latitude={+latitude}&longitude={+longitude}&floor={+floor}
 *
 * @throws Exception
 */
@Test(groups = { "wso2.esb" })
public void testResourcePattern1WithParameters() throws Exception {
    HttpResponse response = HttpRequestUtil.sendGetRequest(
            getApiInvocationURL("last-query-param-empty/pattern1?latitude=10&longitude=20&floor=30"), null);
    Assert.assertNotNull(response);
    int responseCode = response.getResponseCode();
    String responseData = response.getData();
    Assert.assertEquals(responseCode, 200);
    Assert.assertEquals(responseData, "<m:checkQueryParam xmlns:m=\"http://services.samples/xsd\">"
            + "<m:latitude>10</m:latitude><m:longitude>20</m:longitude><m:floor>30</m:floor></m:checkQueryParam>");
}
 
Example 8
Source File: LastQueryParamEmptyTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * This test method verify last query param empty and missing equal sign return expected response for given
 * resource template
 *
 * Resource - /pattern1?latitude={+latitude}&longitude={+longitude}&floor={+floor}
 *
 * @throws Exception
 */
@Test(groups = { "wso2.esb" })
public void testResourcePattern1WithLastParameterEmptyAndMissingEqualSign() throws Exception {
    HttpResponse response = HttpRequestUtil.sendGetRequest(
            getApiInvocationURL("last-query-param-empty/pattern1?latitude=10&longitude=20&floor"),
            null);
    Assert.assertNotNull(response);
    int responseCode = response.getResponseCode();
    String responseData = response.getData();
    Assert.assertEquals(responseCode, 404);
}
 
Example 9
Source File: LastQueryParamEmptyTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * This test method verify last query param empty return expected response for given resource template
 *
 * Resource - /pattern1?latitude={+latitude}&longitude={+longitude}&floor={+floor}
 *
 * @throws Exception
 */
@Test(groups = { "wso2.esb" })
public void testResourcePattern1WithLastParameterEmpty() throws Exception {
    HttpResponse response = HttpRequestUtil.sendGetRequest(
            getApiInvocationURL("last-query-param-empty/pattern1?latitude=10&longitude=20&floor="),
            null);
    Assert.assertNotNull(response);
    int responseCode = response.getResponseCode();
    String responseData = response.getData();
    Assert.assertEquals(responseCode, 200);
    Assert.assertEquals(responseData, "<m:checkQueryParam xmlns:m=\"http://services.samples/xsd\">" +
            "<m:latitude>10</m:latitude><m:longitude>20</m:longitude><m:floor/></m:checkQueryParam>");
}
 
Example 10
Source File: LastQueryParamEmptyTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * This test method verify last query param empty and missing equal sign return expected response for given
 * resource template
 * <p>
 * Resource - /pattern3/*
 *
 * @throws Exception
 */
@Test(groups = { "wso2.esb" })
public void testResourcePattern3WithLastParameterEmptyAndMissingEqualSign() throws Exception {
    HttpResponse response = HttpRequestUtil.sendGetRequest(
            getApiInvocationURL("last-query-param-empty/pattern3/sample?latitude=10&longitude=20&floor"), null);
    Assert.assertNotNull(response);
    int responseCode = response.getResponseCode();
    String responseData = response.getData();
    Assert.assertEquals(responseCode, 200);
    Assert.assertEquals(responseData, "<m:checkQueryParam xmlns:m=\"http://services.samples/xsd\">"
                    + "<m:latitude>10</m:latitude><m:longitude>20&amp;floor</m:longitude><m:floor/></m:checkQueryParam>",
            "Query Parameter isn't evaluated according the standard");
}
 
Example 11
Source File: JSONContentTypeHandlerTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private void listProducts(String contentType) throws Exception {
    GenericJSONClient jsonClient = new GenericJSONClient();
    String expectedResult = "{\"Products\":{\"Product\":[{\"quantityInStock\":\"10\",\"productLine\":\"Cars\",\"productCode\":\"N10_1671\",\"buyPrice\":\"45.54\",\"productName\":\"Honda Civic\"},{\"quantityInStock\":\"24\",\"productLine\":\"Cars\",\"productCode\":\"N10_1672\",\"buyPrice\":\"55.64\",\"productName\":\"Honda Accord\"},{\"quantityInStock\":\"30\",\"productLine\":\"Cars\",\"productCode\":\"N10_1673\",\"buyPrice\":\"48.57\",\"productName\":\"Honda Aria\"},{\"quantityInStock\":\"15\",\"productLine\":\"Cars\",\"productCode\":\"N10_1674\",\"buyPrice\":\"35.55\",\"productName\":\"Honda Insight\"},{\"quantityInStock\":\"20\",\"productLine\":\"Cars\",\"productCode\":\"N10_1675\",\"buyPrice\":\"25.58\",\"productName\":\"Honda Airwave\"}]}}";
    HttpResponse response = HttpURLConnectionClient
            .sendGetRequest(this.getServiceEndpoint() + "_getproducts", null, "application/json");
    JSONObject result = new JSONObject(response.getData());
    Assert.assertNotNull(result, "Response is null");
    for (int i = 1; i < 6; i++) {
        Assert.assertTrue(expectedResult.contains(result.toString()), "Expected result not found");
    }
}
 
Example 12
Source File: LastQueryParamEmptyTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * This test method verify last query param empty and missing equal sign return expected response for given
 * resource template
 *
 * Resource - /pattern3/*
 *
 * @throws Exception
 */
@Test(groups = { "wso2.esb" })
public void testResourcePattern3WithLastParameterEmptyAndMissingEqualSign() throws Exception {
    HttpResponse response = HttpRequestUtil.sendGetRequest(
            getApiInvocationURL("last-query-param-empty/pattern3/sample?latitude=10&longitude=20&floor"),
            null);
    Assert.assertNotNull(response);
    int responseCode = response.getResponseCode();
    String responseData = response.getData();
    Assert.assertEquals(responseCode, 200);
    Assert.assertEquals(responseData, "<m:checkQueryParam xmlns:m=\"http://services.samples/xsd\">" +
            "<m:latitude>10</m:latitude><m:longitude>20&amp;floor</m:longitude><m:floor/></m:checkQueryParam>",
            "Query Parameter isn't evaluated according the standard");
}
 
Example 13
Source File: CARBON15046JsonGsonNUllValueTest.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = { "wso2.dss" }, description = "Check whether the null received successfully", alwaysRun = true)
public void returnNullValueInJsonObjectsOnGETTestCase() throws Exception {
    HttpResponse response = this.getHttpResponse(serviceEndPoint + "_getbird", "application/json");
    JSONObject result = new JSONObject(response.getData());
    assertNotNull(result, "Response is null");
    //Response JSON object will be {"Birds":{"Bird":[{"weight":"30","color":null,"name":"Bird1"}]}}
    JSONArray bidsList = (JSONArray) ((JSONObject) result.get("Birds")).get("Bird");
    JSONObject birdDetails = (JSONObject) bidsList.get(0);
    assertTrue(birdDetails.isNull("color"), "Null value retrieved successful");
    log.info("Null value retrieved from GET successful");
}
 
Example 14
Source File: LastQueryParamEmptyTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * This test method verify all query params empty return expected response for given resource template
 *
 * Resource - /pattern1?latitude={+latitude}&longitude={+longitude}&floor={+floor}
 *
 * @throws Exception
 */
@Test(groups = { "wso2.esb" })
public void testResourcePattern1WithAllParametersEmpty() throws Exception {
    HttpResponse response = HttpRequestUtil.sendGetRequest(
            getApiInvocationURL("last-query-param-empty/pattern1?latitude=&longitude=&floor="),
            null);
    Assert.assertNotNull(response);
    int responseCode = response.getResponseCode();
    String responseData = response.getData();
    Assert.assertEquals(responseCode, 200);
    Assert.assertEquals(responseData, "<m:checkQueryParam xmlns:m=\"http://services.samples/xsd\">" +
            "<m:latitude/><m:longitude/><m:floor/></m:checkQueryParam>");
}
 
Example 15
Source File: DS1186JsonRenderTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Test(groups = {
        "wso2.dss" }, description = "Check whether the JSON render service works when there is '&'", alwaysRun = true)
public void jsonRenderWithSecurity() throws Exception {
    HttpResponse response = this.getHttpResponse(serviceEndPoint + "status", "application/json");
    String receivedResult = response.getData();
    String expectedResult = "{\"Entries\":{\"Entry\":[{\"status\":\"1 & 2\"}]}}";
    Assert.assertNotNull(receivedResult, "Response is null");
    Assert.assertTrue(expectedResult.equals(receivedResult.toString()), "Expected result not found");
}
 
Example 16
Source File: DBMediatorUseTransaction.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
private String getDatabaseResultsForDB1() throws MalformedURLException, AutomationFrameworkException {
    HttpResponse httpResponse = HttpRequestUtil
            .doPost(new URL(getApiInvocationURL(API_URL + TEST_CONTEXT_1 + "?testEntry=IBM")), "");
    return httpResponse.getData();
}
 
Example 17
Source File: DBMediatorUseTransaction.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
private String getDatabaseResultsForDB1FailCase() throws MalformedURLException, AutomationFrameworkException {
    HttpResponse httpResponse = HttpRequestUtil
            .doPost(new URL(getApiInvocationURL(API_URL + TEST_CONTEXT_1 + "?testEntry=SUN")), "");
    return httpResponse.getData();
}
 
Example 18
Source File: DBMediatorUseTransaction.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
private String getDatabaseResultsForDB2() throws MalformedURLException, AutomationFrameworkException {
    HttpResponse httpResponse = HttpRequestUtil
            .doPost(new URL(getApiInvocationURL(API_URL + TEST_CONTEXT_2 + "?testEntry=IBM")), "");
    return httpResponse.getData();
}
 
Example 19
Source File: DBMediatorUseTransaction.java    From product-ei with Apache License 2.0 4 votes vote down vote up
private String getDatabaseResultsForDB1() throws MalformedURLException, AutomationFrameworkException {
    HttpResponse httpResponse = HttpRequestUtil.doPost(new URL(getApiInvocationURL(API_URL + TEST_CONTEXT_1
            + "?testEntry=IBM")), "");
    return httpResponse.getData();
}
 
Example 20
Source File: DBMediatorUseTransaction.java    From product-ei with Apache License 2.0 4 votes vote down vote up
private String getDatabaseResultsForDB2() throws MalformedURLException, AutomationFrameworkException {
    HttpResponse httpResponse = HttpRequestUtil.doPost(new URL(getApiInvocationURL(API_URL + TEST_CONTEXT_2
            + "?testEntry=IBM")), "");
    return httpResponse.getData();
}