use of org.ballerinalang.test.services.testutils.HTTPTestRequest in project ballerina by ballerina-lang.
the class ServiceTest method testConstantValueAsAnnAttributeVal.
@Test(description = "Test using constant as annotation attribute value")
public void testConstantValueAsAnnAttributeVal() {
HTTPTestRequest requestMsg = MessageUtils.generateHTTPMessage("/echo/constantPath", "GET");
HTTPCarbonMessage responseMsg = Services.invokeNew(compileResult, TEST_ENDPOINT_NAME, requestMsg);
Assert.assertNotNull(responseMsg);
String responseMsgPayload = StringUtils.getStringFromInputStream(new HttpMessageDataStreamer(responseMsg).getInputStream());
StringDataSource stringDataSource = new StringDataSource(responseMsgPayload);
Assert.assertNotNull(stringDataSource);
Assert.assertEquals(stringDataSource.getValue(), "constant path test");
}
use of org.ballerinalang.test.services.testutils.HTTPTestRequest in project ballerina by ballerina-lang.
the class ServiceTest method testGetString.
@Test(dependsOnMethods = "testSetString")
public void testGetString() {
HTTPTestRequest requestMsg = MessageUtils.generateHTTPMessage("/echo/getString", "GET");
HTTPCarbonMessage responseMsg = Services.invokeNew(compileResult, TEST_ENDPOINT_NAME, requestMsg);
Assert.assertNotNull(responseMsg);
String responseMsgPayload = StringUtils.getStringFromInputStream(new HttpMessageDataStreamer(responseMsg).getInputStream());
Assert.assertNotNull(responseMsgPayload);
Assert.assertEquals(responseMsgPayload, "hello");
}
use of org.ballerinalang.test.services.testutils.HTTPTestRequest in project ballerina by ballerina-lang.
the class ServiceTest method testGetFormParamsNativeFunction.
@Test(description = "Test GetFormParams Native Function")
public void testGetFormParamsNativeFunction() {
String path = "/echo/getFormParams";
HTTPTestRequest requestMsg = MessageUtils.generateHTTPMessage(path, "POST", "firstName=WSO2&team=BalDance");
requestMsg.setHeader(HttpHeaderNames.CONTENT_TYPE.toString(), APPLICATION_FORM);
HTTPCarbonMessage responseMsg = Services.invokeNew(compileResult, TEST_ENDPOINT_NAME, requestMsg);
Assert.assertNotNull(responseMsg, "responseMsg message not found");
BJSON bJson = new BJSON(new HttpMessageDataStreamer(responseMsg).getInputStream());
Assert.assertEquals(bJson.value().get("Name").asText(), "WSO2", "Name variable not set properly.");
Assert.assertEquals(bJson.value().get("Team").asText(), "BalDance", "Team variable not set properly.");
}
use of org.ballerinalang.test.services.testutils.HTTPTestRequest in project ballerina by ballerina-lang.
the class ServiceTest method testRemoveHeadersNativeFunction.
@Test(description = "Test remove headers native function")
public void testRemoveHeadersNativeFunction() {
HTTPTestRequest requestMsg = MessageUtils.generateHTTPMessage("/echo/removeHeaders", "GET");
HTTPCarbonMessage responseMsg = Services.invokeNew(compileResult, TEST_ENDPOINT_NAME, requestMsg);
Assert.assertNotNull(responseMsg);
Assert.assertNull(responseMsg.getHeader("header1"));
Assert.assertNull(responseMsg.getHeader("header2"));
Assert.assertNull(responseMsg.getHeader("header3"));
}
use of org.ballerinalang.test.services.testutils.HTTPTestRequest in project ballerina by ballerina-lang.
the class ServiceTest method testServiceDispatchingWithWorker.
@Test
public void testServiceDispatchingWithWorker() {
HTTPTestRequest requestMsg = MessageUtils.generateHTTPMessage("/echo/message_worker", "GET");
HTTPCarbonMessage responseMsg = Services.invokeNew(compileResult, TEST_ENDPOINT_NAME, requestMsg);
Assert.assertNotNull(responseMsg);
}
Aggregations