use of org.ballerinalang.test.services.testutils.HTTPTestRequest 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.ballerinalang.test.services.testutils.HTTPTestRequest 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");
}
use of org.ballerinalang.test.services.testutils.HTTPTestRequest in project ballerina by ballerina-lang.
the class HTTPSessionEssentialMethodsTest method testGetSessionWithMultipleCookies.
@Test(description = "Test getting a session with multiple cookies")
public void testGetSessionWithMultipleCookies() {
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage("/sample/test1", "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 created");
String cookie = response.getHeader(RESPONSE_COOKIE_HEADER);
String sessionId = CookieUtils.getCookie(cookie).value;
cMsg = MessageUtils.generateHTTPMessage("/sample/test2", "GET");
cMsg.setHeader(COOKIE_HEADER, "A=5454252; " + SESSION_ID + sessionId + "; JSESSIONID=5454252");
response = Services.invokeNew(compileResult, TEST_ENDPOINT_NAME, cMsg);
Assert.assertNotNull(response);
responseMsgPayload = StringUtils.getStringFromInputStream(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertNotNull(responseMsgPayload);
Assert.assertEquals(responseMsgPayload, "session is returned");
}
use of org.ballerinalang.test.services.testutils.HTTPTestRequest 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.ballerinalang.test.services.testutils.HTTPTestRequest 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");
}
Aggregations