use of org.wso2.transport.http.netty.message.HttpMessageDataStreamer in project ballerina by ballerina-lang.
the class HTTPSessionSubMethodsTest method testGetCreateTimeFunctionError.
@Test(description = "Test for GetCreateTime Function error")
public void testGetCreateTimeFunctionError() {
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage("/sample2/new3", "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.assertTrue(responseMsgPayload.contains("No such session in progress"));
}
use of org.wso2.transport.http.netty.message.HttpMessageDataStreamer in project ballerina by ballerina-lang.
the class HTTPSessionSubMethodsTest method testIsNewFunctiontwoAttempts.
@Test(description = "Test for isNew Function two attempts")
public void testIsNewFunctiontwoAttempts() {
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage("/sample2/new1", "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, "true");
String cookie = response.getHeader(RESPONSE_COOKIE_HEADER);
String sessionId = CookieUtils.getCookie(cookie).value;
cMsg = MessageUtils.generateHTTPMessage("/sample2/new1", "GET");
cMsg.setHeader(COOKIE_HEADER, SESSION_ID + sessionId);
response = Services.invokeNew(compileResult, TEST_ENDPOINT_NAME, cMsg);
Assert.assertNotNull(response);
responseMsgPayload = StringUtils.getStringFromInputStream(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertNotNull(responseMsgPayload);
Assert.assertEquals(responseMsgPayload, "false");
}
use of org.wso2.transport.http.netty.message.HttpMessageDataStreamer in project ballerina by ballerina-lang.
the class HTTPSessionSubMethodsTest method testGetLastAccessedTimeFunctionError.
@Test(description = "Test for GetLastAccessed Function error")
public void testGetLastAccessedTimeFunctionError() {
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage("/sample2/new5", "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.assertTrue(responseMsgPayload.contains("No such session in progress"));
}
use of org.wso2.transport.http.netty.message.HttpMessageDataStreamer in project ballerina by ballerina-lang.
the class ServiceTest method testGetFormParamsEmptyresponseMsgPayload.
@Test(description = "Test GetFormParams empty responseMsgPayloads")
public void testGetFormParamsEmptyresponseMsgPayload() {
String path = "/echo/getFormParams";
HTTPTestRequest requestMsg = MessageUtils.generateHTTPMessage(path, "POST", "");
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.assertNotNull(bJson);
Assert.assertNull(bJson.value().get("Name").stringValue());
Assert.assertNull(bJson.value().get("Team").stringValue());
}
use of org.wso2.transport.http.netty.message.HttpMessageDataStreamer in project ballerina by ballerina-lang.
the class ServiceTest method testGetFormParamsForUndefinedKey.
@Test(description = "Test GetFormParams with undefined key")
public void testGetFormParamsForUndefinedKey() {
String path = "/echo/getFormParams";
HTTPTestRequest requestMsg = MessageUtils.generateHTTPMessage(path, "POST", "firstName=WSO2&company=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.assertTrue(bJson.value().get("Team").isNull(), "Team variable not set properly.");
}
Aggregations