use of org.wso2.transport.http.netty.message.HttpMessageDataStreamer in project ballerina by ballerina-lang.
the class UriTemplateBestMatchTest method testStringQueryParam.
@Test(description = "Test suitable method with URL. /echo125?foo=hello ")
public void testStringQueryParam() {
String path = "/hello/echo125?foo=hello";
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("echo125").asText(), "hello", "Resource dispatched to wrong template");
path = "/hello/echo125?foo=";
cMsg = MessageUtils.generateHTTPMessage(path, "GET");
response = Services.invokeNew(application, TEST_EP, cMsg);
Assert.assertNotNull(response, "Response message not found");
bJson = new BJSON(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertEquals(bJson.value().get("echo125").asText(), "", "Resource dispatched to wrong template");
}
use of org.wso2.transport.http.netty.message.HttpMessageDataStreamer in project ballerina by ballerina-lang.
the class UriTemplateBestMatchTest method testServiceRoot.
@Test(description = "Test dispatching with URL. /hello")
public void testServiceRoot() {
String path = "/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("third").asText(), "zzz", "Resource dispatched to wrong template");
Assert.assertEquals(bJson.value().get("echo33").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 testBestMatchWithCapitalizedPathSegments.
@Test(description = "Test whether requests get dispatched to the capitalized resource path.")
public void testBestMatchWithCapitalizedPathSegments() {
String path = "/uri/Go";
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage(path, "POST");
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("value").asText(), "capitalized", "Request dispatched to wrong resource");
}
use of org.wso2.transport.http.netty.message.HttpMessageDataStreamer in project ballerina by ballerina-lang.
the class UriTemplateBestMatchTest method testLeastSpecificURITemplate.
@Test(description = "Test dispatching with URL. /hello/echo2/shafreen+anfar/foo/bar")
public void testLeastSpecificURITemplate() {
String path = "/hello/echo2/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("echo5").asText(), "any", "Resource dispatched to wrong template");
}
use of org.wso2.transport.http.netty.message.HttpMessageDataStreamer in project ballerina by ballerina-lang.
the class UriTemplateBestMatchTest method testMostSpecificServiceDispatch.
@Test(description = "Test dispatching with URL. /hello/echo2?regid=abc")
public void testMostSpecificServiceDispatch() {
String path = "/hello/echo2?regid=abc";
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("echo5").asText(), "echo5", "Resource dispatched to wrong template");
}
Aggregations