use of org.ballerinalang.test.services.testutils.HTTPTestRequest in project ballerina by ballerina-lang.
the class ResponseNativeFunctionSuccessTest method testServiceGetXmlPayload.
@Test(description = "Test GetXmlPayload function within a service")
public void testServiceGetXmlPayload() {
String value = "ballerina";
String path = "/hello/GetXmlPayload";
HTTPTestRequest inRequestMsg = MessageUtils.generateHTTPMessage(path, HttpConstants.HTTP_METHOD_GET);
HTTPCarbonMessage response = Services.invokeNew(serviceResult, MOCK_ENDPOINT_NAME, inRequestMsg);
Assert.assertNotNull(response, "Response message not found");
String returnvalue = StringUtils.getStringFromInputStream(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertEquals(returnvalue, value);
}
use of org.ballerinalang.test.services.testutils.HTTPTestRequest in project ballerina by ballerina-lang.
the class ResponseNativeFunctionSuccessTest method testServiceRemoveAllHeaders.
@Test(description = "Test RemoveAllHeaders function within a service")
public void testServiceRemoveAllHeaders() {
String path = "/hello/RemoveAllHeaders";
HTTPTestRequest inRequestMsg = MessageUtils.generateHTTPMessage(path, HttpConstants.HTTP_METHOD_GET);
HTTPCarbonMessage response = Services.invokeNew(serviceResult, MOCK_ENDPOINT_NAME, inRequestMsg);
Assert.assertNotNull(response, "Response message not found");
BJSON bJson = new BJSON(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertEquals(bJson.value().get("value").asText(), "value is null");
}
use of org.ballerinalang.test.services.testutils.HTTPTestRequest in project ballerina by ballerina-lang.
the class ResponseNativeFunctionSuccessTest method testServiceAddHeader.
@Test(description = "Test addHeader function within a service")
public void testServiceAddHeader() {
String key = "lang";
String value = "ballerina";
String path = "/hello/addheader/" + key + "/" + value;
HTTPTestRequest inRequestMsg = MessageUtils.generateHTTPMessage(path, HttpConstants.HTTP_METHOD_GET);
HTTPCarbonMessage response = Services.invokeNew(serviceResult, MOCK_ENDPOINT_NAME, inRequestMsg);
Assert.assertNotNull(response, "Response message not found");
BJSON bJson = new BJSON(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertEquals(bJson.value().get(key).asText(), value);
}
use of org.ballerinalang.test.services.testutils.HTTPTestRequest in project ballerina by ballerina-lang.
the class ResponseNativeFunctionSuccessTest method testServiceGetStringPayload.
@Test(description = "Test GetStringPayload function within a service")
public void testServiceGetStringPayload() {
String value = "ballerina";
String path = "/hello/GetStringPayload/" + value;
HTTPTestRequest inRequestMsg = MessageUtils.generateHTTPMessage(path, HttpConstants.HTTP_METHOD_GET);
HTTPCarbonMessage response = Services.invokeNew(serviceResult, MOCK_ENDPOINT_NAME, inRequestMsg);
Assert.assertNotNull(response, "Response message not found");
Assert.assertEquals(StringUtils.getStringFromInputStream(new HttpMessageDataStreamer(response).getInputStream()), value);
}
use of org.ballerinalang.test.services.testutils.HTTPTestRequest in project ballerina by ballerina-lang.
the class ResponseNativeFunctionSuccessTest method testForwardMethod.
@Test
public void testForwardMethod() {
String path = "/hello/11";
HTTPTestRequest inRequestMsg = MessageUtils.generateHTTPMessage(path, HttpConstants.HTTP_METHOD_GET);
HTTPCarbonMessage response = Services.invokeNew(serviceResult, MOCK_ENDPOINT_NAME, inRequestMsg);
Assert.assertNotNull(response, "Response message not found");
}
Aggregations