use of org.wso2.carbon.apimgt.core.models.Function 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.wso2.carbon.apimgt.core.models.Function in project ballerina by ballerina-lang.
the class HTTPSessionEssentialMethodsTest method testGetAttributeNamesFunction.
@Test(description = "Test for getAttributeNames function")
public void testGetAttributeNamesFunction() {
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage("/sample2/names", "GET");
HTTPCarbonMessage response = Services.invokeNew(compileResult, TEST_ENDPOINT_NAME, cMsg);
Assert.assertNotNull(response);
String responseMsgPayload = StringUtils.getStringFromInputStream(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertNotNull(responseMsgPayload);
Assert.assertEquals(responseMsgPayload, "arraysize:2");
}
use of org.wso2.carbon.apimgt.core.models.Function in project ballerina by ballerina-lang.
the class HTTPSessionEssentialMethodsTest method testRemoveAttributeFunctionForUnavailableAttribute.
@Test(description = "Test for removeAttribute function for unavailable attributes")
public void testRemoveAttributeFunctionForUnavailableAttribute() {
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage("/sample2/names6", "GET");
HTTPCarbonMessage response = Services.invokeNew(compileResult, TEST_ENDPOINT_NAME, cMsg);
Assert.assertNotNull(response);
String responseMsgPayload = StringUtils.getStringFromInputStream(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertNotNull(responseMsgPayload);
Assert.assertEquals(responseMsgPayload, "1");
}
use of org.wso2.carbon.apimgt.core.models.Function in project ballerina by ballerina-lang.
the class HTTPSessionEssentialMethodsTest method testNullGetAttributeNamesFunction.
@Test(description = "Test for null attributes from getAttributeNames function")
public void testNullGetAttributeNamesFunction() {
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage("/sample2/names5", "GET");
HTTPCarbonMessage response = Services.invokeNew(compileResult, TEST_ENDPOINT_NAME, cMsg);
Assert.assertNotNull(response);
String responseMsgPayload = StringUtils.getStringFromInputStream(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertNotNull(responseMsgPayload);
Assert.assertEquals(responseMsgPayload, "0");
}
use of org.wso2.carbon.apimgt.core.models.Function in project ballerina by ballerina-lang.
the class HTTPSessionEssentialMethodsTest method testGetAttributeFunction.
@Test(description = "Test for Get Attribute Function")
public void testGetAttributeFunction() {
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage("/sample/test4", "GET");
HTTPCarbonMessage response = Services.invokeNew(compileResult, TEST_ENDPOINT_NAME, cMsg);
Assert.assertNotNull(response);
String responseMsgPayload = StringUtils.getStringFromInputStream(new HttpMessageDataStreamer(response).getInputStream());
;
Assert.assertNotNull(responseMsgPayload);
Assert.assertEquals(responseMsgPayload, "attribute not available");
}
Aggregations