use of org.wso2.transport.http.netty.message.HttpCarbonMessage 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.transport.http.netty.message.HttpCarbonMessage in project ballerina by ballerina-lang.
the class HTTPSessionEssentialMethodsTest method testGetSessionWithoutSessionIDCheck.
@Test(description = "Test for getting a session without Id at first time")
public void testGetSessionWithoutSessionIDCheck() {
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage("/sample/test2", "GET");
HTTPCarbonMessage responseMsg = Services.invokeNew(compileResult, TEST_ENDPOINT_NAME, cMsg);
Assert.assertNotNull(responseMsg);
String responseMsgPayload = StringUtils.getStringFromInputStream(new HttpMessageDataStreamer(responseMsg).getInputStream());
Assert.assertNotNull(responseMsgPayload);
Assert.assertEquals(responseMsgPayload, "no session id available");
}
use of org.wso2.transport.http.netty.message.HttpCarbonMessage in project ballerina by ballerina-lang.
the class HTTPSessionEssentialMethodsTest method testCheckPathValidity.
@Test(description = "Test for path limitation")
public void testCheckPathValidity() {
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage("/counter/echo", "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");
String cookie = response.getHeader(RESPONSE_COOKIE_HEADER);
String sessionId = CookieUtils.getCookie(cookie).value;
cMsg = MessageUtils.generateHTTPMessage("/sample2/echoName", "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.assertTrue(responseMsgPayload.contains("failed to get session: /sample2 is not an allowed path"));
}
use of org.wso2.transport.http.netty.message.HttpCarbonMessage in project ballerina by ballerina-lang.
the class HTTPSessionEssentialMethodsTest method testGetSessionMethod.
@Test(description = "Test for not getting a session with at first time")
public void testGetSessionMethod() {
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage("/sample/test3", "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, "session is not created");
}
use of org.wso2.transport.http.netty.message.HttpCarbonMessage in project ballerina by ballerina-lang.
the class HTTPSessionEssentialMethodsTest method testNullSessionWithGetSession.
@Test(description = "Test for null session with getsession")
public void testNullSessionWithGetSession() {
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage("/sample/test5", "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, "testValue");
}
Aggregations