From 17ce951d80ceb10817b992dc07ef09d28c323938 Mon Sep 17 00:00:00 2001 From: "gustavo.monarin" Date: Wed, 19 Oct 2022 13:06:26 +0200 Subject: [PATCH] Extend schema registry tests Schema registry tests for publishing and consuming new schemas. The tests only cover the api availability. Further reference should follow the official documentation as this is a quite extensive / complex subject, which would require code generation, plugins to have as example while the [official documentation](https://docs.confluent.io/platform/current/schema-registry/index.html) is quite good. --- .../redpanda/RedpandaContainerTest.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/redpanda/src/test/java/org/testcontainers/redpanda/RedpandaContainerTest.java b/modules/redpanda/src/test/java/org/testcontainers/redpanda/RedpandaContainerTest.java index dd32151f407..7ee1c8bdc04 100644 --- a/modules/redpanda/src/test/java/org/testcontainers/redpanda/RedpandaContainerTest.java +++ b/modules/redpanda/src/test/java/org/testcontainers/redpanda/RedpandaContainerTest.java @@ -27,6 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.tuple; +import static org.hamcrest.Matchers.hasItems; public class RedpandaContainerTest { @@ -77,9 +78,21 @@ public void testSchemaRegistry() { // } ); - io.restassured.response.Response subjects = RestAssured.given().when().get(subjectsEndpoint).andReturn(); - - assertThat(subjects.getStatusCode()).isEqualTo(200); + String subjectName = String.format("test-%s-value", UUID.randomUUID()); + + // register the new subject + RestAssured + .given() + .contentType("application/vnd.schemaregistry.v1+json") + .pathParam("subject", subjectName) + .body("{\"schema\": \"{\\\"type\\\": \\\"string\\\"}\"}") + .when() + .post(subjectsEndpoint + "/{subject}/versions") + .then() + .statusCode(200); + + // list all the registered subjects + RestAssured.given().when().get(subjectsEndpoint).then().statusCode(200).body("$", hasItems(subjectName)); } }