forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Testing: add reproducer for testing bug with multi-module project and…
… Avro
- Loading branch information
Showing
7 changed files
with
231 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
.../test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestAvroMultimoduleIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.quarkus.it.extension.it; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.apache.maven.shared.invoker.MavenInvocationException; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.DisabledIfSystemProperty; | ||
|
||
import io.quarkus.maven.it.MojoTestBase; | ||
import io.quarkus.maven.it.verifier.MavenProcessInvocationResult; | ||
import io.quarkus.maven.it.verifier.RunningInvoker; | ||
|
||
/** | ||
* Be aware! This test will not run if the name does not start with 'Test'. | ||
*/ | ||
@Disabled("https://github.com/quarkusio/quarkus/issues/27057") | ||
@DisabledIfSystemProperty(named = "quarkus.test.native", matches = "true") | ||
public class TestAvroMultimoduleIT extends MojoTestBase { | ||
@Test | ||
public void testThatTheTestsPassed() throws MavenInvocationException, InterruptedException { | ||
File testDir = initProject("projects/avro-multimodule-project", "projects/avro-multimodule-project-build"); | ||
RunningInvoker running = new RunningInvoker(testDir, false); | ||
MavenProcessInvocationResult result = running.execute(List.of("clean", "test"), Map.of()); | ||
assertThat(result.getProcess().waitFor()).isZero(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...nsion/tests/src/test/resources-filtered/projects/avro-multimodule-project/module1/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.acme</groupId> | ||
<artifactId>avro-multimodule-project</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>module1</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-avro</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
11 changes: 11 additions & 0 deletions
11
...est/resources-filtered/projects/avro-multimodule-project/module1/src/main/avro/movie.avsc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"namespace": "org.acme.quarkus", | ||
"type": "record", | ||
"name": "Movie", | ||
"fields": [ | ||
{ | ||
"name": "title", | ||
"type": "string" | ||
} | ||
] | ||
} |
30 changes: 30 additions & 0 deletions
30
...nsion/tests/src/test/resources-filtered/projects/avro-multimodule-project/module2/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.acme</groupId> | ||
<artifactId>avro-multimodule-project</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>module2</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.acme</groupId> | ||
<artifactId>module1</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-arc</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
37 changes: 37 additions & 0 deletions
37
...filtered/projects/avro-multimodule-project/module2/src/main/java/org/acme/MovieSerde.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.acme; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
|
||
import org.acme.quarkus.Movie; | ||
import org.apache.avro.file.DataFileStream; | ||
import org.apache.avro.file.DataFileWriter; | ||
import org.apache.avro.io.DatumReader; | ||
import org.apache.avro.io.DatumWriter; | ||
import org.apache.avro.specific.SpecificDatumReader; | ||
import org.apache.avro.specific.SpecificDatumWriter; | ||
|
||
@ApplicationScoped | ||
public class MovieSerde { | ||
public byte[] serialize(Movie movie) throws IOException { | ||
ByteArrayOutputStream out = new ByteArrayOutputStream(); | ||
DatumWriter<Movie> movieWriter = new SpecificDatumWriter<>(Movie.class); | ||
try (DataFileWriter<Movie> writer = new DataFileWriter<>(movieWriter)) { | ||
writer.create(Movie.getClassSchema(), out); | ||
writer.append(movie); | ||
writer.flush(); | ||
} | ||
return out.toByteArray(); | ||
} | ||
|
||
public Movie deserialize(byte[] bytes) throws IOException { | ||
ByteArrayInputStream in = new ByteArrayInputStream(bytes); | ||
DatumReader<Movie> movieReader = new SpecificDatumReader<>(Movie.class); | ||
try (DataFileStream<Movie> movieStream = new DataFileStream<>(in, movieReader)) { | ||
return movieStream.next(); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ered/projects/avro-multimodule-project/module2/src/test/java/org/acme/MovieSerdeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.acme; | ||
|
||
import jakarta.inject.Inject; | ||
import org.acme.quarkus.Movie; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@QuarkusTest | ||
public class MovieSerdeTest { | ||
@Inject | ||
MovieSerde serializer; | ||
|
||
@Test | ||
void test() throws Exception { | ||
Movie movie = new Movie("my-movie"); | ||
|
||
byte[] serializedMovie = serializer.serialize(movie); | ||
Movie deserialized = serializer.deserialize(serializedMovie); | ||
|
||
assertEquals(deserialized, movie); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...est-extension/tests/src/test/resources-filtered/projects/avro-multimodule-project/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.acme</groupId> | ||
<artifactId>avro-multimodule-project</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
|
||
<maven.compiler.release>17</maven.compiler.release> | ||
|
||
<version.maven-compiler-plugin>${compiler-plugin.version}</version.maven-compiler-plugin> | ||
<version.maven-surefire-plugin>3.5.2</version.maven-surefire-plugin> | ||
<version.quarkus>@project.version@</version.quarkus> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-bom</artifactId> | ||
<version>\${version.quarkus}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<modules> | ||
<module>module1</module> | ||
<module>module2</module> | ||
</modules> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<version>\${version.quarkus}</version> | ||
<extensions>true</extensions> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>build</goal> | ||
<goal>generate-code</goal> | ||
<goal>generate-code-tests</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>\${version.maven-compiler-plugin}</version> | ||
<configuration> | ||
<parameters>true</parameters> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>\${version.maven-surefire-plugin}</version> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> | ||
<maven.home>\${maven.home}</maven.home> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |