Skip to content

Commit

Permalink
integration tests for proto test imports in reactor projects
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-ivanov committed Jun 12, 2011
1 parent 396ff6f commit b891994
Show file tree
Hide file tree
Showing 28 changed files with 814 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/it/TEST-10/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 protobuf definitions can be imported from other modules in the reactor. \
In this test, imports are scoped to the default package.

invoker.goals = clean compile
69 changes: 69 additions & 0 deletions src/it/TEST-10/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?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>
<groupId>com.google.protobuf.tools.maven-protoc-plugin.its</groupId>
<artifactId>TEST-10-parent</artifactId>
<name>Integration Test</name>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>project1</module>
<module>project2</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>[2.4,2.5)</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<protobuf>
<version>[2.4,2.5)</version>
</protobuf>
</toolchains>
</configuration>
</plugin>
<plugin>
<groupId>com.google.protobuf.tools</groupId>
<artifactId>maven-protoc-plugin</artifactId>
<version>@project.version@</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
37 changes: 37 additions & 0 deletions src/it/TEST-10/project1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?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>TEST-10-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>TEST-10-project1</artifactId>
<name>Integration Test</name>
<build>
<plugins>
<plugin>
<groupId>com.google.protobuf.tools</groupId>
<artifactId>maven-protoc-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</dependency>
</dependencies>
</project>
6 changes: 6 additions & 0 deletions src/it/TEST-10/project1/src/main/proto/test1.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
option java_package = "it.project1.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;

message TestMessage1 {
}
42 changes: 42 additions & 0 deletions src/it/TEST-10/project2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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>TEST-10-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>TEST-10-project2</artifactId>
<name>Integration Test</name>
<build>
<plugins>
<plugin>
<groupId>com.google.protobuf.tools</groupId>
<artifactId>maven-protoc-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>TEST-10-project1</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
9 changes: 9 additions & 0 deletions src/it/TEST-10/project2/src/main/proto/test2.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import "test1.proto";

option java_package = "it.project2.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;

message TestMessage2 {
optional TestMessage1 included = 1;
}
27 changes: 27 additions & 0 deletions src/it/TEST-10/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
outputDirectory = new File(basedir, 'project1/target/generated-sources/protoc');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();

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

content = generatedJavaFile.text;
assert content.contains('package it.project1.messages');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage1');

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

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

content = generatedJavaFile.text;
assert content.contains('package it.project2.messages');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage2');

return true;
16 changes: 16 additions & 0 deletions src/it/TEST-11/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# An optional description for this build job to be included in the build reports.
invoker.description = \
Verifies that protobuf definitions can be imported from other modules in the reactor. \
In this test, imports are scoped to packages. \
We need to make sure that package structure for protobuf definitions \
is preserved in packaged jars, and correctly restored for importing.

invoker.goals = clean test-compile

# >>>> THIS TEST IS TEMPORARILY IGNORED <<<<
# This is because protos from dependencies that are scoped to custom package
# are incorrectly specified on the protoc command line
#
# TODO: fix command line for imports
#invoker.buildResult = failure
invoker.failureBehavior = fail-never
69 changes: 69 additions & 0 deletions src/it/TEST-11/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?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>
<groupId>com.google.protobuf.tools.maven-protoc-plugin.its</groupId>
<artifactId>TEST-11-parent</artifactId>
<name>Integration Test</name>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>project1</module>
<module>project2</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>[2.4,2.5)</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<protobuf>
<version>[2.4,2.5)</version>
</protobuf>
</toolchains>
</configuration>
</plugin>
<plugin>
<groupId>com.google.protobuf.tools</groupId>
<artifactId>maven-protoc-plugin</artifactId>
<version>@project.version@</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
49 changes: 49 additions & 0 deletions src/it/TEST-11/project1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?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>TEST-11-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>TEST-11-project1</artifactId>
<name>Integration Test</name>
<build>
<plugins>
<plugin>
<groupId>com.google.protobuf.tools</groupId>
<artifactId>maven-protoc-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package it.project1;

option java_package = "it.project1.messages";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;

message TestMessage1 {
}
44 changes: 44 additions & 0 deletions src/it/TEST-11/project2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?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>TEST-11-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>TEST-11-project2</artifactId>
<name>Integration Test</name>
<build>
<plugins>
<plugin>
<groupId>com.google.protobuf.tools</groupId>
<artifactId>maven-protoc-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>TEST-11-project1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Loading

0 comments on commit b891994

Please sign in to comment.