use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class WorkerInFunctionTest method testWorkerMultipleInteractions.
@Test(description = "Test worker interactions with each other")
public void testWorkerMultipleInteractions() {
CompileResult result = BCompileUtil.compile("test-src/workers/worker-multiple-interactions.bal");
BValue[] args = { new BInteger(100) };
BValue[] returns = BRunUtil.invoke(result, "testMultiInteractions", args);
Assert.assertEquals(returns.length, 1);
Assert.assertTrue(returns[0] instanceof BInteger);
final String expected = "1103";
Assert.assertEquals(returns[0].stringValue(), expected);
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class VMDebuggerUtil method setupProgram.
private static TestDebugger setupProgram(String sourceFilePath, BreakPointDTO[] breakPoints) {
CompileResult result = BCompileUtil.compile(sourceFilePath);
TestDebugger debugger = new TestDebugger(result.getProgFile());
result.getProgFile().setDebugger(debugger);
debugger.setDebugEnabled();
String[] args = { "Hello", "World" };
DebuggerExecutor executor = new DebuggerExecutor(result, args, debugger, new ArrayList<>(Arrays.asList(breakPoints)));
(new Thread(executor)).start();
return debugger;
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class BalGenToolTest method testUnaryHelloWorld.
@Test(enabled = false)
public void testUnaryHelloWorld() throws IllegalAccessException, ClassNotFoundException, InstantiationException, IOException {
Class<?> grpcCmd = Class.forName("org.ballerinalang.protobuf.cmd.GrpcCmd");
GrpcCmd grpcCmd1 = (GrpcCmd) grpcCmd.newInstance();
Path sourcePath = Paths.get("protoFiles");
Path sourceRoot = resourceDir.resolve(sourcePath);
Path protoPath = Paths.get("protoFiles/helloWorld.proto");
Path protoRoot = resourceDir.resolve(protoPath);
grpcCmd1.setBalOutPath(sourceRoot.toString());
grpcCmd1.setProtoPath(protoRoot.toString());
grpcCmd1.execute();
Path sourceFileRoot = resourceDir.resolve(Paths.get("protoFiles/helloWorld.pb.bal"));
Path destFileRoot = resourceDir.resolve(Paths.get("protoFiles/helloWorld.gen.pb.bal"));
removePackage(sourceFileRoot.toString(), destFileRoot.toString());
CompileResult compileResult = BCompileUtil.compile(destFileRoot.toString());
Assert.assertNotNull(compileResult.getProgFile().getPackageInfo(PACKAGE_NAME).getStructInfo("helloWorldClient"), "Connector not found.");
Assert.assertNotNull(compileResult.getProgFile().getPackageInfo(PACKAGE_NAME).getStructInfo("helloWorldBlockingClient"), "Connector not found.");
Assert.assertNotNull(compileResult.getProgFile().getPackageInfo(PACKAGE_NAME).getStructInfo("helloWorldBlockingStub"), "Connector not found.");
Assert.assertNotNull(compileResult.getProgFile().getPackageInfo(PACKAGE_NAME).getFunctionInfo("helloWorldBlockingStub.hello"), "Connector not found.");
Assert.assertNotNull(compileResult.getProgFile().getPackageInfo(PACKAGE_NAME).getFunctionInfo("helloWorldStub.hello"), "Connector not found.");
Assert.assertNotNull(compileResult.getProgFile().getPackageInfo(PACKAGE_NAME).getFunctionInfo("helloWorldBlockingStub.bye"), "Connector not found.");
Assert.assertNotNull(compileResult.getProgFile().getPackageInfo(PACKAGE_NAME).getFunctionInfo("helloWorldStub.bye"), "Connector not found.");
BalFileGenerationUtils.delete(new File(protoExeName));
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class BalGenToolTest method testClientStreamingHelloWorld.
@Test(enabled = false)
public void testClientStreamingHelloWorld() throws IllegalAccessException, ClassNotFoundException, InstantiationException, IOException {
Class<?> grpcCmd = Class.forName("org.ballerinalang.protobuf.cmd.GrpcCmd");
GrpcCmd grpcCmd1 = (GrpcCmd) grpcCmd.newInstance();
Path sourcePath = Paths.get("protoFiles");
Path sourceRoot = resourceDir.resolve(sourcePath);
Path protoPath = Paths.get("protoFiles/helloWorldClientStreaming.proto");
Path protoRoot = resourceDir.resolve(protoPath);
grpcCmd1.setBalOutPath(sourceRoot.toString());
grpcCmd1.setProtoPath(protoRoot.toString());
grpcCmd1.execute();
Path sourceFileRoot = resourceDir.resolve(Paths.get("protoFiles/helloWorldClientStreaming.pb.bal"));
Path destFileRoot = resourceDir.resolve(Paths.get("protoFiles/helloWorldClientStreaming.gen.pb.bal"));
removePackage(sourceFileRoot.toString(), destFileRoot.toString());
CompileResult compileResult = BCompileUtil.compile(destFileRoot.toString());
Assert.assertNotNull(compileResult.getProgFile().getPackageInfo(PACKAGE_NAME).getStructInfo("helloWorldClientStreamingClient"), "Connector not found.");
Assert.assertNotNull(compileResult.getProgFile().getPackageInfo(PACKAGE_NAME).getStructInfo("helloWorldClientStreamingStub"), "Connector not found.");
Assert.assertNotNull(compileResult.getProgFile().getPackageInfo(PACKAGE_NAME).getFunctionInfo("helloWorldClientStreamingStub.LotsOfGreetings"), "Connector not found.");
BalFileGenerationUtils.delete(new File(protoExeName));
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class ObjectTest method testObjectWithSimpleInitWithDiffValues.
@Test(description = "Test object with init with different values")
public void testObjectWithSimpleInitWithDiffValues() {
CompileResult compileResult = BCompileUtil.compile("test-src/object/object-with-init-func.bal");
BValue[] returns = BRunUtil.invoke(compileResult, "testObjectWithSimpleInitWithDiffValues");
Assert.assertEquals(returns.length, 4);
Assert.assertSame(returns[0].getClass(), BInteger.class);
Assert.assertSame(returns[1].getClass(), BString.class);
Assert.assertSame(returns[2].getClass(), BInteger.class);
Assert.assertSame(returns[3].getClass(), BString.class);
Assert.assertEquals(((BInteger) returns[0]).intValue(), 37);
Assert.assertEquals(returns[1].stringValue(), "sample value1");
Assert.assertEquals(((BInteger) returns[2]).intValue(), 675);
Assert.assertEquals(returns[3].stringValue(), "adding value in invocation");
}
Aggregations