Search in sources :

Example 46 with HttpCarbonMessage

use of org.wso2.transport.http.netty.message.HttpCarbonMessage in project ballerina by ballerina-lang.

the class GlobalVarServicePkgTest method testChangeAndAccessGlobalVarInDiffPkg.

@Test(description = "Test change global var in different package and access it", enabled = false)
public void testChangeAndAccessGlobalVarInDiffPkg() {
    HTTPTestRequest cMsgChange = MessageUtils.generateHTTPMessage("/globalvar-pkg/change-global-var-diff-pkg", "GET");
    Services.invokeNew(result, cMsgChange);
    HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage("/globalvar-second-pkg/get-changed-resource-level", "GET");
    HTTPCarbonMessage response = Services.invokeNew(result, cMsg);
    Assert.assertNotNull(response);
    // Expected Json message : {"changeVarFloat":345432.454}
    BJSON bJson = new BJSON(new HttpMessageDataStreamer(response).getInputStream());
    Assert.assertEquals(bJson.value().get("changeVarFloat").asText(), "345432.454");
}
Also used : HTTPCarbonMessage(org.wso2.transport.http.netty.message.HTTPCarbonMessage) HttpMessageDataStreamer(org.wso2.transport.http.netty.message.HttpMessageDataStreamer) HTTPTestRequest(org.ballerinalang.test.services.testutils.HTTPTestRequest) BJSON(org.ballerinalang.model.values.BJSON) Test(org.testng.annotations.Test)

Example 47 with HttpCarbonMessage

use of org.wso2.transport.http.netty.message.HttpCarbonMessage in project ballerina by ballerina-lang.

the class GlobalVarServiceTest method testAccessingChangedGlobalVarInAnotherResource.

@Test(description = "Test accessing changed global var in another resource in same service", enabled = false)
public void testAccessingChangedGlobalVarInAnotherResource() {
    HTTPTestRequest cMsgChange = MessageUtils.generateHTTPMessage("/globalvar/change-resource-level", "GET");
    Services.invokeNew(result, cMsgChange);
    HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage("/globalvar/get-changed-resource-level", "GET");
    HTTPCarbonMessage response = Services.invokeNew(result, cMsg);
    Assert.assertNotNull(response);
    // Expected Json message : {"glbVarFloatChange":77.87}
    BJSON bJson = new BJSON(new HttpMessageDataStreamer(response).getInputStream());
    Assert.assertEquals(bJson.value().get("glbVarFloatChange").asText(), "77.87");
}
Also used : HTTPCarbonMessage(org.wso2.transport.http.netty.message.HTTPCarbonMessage) HttpMessageDataStreamer(org.wso2.transport.http.netty.message.HttpMessageDataStreamer) HTTPTestRequest(org.ballerinalang.test.services.testutils.HTTPTestRequest) BJSON(org.ballerinalang.model.values.BJSON) Test(org.testng.annotations.Test)

Example 48 with HttpCarbonMessage

use of org.wso2.transport.http.netty.message.HttpCarbonMessage in project ballerina by ballerina-lang.

the class GlobalVarServiceTest method testAccessingChangedGlobalVarInAnotherResourceInAnotherService.

@Test(description = "Test accessing changed global var in another resource in different service", enabled = false)
public void testAccessingChangedGlobalVarInAnotherResourceInAnotherService() {
    HTTPTestRequest cMsgChange = MessageUtils.generateHTTPMessage("/globalvar/change-resource-level", "GET");
    Services.invokeNew(result, cMsgChange);
    HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage("/globalvar-second/get-changed-resource-level", "GET");
    HTTPCarbonMessage response = Services.invokeNew(result, cMsg);
    Assert.assertNotNull(response);
    // Expected Json message : {"glbVarFloatChange":77.87}
    BJSON bJson = new BJSON(new HttpMessageDataStreamer(response).getInputStream());
    Assert.assertEquals(bJson.value().get("glbVarFloatChange").asText(), "77.87");
}
Also used : HTTPCarbonMessage(org.wso2.transport.http.netty.message.HTTPCarbonMessage) HttpMessageDataStreamer(org.wso2.transport.http.netty.message.HttpMessageDataStreamer) HTTPTestRequest(org.ballerinalang.test.services.testutils.HTTPTestRequest) BJSON(org.ballerinalang.model.values.BJSON) Test(org.testng.annotations.Test)

Example 49 with HttpCarbonMessage

use of org.wso2.transport.http.netty.message.HttpCarbonMessage in project ballerina by ballerina-lang.

the class GlobalVarServiceTest method testDefiningGlobalVarInService.

@Test(description = "Test defining global variables in services", enabled = false)
public void testDefiningGlobalVarInService() {
    HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage("/globalvar/defined", "GET");
    HTTPCarbonMessage response = Services.invokeNew(result, cMsg);
    Assert.assertNotNull(response);
    // Expected Json message : {"glbVarInt":800, "glbVarString":"value", "glbVarFloat":99.34323}
    BJSON bJson = new BJSON(new HttpMessageDataStreamer(response).getInputStream());
    Assert.assertEquals(bJson.value().get("glbVarInt").asText(), "800");
    Assert.assertEquals(bJson.value().get("glbVarString").asText(), "value");
    Assert.assertEquals(bJson.value().get("glbVarFloat").asText(), "99.34323");
}
Also used : HTTPCarbonMessage(org.wso2.transport.http.netty.message.HTTPCarbonMessage) HttpMessageDataStreamer(org.wso2.transport.http.netty.message.HttpMessageDataStreamer) HTTPTestRequest(org.ballerinalang.test.services.testutils.HTTPTestRequest) BJSON(org.ballerinalang.model.values.BJSON) Test(org.testng.annotations.Test)

Example 50 with HttpCarbonMessage

use of org.wso2.transport.http.netty.message.HttpCarbonMessage in project ballerina by ballerina-lang.

the class GlobalVarServiceTest method testAccessingGlobalVarInServiceLevel.

@Test(description = "Test accessing global variables in service level", enabled = false)
public void testAccessingGlobalVarInServiceLevel() {
    HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage("/globalvar/access-service-level", "GET");
    HTTPCarbonMessage response = Services.invokeNew(result, cMsg);
    Assert.assertNotNull(response);
    // Expected Json message : {"serviceVarFloat":99.34323}
    BJSON bJson = new BJSON(new HttpMessageDataStreamer(response).getInputStream());
    Assert.assertEquals(bJson.value().get("serviceVarFloat").asText(), "99.34323");
}
Also used : HTTPCarbonMessage(org.wso2.transport.http.netty.message.HTTPCarbonMessage) HttpMessageDataStreamer(org.wso2.transport.http.netty.message.HttpMessageDataStreamer) HTTPTestRequest(org.ballerinalang.test.services.testutils.HTTPTestRequest) BJSON(org.ballerinalang.model.values.BJSON) Test(org.testng.annotations.Test)

Aggregations

HTTPCarbonMessage (org.wso2.transport.http.netty.message.HTTPCarbonMessage)308 Test (org.testng.annotations.Test)247 HTTPTestRequest (org.ballerinalang.test.services.testutils.HTTPTestRequest)233 HttpMessageDataStreamer (org.wso2.transport.http.netty.message.HttpMessageDataStreamer)179 BJSON (org.ballerinalang.model.values.BJSON)108 BString (org.ballerinalang.model.values.BString)45 BStruct (org.ballerinalang.model.values.BStruct)43 Request (org.wso2.msf4j.Request)34 ArrayList (java.util.ArrayList)25 BValue (org.ballerinalang.model.values.BValue)19 Header (org.wso2.carbon.messaging.Header)14 Tracer (org.ballerinalang.util.tracer.Tracer)11 HttpCarbonMessage (org.wso2.transport.http.netty.message.HttpCarbonMessage)10 BallerinaException (org.ballerinalang.util.exceptions.BallerinaException)9 IOException (java.io.IOException)8 ResponseCacheControlStruct (org.ballerinalang.net.http.caching.ResponseCacheControlStruct)7 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)5 Semaphore (java.util.concurrent.Semaphore)5 APIMgtSecurityException (org.wso2.carbon.apimgt.rest.api.common.exception.APIMgtSecurityException)5 DefaultLastHttpContent (io.netty.handler.codec.http.DefaultLastHttpContent)4