Search in sources :

Example 1 with GrpcCmd

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));
}
Also used : Path(java.nio.file.Path) GrpcCmd(org.ballerinalang.protobuf.cmd.GrpcCmd) CompileResult(org.ballerinalang.launcher.util.CompileResult) File(java.io.File) Test(org.testng.annotations.Test)

Example 2 with GrpcCmd

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));
}
Also used : Path(java.nio.file.Path) GrpcCmd(org.ballerinalang.protobuf.cmd.GrpcCmd) CompileResult(org.ballerinalang.launcher.util.CompileResult) File(java.io.File) Test(org.testng.annotations.Test)

Example 3 with GrpcCmd

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));
}
Also used : Path(java.nio.file.Path) GrpcCmd(org.ballerinalang.protobuf.cmd.GrpcCmd) CompileResult(org.ballerinalang.launcher.util.CompileResult) File(java.io.File) Test(org.testng.annotations.Test)

Example 4 with GrpcCmd

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));
}
Also used : Path(java.nio.file.Path) GrpcCmd(org.ballerinalang.protobuf.cmd.GrpcCmd) CompileResult(org.ballerinalang.launcher.util.CompileResult) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

File (java.io.File)4 Path (java.nio.file.Path)4 CompileResult (org.ballerinalang.launcher.util.CompileResult)4 GrpcCmd (org.ballerinalang.protobuf.cmd.GrpcCmd)4 Test (org.testng.annotations.Test)4