Class SchemaRegistryMockExtension
- java.lang.Object
-
- com.bakdata.schemaregistrymock.SchemaRegistryMock
-
- com.bakdata.schemaregistrymock.junit5.SchemaRegistryMockExtension
-
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterEachCallback,org.junit.jupiter.api.extension.BeforeEachCallback,org.junit.jupiter.api.extension.Extension
public class SchemaRegistryMockExtension extends com.bakdata.schemaregistrymock.SchemaRegistryMock implements org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallbackThe schema registry mock implements a few basic HTTP endpoints that are used by the Avro serdes.
In particular,- you can register a schema
- retrieve a schema by id.
- list and get schema versions of a subject
If you use the TestTopology of the fluent Kafka Streams test, you don't have to interact with this class at all.
Without the test framework, you can use the mock as follows:
To retrieve the url of the schema registry for a Kafka Streams config, please useclass SchemaRegistryMockTest { @RegisterExtension final SchemaRegistryMockExtension schemaRegistry = new SchemaRegistryMockExtension(); @Test void shouldRegisterKeySchema() throws IOException, RestClientException { final Schema keySchema = this.createSchema("key_schema"); final int id = this.schemaRegistry.registerKeySchema("test-topic", keySchema); final Schema retrievedSchema = this.schemaRegistry.getSchemaRegistryClient().getById(id); assertThat(retrievedSchema).isEqualTo(keySchema); } }SchemaRegistryMock.getUrl()
-
-
Constructor Summary
Constructors Constructor Description SchemaRegistryMockExtension()Create a newSchemaRegistryMockExtensionwith defaultSchemaProviders.SchemaRegistryMockExtension(java.util.List<io.confluent.kafka.schemaregistry.SchemaProvider> schemaProviders)Create a newSchemaRegistryMockExtensionfromSchemaProviders.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterEach(org.junit.jupiter.api.extension.ExtensionContext context)voidbeforeEach(org.junit.jupiter.api.extension.ExtensionContext context)
-
-
-
Constructor Detail
-
SchemaRegistryMockExtension
public SchemaRegistryMockExtension()
Create a newSchemaRegistryMockExtensionwith defaultSchemaProviders.- See Also:
SchemaRegistryMockExtension(List)
-
SchemaRegistryMockExtension
public SchemaRegistryMockExtension(java.util.List<io.confluent.kafka.schemaregistry.SchemaProvider> schemaProviders)
Create a newSchemaRegistryMockExtensionfromSchemaProviders.- Parameters:
schemaProviders- List ofSchemaProvider. If null,AvroSchemaProviderwill be used.
-
-
Method Detail
-
afterEach
public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context)
- Specified by:
afterEachin interfaceorg.junit.jupiter.api.extension.AfterEachCallback
-
beforeEach
public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context)
- Specified by:
beforeEachin interfaceorg.junit.jupiter.api.extension.BeforeEachCallback
-
-