-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for Apicurio Registry 2.x Avro library
- Loading branch information
Showing
12 changed files
with
680 additions
and
12 deletions.
There are no files selected for viewing
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
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,280 @@ | ||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>quarkus-integration-tests-parent</artifactId> | ||
<groupId>io.quarkus</groupId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>quarkus-integration-test-kafka-avro-apicurio2</artifactId> | ||
<name>Quarkus - Integration Tests - Kafka Avro with Apicurio 2.x</name> | ||
<description>The Apache Kafka Avro with Apicurio Registry 2.x integration tests module</description> | ||
|
||
<!-- | ||
- This must be a separate Maven module, because adding Apicurio Registry 2.x | ||
- libraries to the `kafka-avro` module would lead to dependency divergence. | ||
- When we no longer care about Apicurio Registry 1.x, the `kafka-avro` | ||
- module can be deleted, as this module is a copy and hence also includes | ||
- the tests for Confluent schema registry. | ||
--> | ||
|
||
<properties> | ||
<apicurio.version>2.0.0.Final</apicurio.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-integration-test-class-transformer</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-integration-test-shared-library</artifactId> | ||
</dependency> | ||
|
||
<!-- JAX-RS --> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-jackson</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-jsonb</artifactId> | ||
</dependency> | ||
|
||
<!-- Kafka --> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-kafka-client</artifactId> | ||
</dependency> | ||
|
||
<!-- Avro --> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-avro</artifactId> | ||
</dependency> | ||
|
||
<!-- Confluent (Not in Maven Central) --> | ||
<dependency> | ||
<groupId>io.confluent</groupId> | ||
<artifactId>kafka-avro-serializer</artifactId> | ||
<version>6.1.1</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>jakarta.ws.rs</groupId> | ||
<artifactId>jakarta.ws.rs-api</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<!-- Apicurio --> | ||
<dependency> | ||
<groupId>io.apicurio</groupId> | ||
<artifactId>apicurio-registry-serdes-avro-serde</artifactId> | ||
<version>${apicurio.version}</version> | ||
</dependency> | ||
|
||
|
||
<!-- test dependencies --> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.rest-assured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>jakarta.xml.bind</groupId> | ||
<artifactId>jakarta.xml.bind-api</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.strimzi</groupId> | ||
<artifactId>strimzi-test-container</artifactId> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-core</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>testcontainers</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- Minimal test dependencies to *-deployment artifacts for consistent build order --> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-avro-deployment</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-integration-test-class-transformer-deployment</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-kafka-client-deployment</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-deployment</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-jackson-deployment</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-jsonb-deployment</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
|
||
<repositories> | ||
<repository> | ||
<id>confluent</id> | ||
<url>https://packages.confluent.io/maven/</url> | ||
<snapshots> | ||
<enabled>false</enabled> | ||
</snapshots> | ||
</repository> | ||
</repositories> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>generate-code</goal> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>test-kafka</id> | ||
<activation> | ||
<property> | ||
<name>test-containers</name> | ||
</property> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skip>false</skip> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<configuration> | ||
<skip>false</skip> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
|
||
<profile> | ||
<id>native-image</id> | ||
<activation> | ||
<property> | ||
<name>native</name> | ||
</property> | ||
</activation> | ||
<!-- add some custom config, the rest comes from parent --> | ||
<properties> | ||
<quarkus.native.enable-all-security-services>true</quarkus.native.enable-all-security-services> | ||
</properties> | ||
</profile> | ||
</profiles> | ||
|
||
</project> |
15 changes: 15 additions & 0 deletions
15
integration-tests/kafka-avro-apicurio2/src/main/avro/pet.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,15 @@ | ||
{ | ||
"namespace": "io.quarkus.it.kafka.avro", | ||
"type": "record", | ||
"name": "Pet", | ||
"fields": [ | ||
{ | ||
"name": "name", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "color", | ||
"type": "string" | ||
} | ||
] | ||
} |
71 changes: 71 additions & 0 deletions
71
...ation-tests/kafka-avro-apicurio2/src/main/java/io/quarkus/it/kafka/avro/AvroEndpoint.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,71 @@ | ||
package io.quarkus.it.kafka.avro; | ||
|
||
import java.time.Duration; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
|
||
import org.apache.kafka.clients.consumer.ConsumerRecord; | ||
import org.apache.kafka.clients.consumer.ConsumerRecords; | ||
import org.apache.kafka.clients.consumer.KafkaConsumer; | ||
import org.apache.kafka.clients.producer.KafkaProducer; | ||
import org.apache.kafka.clients.producer.ProducerRecord; | ||
|
||
import io.vertx.core.json.JsonObject; | ||
|
||
/** | ||
* Endpoint to test the Avro support | ||
*/ | ||
@Path("/avro") | ||
public class AvroEndpoint { | ||
|
||
@Inject | ||
AvroKafkaCreator creator; | ||
|
||
@GET | ||
@Path("/confluent") | ||
public JsonObject getConfluent() { | ||
return get(creator.createConfluentConsumer("test-avro-confluent-consumer", "test-avro-confluent-consumer")); | ||
} | ||
|
||
@POST | ||
@Path("/confluent") | ||
public void sendConfluent(Pet pet) { | ||
KafkaProducer<Integer, Pet> p = creator.createConfluentProducer("test-avro-confluent"); | ||
send(p, pet, "test-avro-confluent-producer"); | ||
} | ||
|
||
@GET | ||
@Path("/apicurio") | ||
public JsonObject getApicurio() { | ||
return get(creator.createApicurioConsumer("test-avro-apicurio-consumer", "test-avro-apicurio-consumer")); | ||
} | ||
|
||
@POST | ||
@Path("/apicurio") | ||
public void sendApicurio(Pet pet) { | ||
KafkaProducer<Integer, Pet> p = creator.createApicurioProducer("test-avro-apicurio"); | ||
send(p, pet, "test-avro-apicurio-producer"); | ||
} | ||
|
||
private JsonObject get(KafkaConsumer<Integer, Pet> consumer) { | ||
final ConsumerRecords<Integer, Pet> records = consumer.poll(Duration.ofMillis(60000)); | ||
if (records.isEmpty()) { | ||
return null; | ||
} | ||
ConsumerRecord<Integer, Pet> consumerRecord = records.iterator().next(); | ||
Pet p = consumerRecord.value(); | ||
// We cannot serialize the returned Pet directly, it contains non-serializable object such as the schema. | ||
JsonObject result = new JsonObject(); | ||
result.put("name", p.getName()); | ||
result.put("color", p.getColor()); | ||
return result; | ||
} | ||
|
||
private void send(KafkaProducer<Integer, Pet> producer, Pet pet, String topic) { | ||
producer.send(new ProducerRecord<>(topic, 0, pet)); | ||
producer.flush(); | ||
} | ||
} |
Oops, something went wrong.