Skip to content

Commit 987c09b

Browse files
francescopellegrinimanub
authored andcommitted
Add Schema Registry docs (#136)
* fix leftovers of 0f615aa * update README.md with docs on the new module
1 parent 0f615aa commit 987c09b

File tree

1 file changed

+43
-33
lines changed

1 file changed

+43
-33
lines changed

README.md

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Versions match the version of Kafka they're built against.
2626

2727
### How to use
2828

29-
* In your `build.sbt` file add the following dependency: `"net.manub" %% "scalatest-embedded-kafka" % "1.1.0-kafka1.1" % "test"`
29+
* In your `build.sbt` file add the following dependency: `"net.manub" %% "scalatest-embedded-kafka" % "1.1.0-kafka1.1-nosr" % "test"`
3030
* Have your `Spec` extend the `EmbeddedKafka` trait.
3131
* Enclose the code that needs a running instance of Kafka within the `withRunningKafka` closure.
3232

@@ -192,37 +192,6 @@ consumer.consumeLazily[(String, String)]("from-this-topic").take(3).toList shoul
192192
)
193193
```
194194

195-
## Confuent Schema Registry support
196-
197-
If you need to serialize and deserialize messages using Avro, a [Confluent Schema Registry](https://docs.confluent.io/current/schema-registry/docs/index.html) instance can be provided to test your code.
198-
199-
### How to use
200-
201-
* Provide an implicit `EmbeddedKafkaConfig` specifying a port for Schema Registry to use (a value of 0 means random available port will be selected).
202-
203-
```scala
204-
class MySpec extends WordSpec with EmbeddedKafka {
205-
206-
"runs with embedded kafka and Schema Registry" should {
207-
208-
"work" in {
209-
implicit val config = EmbeddedKafkaConfig(schemaRegistryPort = Some(12345))
210-
211-
withRunningKafka {
212-
// ... code goes here
213-
}
214-
}
215-
}
216-
}
217-
```
218-
219-
* A Schema Registry server will be started and automatically shutdown at the end of the test.
220-
* Have a look at the [example test](kafka-streams/src/test/scala/net/manub/embeddedkafka/streams/ExampleKafkaStreamsSchemaRegistrySpec.scala).
221-
222-
### Utility methods
223-
224-
The `net.manub.embeddedkafka.avro.schemaregistry` package object provides useful implicit converters for testing with Avro and Schema Registry.
225-
226195
## scalatest-embedded-kafka-streams
227196

228197
A library that builds on top of `scalatest-embedded-kafka` to offer easy testing of [Kafka Streams](https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Streams) with ScalaTest.
@@ -231,7 +200,7 @@ It takes care of instantiating and starting your streams as well as closing them
231200

232201
### How to use
233202

234-
* In your `build.sbt` file add the following dependency: `"net.manub" %% "scalatest-embedded-kafka-streams" % "1.1.0-kafka1.1" % "test"`
203+
* In your `build.sbt` file add the following dependency: `"net.manub" %% "scalatest-embedded-kafka-streams" % "1.1.0-kafka1.1-nosr" % "test"`
235204
* Have a look at the [example test](kafka-streams/src/test/scala/net/manub/embeddedkafka/streams/ExampleKafkaStreamsSpec.scala)
236205
* For most of the cases have your `Spec` extend the `EmbeddedKafkaStreamsAllInOne` trait. This offers both streams management and easy creation of consumers for asserting resulting messages in output/sink topics.
237206
* If you only want to use the streams management without the test consumers just have the `Spec` extend the `EmbeddedKafkaStreams` trait.
@@ -270,3 +239,44 @@ class MySpec extends WordSpec with Matchers with EmbeddedKafkaStreamsAllInOne {
270239
}
271240
}
272241
```
242+
243+
## scalatest-embedded-schema-registry
244+
245+
If you need to serialize and deserialize messages using Avro, a [Confluent Schema Registry](https://docs.confluent.io/current/schema-registry/docs/index.html) instance can be provided to test your code.
246+
247+
### How to use
248+
249+
* In your `build.sbt` file add the following resolver: `resolvers += "confluent" at "https://packages.confluent.io/maven/"`
250+
* In your `build.sbt` file add the following dependency: `"net.manub" %% "scalatest-embedded-schema-registry" % "1.1.0-kafka1.1-nosr" % "test"`
251+
* Have your `Spec` extend the `EmbeddedKafkaWithSchemaRegistry` trait.
252+
* Enclose the code that needs a running instance of Kafka within the `withRunningKafka` closure.
253+
* Provide an implicit `EmbeddedKafkaConfigWithSchemaRegistryImpl`.
254+
255+
```scala
256+
class MySpec extends WordSpec with EmbeddedKafkaWithSchemaRegistry {
257+
258+
"runs with embedded kafka and Schema Registry" should {
259+
260+
"work" in {
261+
implicit val config = EmbeddedKafkaConfigWithSchemaRegistryImpl()
262+
263+
withRunningKafka {
264+
// ... code goes here
265+
}
266+
}
267+
}
268+
}
269+
```
270+
271+
* A Schema Registry server will be started and automatically shutdown at the end of the test.
272+
273+
### Utility methods
274+
275+
The `net.manub.embeddedkafka.avro.schemaregistry` package object provides useful implicit converters for testing with Avro and Schema Registry.
276+
277+
## Using streams
278+
279+
* For most of the cases have your `Spec` extend the `EmbeddedKafkaStreamsWithSchemaRegistryAllInOne` trait. This offers both streams management and easy creation of consumers for asserting resulting messages in output/sink topics.
280+
* If you only want to use the streams management without the test consumers just have the `Spec` extend the `EmbeddedKafkaStreamsWithSchemaRegistry` trait.
281+
* Build your own `Topology` and use `runStreams` to test it.
282+
* Have a look at the [example test](schema-registry/src/test/scala/net/manub/embeddedkafka/schemaregistry/streams/ExampleKafkaStreamsSchemaRegistrySpec.scala).

0 commit comments

Comments
 (0)