use of org.wso2.transport.http.netty.message.HttpMessageDataStreamer 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");
}
use of org.wso2.transport.http.netty.message.HttpMessageDataStreamer 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");
}
use of org.wso2.transport.http.netty.message.HttpMessageDataStreamer 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");
}
use of org.wso2.transport.http.netty.message.HttpMessageDataStreamer 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");
}
use of org.wso2.transport.http.netty.message.HttpMessageDataStreamer in project ballerina by ballerina-lang.
the class LocksInServicesTest method testServiceLvlVarLockComplex.
@Test(description = "Test locking service level variable complex", enabled = false)
public void testServiceLvlVarLockComplex() {
Semaphore semaphore = new Semaphore(-11);
ExecutorService executor = TestThreadPool.getInstance().getExecutor();
for (int i = 0; i < 4; i++) {
executor.submit(new TestRequestSender(compileResult, semaphore, "/sample1/echo"));
executor.submit(new TestRequestSender(compileResult, semaphore, "/sample1/echo1"));
executor.submit(new TestRequestSender(compileResult, semaphore, "/sample1/echo2"));
}
try {
if (!semaphore.tryAcquire(10, TimeUnit.MINUTES)) {
Assert.fail("request execution not finished within 2s");
}
String path = "/sample1/getResult";
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage(path, "GET");
HTTPCarbonMessage response = Services.invokeNew(compileResult, cMsg);
Assert.assertNotNull(response, "Response message not found");
String responseMsgPayload = StringUtils.getStringFromInputStream(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertEquals(responseMsgPayload, "3333333333331224.01455555555555513.026.0777777777777", "incorrect request count");
} catch (InterruptedException e) {
Assert.fail("thread interrupted before request execution finished - " + e.getMessage(), e);
}
}
Aggregations