use of org.ballerinalang.protobuf.cmd.GrpcCmd 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.protobuf.cmd.GrpcCmd 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.protobuf.cmd.GrpcCmd in project ballerina by ballerina-lang.
the class BalGenToolTest method testServerStreamingHelloWorld.
@Test(enabled = false)
public void testServerStreamingHelloWorld() 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/helloWorldServerStreaming.proto");
Path protoRoot = resourceDir.resolve(protoPath);
grpcCmd1.setBalOutPath(sourceRoot.toString());
grpcCmd1.setProtoPath(protoRoot.toString());
grpcCmd1.execute();
Path sourceFileRoot = resourceDir.resolve(Paths.get("protoFiles/helloWorldServerStreaming.pb.bal"));
Path destFileRoot = resourceDir.resolve(Paths.get("protoFiles/helloWorldServerStreaming.gen.pb.bal"));
removePackage(sourceFileRoot.toString(), destFileRoot.toString());
CompileResult compileResult = BCompileUtil.compile(destFileRoot.toString());
Assert.assertNotNull(compileResult.getProgFile().getPackageInfo(PACKAGE_NAME).getStructInfo("helloWorldServerStreamingClient"), "Connector not found.");
Assert.assertNotNull(compileResult.getProgFile().getPackageInfo(PACKAGE_NAME).getStructInfo("helloWorldServerStreamingStub"), "Connector not found.");
Assert.assertNotNull(compileResult.getProgFile().getPackageInfo(PACKAGE_NAME).getFunctionInfo("helloWorldServerStreamingStub.lotsOfReplies"), "Connector not found.");
BalFileGenerationUtils.delete(new File(protoExeName));
}
use of org.ballerinalang.protobuf.cmd.GrpcCmd in project ballerina by ballerina-lang.
the class BalGenToolTest method testStandardDataTypes.
@Test(enabled = false)
public void testStandardDataTypes() 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/helloWorldString.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));
}
Aggregations