Skip to content

Commit e50257f

Browse files
committed
feat(#821): docs
1 parent 3d1fb6f commit e50257f

File tree

8 files changed

+485
-140
lines changed

8 files changed

+485
-140
lines changed

docs/Components/02-kafka.md

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -230,28 +230,52 @@ messages.
230230
When all the configuration is done, it is time to tell to application to use our `TestSystemInterceptor` and
231231
configuration values.
232232

233-
#### TestSystemInterceptor and TestInitializer
233+
#### TestSystemInterceptor and Bean Registration
234+
235+
Register the interceptor and serde using `addTestDependencies`:
236+
237+
**Spring Boot 2.x / 3.x:**
234238

235239
```kotlin
236-
class TestInitializer : BaseApplicationContextInitializer({
237-
bean<TestSystemInterceptor>(isPrimary = true)
238-
bean { StoveSerde.jackson.anyByteArraySerde(yourObjectMapper()) } // or any serde that implements StoveSerde<Any, ByteArray>
239-
})
240+
import com.trendyol.stove.testing.e2e.addTestDependencies
240241

241-
fun SpringApplication.addTestDependencies() {
242-
this.addInitializers(TestInitializer())
243-
}
242+
springBoot(
243+
runner = { parameters ->
244+
runApplication<MyApp>(*parameters) {
245+
addTestDependencies {
246+
bean<TestSystemInterceptor>(isPrimary = true)
247+
bean { StoveSerde.jackson.anyByteArraySerde(yourObjectMapper()) }
248+
}
249+
}
250+
},
244251
```
245252

246-
#### Configuring the SystemUnderTest and Parameters
253+
**Spring Boot 4.x:**
254+
255+
```kotlin
256+
import com.trendyol.stove.testing.e2e.addTestDependencies4x
257+
258+
springBoot(
259+
runner = { parameters ->
260+
runApplication<MyApp>(*parameters) {
261+
addTestDependencies4x {
262+
registerBean<TestSystemInterceptor>(primary = true)
263+
registerBean { StoveSerde.jackson.anyByteArraySerde(yourObjectMapper()) }
264+
}
265+
}
266+
},
267+
```
247268

248-
`addTestDependencies` is an extension that helps us to register our dependencies in the application.
269+
#### Configuring the SystemUnderTest and Parameters
249270

250-
```kotlin hl_lines="4"
271+
```kotlin hl_lines="4-8"
251272
springBoot(
252273
runner = { parameters ->
253-
com.trendyol.exampleapp.run(parameters) {
254-
addTestDependencies() // Enable TestInitializer with extensions call
274+
runApplication<MyApp>(*parameters) {
275+
addTestDependencies {
276+
bean<TestSystemInterceptor>(isPrimary = true)
277+
bean { StoveSerde.jackson.anyByteArraySerde(yourObjectMapper()) }
278+
}
255279
}
256280
},
257281
withParameters = listOf(

0 commit comments

Comments
 (0)