use of org.wso2.siddhi.query.api.annotation.Annotation in project ballerina by ballerina-lang.
the class ProducesConsumesAnnotationTest method testWithoutProducesConsumeAnnotation.
@Test(description = "Test without Pro-Con annotation with URL. /echo67/echo1 ")
public void testWithoutProducesConsumeAnnotation() {
String path = "/echo67/echo1";
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage(path, "GET");
cMsg.setHeader(HttpHeaderNames.CONTENT_TYPE.toString(), "text/plain; charset=ISO-8859-4");
cMsg.setHeader(HttpHeaderNames.ACCEPT.toString(), "text/*;q=0.3, text/html;Level=1;q=0.7");
HTTPCarbonMessage response = Services.invokeNew(compileResult, TEST_EP, cMsg);
Assert.assertNotNull(response, "Response message not found");
BJSON bJson = new BJSON(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertEquals(bJson.value().get("echo33").asText(), "echo1", "No media types");
}
use of org.wso2.siddhi.query.api.annotation.Annotation in project ballerina by ballerina-lang.
the class ProducesConsumesAnnotationTest method testProducesAnnotation.
@Test(description = "Test Produces annotation with URL. /echo66/test2 ")
public void testProducesAnnotation() {
String path = "/echo66/test2";
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage(path, "GET");
cMsg.setHeader(HttpHeaderNames.ACCEPT.toString(), "text/xml;q=0.3, multipart/*;Level=1;q=0.7");
HTTPCarbonMessage response = Services.invokeNew(compileResult, TEST_EP, cMsg);
Assert.assertNotNull(response, "Response message not found");
BJSON bJson = new BJSON(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertEquals(bJson.value().get("msg").asText(), "wso22", "media type matched");
}
use of org.wso2.siddhi.query.api.annotation.Annotation in project ballerina by ballerina-lang.
the class ProducesConsumesAnnotationTest method testIncorrectConsumesAnnotation.
@Test(description = "Test incorrect Consumes annotation with URL. /echo66/test1 ")
public void testIncorrectConsumesAnnotation() {
String path = "/echo66/test1";
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage(path, "POST", "Test");
cMsg.setHeader(HttpHeaderNames.CONTENT_TYPE.toString(), "compileResult/json");
HTTPCarbonMessage response = Services.invokeNew(compileResult, TEST_EP, cMsg);
Assert.assertNotNull(response, "Response message not found");
int trueResponse = (int) response.getProperty(HttpConstants.HTTP_STATUS_CODE);
Assert.assertEquals(trueResponse, 415, "Unsupported media type");
}
use of org.wso2.siddhi.query.api.annotation.Annotation in project ballerina by ballerina-lang.
the class ProducesConsumesAnnotationTest method testBogusConsumesAnnotation.
@Test(description = "Test bogus Consumes annotation with URL. /echo66/test1 ")
public void testBogusConsumesAnnotation() {
String path = "/echo66/test1";
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage(path, "POST", "Test");
cMsg.setHeader(HttpHeaderNames.CONTENT_TYPE.toString(), ",:vhjv");
HTTPCarbonMessage response = Services.invokeNew(compileResult, TEST_EP, cMsg);
Assert.assertNotNull(response, "Response message not found");
int trueResponse = (int) response.getProperty(HttpConstants.HTTP_STATUS_CODE);
Assert.assertEquals(trueResponse, 415, "Unsupported media type");
}
use of org.wso2.siddhi.query.api.annotation.Annotation in project ballerina by ballerina-lang.
the class UriTemplateDefaultDispatcherTest method testServiceNameDispatchingWhenAnnotationUnavailable.
@Test(description = "Test dispatching with Service name when annotation is not available")
public void testServiceNameDispatchingWhenAnnotationUnavailable() {
String path = "/serviceWithNoAnnotation/test1";
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("echo").asText(), "dispatched to a service without an annotation", "Resource dispatched to wrong template");
}
Aggregations