use of org.wso2.transport.http.netty.message.HttpMessageDataStreamer in project ballerina by ballerina-lang.
the class UriTemplateBestMatchTest method testParamDefaultValues.
@Test(description = "Test dispatching with URL. /hello/echo2/shafreen+anfar/bar")
public void testParamDefaultValues() {
String path = "/hello/echo3/shafreen+anfar?foo=bar";
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage(path, "GET");
HTTPCarbonMessage response = Services.invokeNew(application, TEST_EP, cMsg);
Assert.assertNotNull(response, "Response message not found");
BJSON bJson = new BJSON(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertEquals(bJson.value().get("first").asText(), "shafreen anfar", "Resource dispatched to wrong template");
Assert.assertEquals(bJson.value().get("second").asText(), "bar", "Resource dispatched to wrong template");
Assert.assertEquals(bJson.value().get("echo9").asText(), "echo9", "Resource dispatched to wrong template");
}
use of org.wso2.transport.http.netty.message.HttpMessageDataStreamer in project ballerina by ballerina-lang.
the class UriTemplateBestMatchTest method testSubPathEndsWithBar.
@Test(description = "Test dispatching with URL. /hello/echo2/shafreen+anfar/bar")
public void testSubPathEndsWithBar() {
String path = "/hello/echo2/shafreen+anfar/bar";
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage(path, "GET");
HTTPCarbonMessage response = Services.invokeNew(application, TEST_EP, cMsg);
Assert.assertNotNull(response, "Response message not found");
BJSON bJson = new BJSON(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertEquals(bJson.value().get("first").asText(), "shafreen anfar", "Resource dispatched to wrong template");
Assert.assertEquals(bJson.value().get("echo4").asText(), "echo4", "Resource dispatched to wrong template");
}
use of org.wso2.transport.http.netty.message.HttpMessageDataStreamer in project ballerina by ballerina-lang.
the class UriTemplateBestMatchTest method testAllDefaultValues.
@Test(description = "Test dispatching with all default values")
public void testAllDefaultValues() {
String path = "/echo44/echo1?foo=zzz";
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage(path, "GET");
HTTPCarbonMessage response = Services.invokeNew(application, TEST_EP, cMsg);
Assert.assertNotNull(response, "Response message not found");
BJSON bJson = new BJSON(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertEquals(bJson.value().get("first").asText(), "zzz", "Resource dispatched to wrong template");
Assert.assertEquals(bJson.value().get("echo44").asText(), "echo1", "Resource dispatched to wrong template");
}
use of org.wso2.transport.http.netty.message.HttpMessageDataStreamer in project ballerina by ballerina-lang.
the class UriTemplateBestMatchTest method testRootPathDefaultValues.
@Test(description = "Test dispatching with URL. /hello")
public void testRootPathDefaultValues() {
String path = "/hello?foo=zzz";
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage(path, "GET");
HTTPCarbonMessage response = Services.invokeNew(application, TEST_EP, cMsg);
Assert.assertNotNull(response, "Response message not found");
BJSON bJson = new BJSON(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertEquals(bJson.value().get("third").asText(), "zzz", "Resource dispatched to wrong template");
Assert.assertEquals(bJson.value().get("echo10").asText(), "echo10", "Resource dispatched to wrong template");
}
use of org.wso2.transport.http.netty.message.HttpMessageDataStreamer in project ballerina by ballerina-lang.
the class UriTemplateBestMatchTest method testMatchWithWildCard.
@Test(description = "Test whether requests get dispatch to the correct resource.")
public void testMatchWithWildCard() {
String path = "/uri/123";
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage(path, "GET");
HTTPCarbonMessage response = Services.invokeNew(application, TEST_EP, cMsg);
Assert.assertNotNull(response, "Response message not found.");
BJSON bJson = new BJSON(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertEquals(bJson.value().get("message").asText(), "Wildcard Params Resource is invoked.", "Request dispatched to wrong resource");
}
Aggregations