-
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.
Set Ccompat url as default registry url when Confluent serde is on th…
…e classpath.
- Loading branch information
Showing
9 changed files
with
111 additions
and
139 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
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
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
50 changes: 0 additions & 50 deletions
50
...-avro-apicurio2/src/test/java/io/quarkus/it/kafka/KafkaAndSchemaRegistryTestResource.java
This file was deleted.
Oops, something went wrong.
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
64 changes: 13 additions & 51 deletions
64
integration-tests/kafka-avro-apicurio2/src/test/java/io/quarkus/it/kafka/KafkaAvroTest.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 |
---|---|---|
@@ -1,90 +1,52 @@ | ||
package io.quarkus.it.kafka; | ||
|
||
import java.time.Duration; | ||
import javax.inject.Inject; | ||
|
||
import org.apache.kafka.clients.consumer.ConsumerRecord; | ||
import org.apache.kafka.clients.consumer.KafkaConsumer; | ||
import org.apache.kafka.clients.producer.KafkaProducer; | ||
import org.apache.kafka.clients.producer.ProducerRecord; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.it.kafka.avro.AvroKafkaCreator; | ||
import io.quarkus.it.kafka.avro.Pet; | ||
import io.quarkus.test.common.QuarkusTestResource; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.restassured.RestAssured; | ||
|
||
@QuarkusTest | ||
@QuarkusTestResource(KafkaAndSchemaRegistryTestResource.class) | ||
public class KafkaAvroTest { | ||
public class KafkaAvroTest extends KafkaAvroTestBase { | ||
|
||
private static final String CONFLUENT_PATH = "/avro/confluent"; | ||
private static final String APICURIO_PATH = "/avro/apicurio"; | ||
@Inject | ||
AvroKafkaCreator creator; | ||
|
||
@Test | ||
public void testCcompat() { | ||
Assertions.assertTrue(creator.getApicurioRegistryUrl().endsWith("/apis/ccompat/v6")); | ||
} | ||
|
||
@Test | ||
public void testConfluentAvroProducer() { | ||
KafkaConsumer<Integer, Pet> consumer = AvroKafkaCreator.createConfluentConsumer( | ||
KafkaAndSchemaRegistryTestResource.getBootstrapServers(), | ||
KafkaAndSchemaRegistryTestResource.getConfluentSchemaRegistryUrl(), | ||
KafkaConsumer<Integer, Pet> consumer = creator.createConfluentConsumer( | ||
"test-avro-confluent", | ||
"test-avro-confluent-producer"); | ||
testAvroProducer(consumer, CONFLUENT_PATH); | ||
} | ||
|
||
@Test | ||
public void testConfluentAvroConsumer() { | ||
KafkaProducer<Integer, Pet> producer = AvroKafkaCreator.createConfluentProducer( | ||
KafkaAndSchemaRegistryTestResource.getBootstrapServers(), | ||
KafkaAndSchemaRegistryTestResource.getConfluentSchemaRegistryUrl(), | ||
"test-avro-confluent-test"); | ||
KafkaProducer<Integer, Pet> producer = creator.createConfluentProducer("test-avro-confluent-test"); | ||
testAvroConsumer(producer, CONFLUENT_PATH, "test-avro-confluent-consumer"); | ||
} | ||
|
||
@Test | ||
public void testApicurioAvroProducer() { | ||
KafkaConsumer<Integer, Pet> consumer = AvroKafkaCreator.createApicurioConsumer( | ||
KafkaAndSchemaRegistryTestResource.getBootstrapServers(), | ||
KafkaAndSchemaRegistryTestResource.getApicurioSchemaRegistryUrl(), | ||
KafkaConsumer<Integer, Pet> consumer = creator.createApicurioConsumer( | ||
"test-avro-apicurio", | ||
"test-avro-apicurio-producer"); | ||
testAvroProducer(consumer, APICURIO_PATH); | ||
} | ||
|
||
@Test | ||
public void testApicurioAvroConsumer() { | ||
KafkaProducer<Integer, Pet> producer = AvroKafkaCreator.createApicurioProducer( | ||
KafkaAndSchemaRegistryTestResource.getBootstrapServers(), | ||
KafkaAndSchemaRegistryTestResource.getApicurioSchemaRegistryUrl(), | ||
"test-avro-apicurio-test"); | ||
KafkaProducer<Integer, Pet> producer = creator.createApicurioProducer("test-avro-apicurio-test"); | ||
testAvroConsumer(producer, APICURIO_PATH, "test-avro-apicurio-consumer"); | ||
} | ||
|
||
private void testAvroProducer(KafkaConsumer<Integer, Pet> consumer, String path) { | ||
RestAssured.given() | ||
.header("content-type", "application/json") | ||
.body("{\"name\":\"neo\", \"color\":\"tricolor\"}") | ||
.post(path); | ||
ConsumerRecord<Integer, Pet> records = consumer.poll(Duration.ofMillis(20000)).iterator().next(); | ||
Assertions.assertEquals(records.key(), (Integer) 0); | ||
Pet pet = records.value(); | ||
Assertions.assertEquals("neo", pet.getName()); | ||
Assertions.assertEquals("tricolor", pet.getColor()); | ||
consumer.close(); | ||
} | ||
|
||
private void testAvroConsumer(KafkaProducer<Integer, Pet> producer, String path, String topic) { | ||
producer.send(new ProducerRecord<>(topic, 1, createPet())); | ||
Pet retrieved = RestAssured.when().get(path).as(Pet.class); | ||
Assertions.assertEquals("neo", retrieved.getName()); | ||
Assertions.assertEquals("white", retrieved.getColor()); | ||
producer.close(); | ||
} | ||
|
||
private Pet createPet() { | ||
Pet pet = new Pet(); | ||
pet.setName("neo"); | ||
pet.setColor("white"); | ||
return pet; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...ation-tests/kafka-avro-apicurio2/src/test/java/io/quarkus/it/kafka/KafkaAvroTestBase.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,46 @@ | ||
package io.quarkus.it.kafka; | ||
|
||
import java.time.Duration; | ||
|
||
import org.apache.kafka.clients.consumer.ConsumerRecord; | ||
import org.apache.kafka.clients.consumer.KafkaConsumer; | ||
import org.apache.kafka.clients.producer.KafkaProducer; | ||
import org.apache.kafka.clients.producer.ProducerRecord; | ||
import org.junit.jupiter.api.Assertions; | ||
|
||
import io.quarkus.it.kafka.avro.Pet; | ||
import io.restassured.RestAssured; | ||
|
||
public abstract class KafkaAvroTestBase { | ||
|
||
static final String CONFLUENT_PATH = "/avro/confluent"; | ||
static final String APICURIO_PATH = "/avro/apicurio"; | ||
|
||
protected void testAvroProducer(KafkaConsumer<Integer, Pet> consumer, String path) { | ||
RestAssured.given() | ||
.header("content-type", "application/json") | ||
.body("{\"name\":\"neo\", \"color\":\"tricolor\"}") | ||
.post(path); | ||
ConsumerRecord<Integer, Pet> records = consumer.poll(Duration.ofMillis(20000)).iterator().next(); | ||
Assertions.assertEquals(records.key(), (Integer) 0); | ||
Pet pet = records.value(); | ||
Assertions.assertEquals("neo", pet.getName()); | ||
Assertions.assertEquals("tricolor", pet.getColor()); | ||
consumer.close(); | ||
} | ||
|
||
protected void testAvroConsumer(KafkaProducer<Integer, Pet> producer, String path, String topic) { | ||
producer.send(new ProducerRecord<>(topic, 1, createPet())); | ||
Pet retrieved = RestAssured.when().get(path).as(Pet.class); | ||
Assertions.assertEquals("neo", retrieved.getName()); | ||
Assertions.assertEquals("white", retrieved.getColor()); | ||
producer.close(); | ||
} | ||
|
||
private Pet createPet() { | ||
Pet pet = new Pet(); | ||
pet.setName("neo"); | ||
pet.setColor("white"); | ||
return pet; | ||
} | ||
} |