Skip to content
This repository has been archived by the owner on Feb 12, 2018. It is now read-only.

Commit

Permalink
#30 Added an integration test for custom protoc plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-ivanov committed Sep 15, 2015
1 parent 5e991ee commit 5afebeb
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/it/TEST-28/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# An optional description for this build job to be included in the build reports.
invoker.description = Verifies that a binary artifact for a protoc plugin can be downloaded from Maven repository.

# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean package
76 changes: 76 additions & 0 deletions src/it/TEST-28/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.google.protobuf.tools.maven-protoc-plugin.its</groupId>
<artifactId>it-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

<artifactId>TEST-28</artifactId>
<version>0.0.1-SNAPSHOT</version>

<name>Integration Test 28</name>

<properties>
<protobufVersion>3.0.0-alpha-3</protobufVersion>
<grpcVersion>0.7.2</grpcVersion>
</properties>

<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.3.0.Final</version>
</extension>
</extensions>

<plugins>
<plugin>
<groupId>com.google.protobuf.tools</groupId>
<artifactId>maven-protoc-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>protoc-compile</id>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
<execution>
<id>protoc-test-compile</id>
<phase>generate-test-sources</phase>
<goals>
<goal>test-compile</goal>
<goal>test-compile-custom</goal>
</goals>
</execution>
</executions>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
</protocArtifact>
<pluginId>grpc</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpcVersion}:exe:${os.detected.classifier}
</pluginArtifact>
<pluginParameter>nano=false</pluginParameter>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-all</artifactId>
<version>${grpcVersion}</version>
</dependency>
</dependencies>
</project>
25 changes: 25 additions & 0 deletions src/it/TEST-28/src/main/proto/test.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
syntax = "proto3";

option java_package = "test";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;

message TestMessage {
message NestedMessage {
int32 zz = 1;
}

enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}

// Singular
int32 xx = 1;
repeated NestedEnum yy = 2;
}

service MyService {
rpc MyMethod(TestMessage) returns(TestMessage) {}
}
28 changes: 28 additions & 0 deletions src/it/TEST-28/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
outputDirectory = new File(basedir, 'target/generated-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();

generatedJavaFile = new File(outputDirectory, 'test/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();

content = generatedJavaFile.text;
assert content.contains('package test');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage');

outputDirectory = new File(basedir, 'target/generated-sources/protobuf/grpc');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();

generatedJavaFile = new File(outputDirectory, 'test/MyServiceGrpc.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();

content = generatedJavaFile.text;
assert content.contains('package test');
assert content.contains('class MyServiceGrpc');
assert content.contains('interface MyService');


return true;

0 comments on commit 5afebeb

Please sign in to comment.