-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add docs for kafka and arrange tests
- Loading branch information
Showing
15 changed files
with
153 additions
and
41 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
docs/how-to-write-tests/1.Application-Aware/2.Ktor/index.md
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,3 +1,72 @@ | ||
# 2. Ktor | ||
|
||
[Here](https://github.com/Trendyol/stove/tree/main/examples/ktor-example) you can jump immediately to the Ktor example application. | ||
|
||
## Deps | ||
|
||
=== "Gradle" | ||
|
||
```kotlin | ||
dependencies { | ||
testImplementation("com.trendyol:stove-ktor-testing-e2e:$version") | ||
} | ||
``` | ||
|
||
=== "Maven" | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.trendyol</groupId> | ||
<artifactId>stove-ktor-testing-e2e</artifactId> | ||
<version>${stove-version}</version> | ||
</dependency> | ||
``` | ||
|
||
## Example Setup | ||
|
||
```kotlin | ||
TestSystem(baseUrl = "http://localhost:8080") | ||
.with { | ||
httpClient() | ||
bridge() | ||
postgresql { | ||
PostgresqlOptions(configureExposedConfiguration = { cfg -> | ||
listOf( | ||
"database.jdbcUrl=${cfg.jdbcUrl}", | ||
"database.host=${cfg.host}", | ||
"database.port=${cfg.port}", | ||
"database.name=${cfg.database}", | ||
"database.username=${cfg.username}", | ||
"database.password=${cfg.password}" | ||
) | ||
}) | ||
} | ||
kafka { | ||
stoveKafkaObjectMapperRef = objectMapperRef | ||
KafkaSystemOptions { | ||
listOf( | ||
"kafka.bootstrapServers=${it.bootstrapServers}" | ||
) | ||
} | ||
} | ||
wiremock { | ||
WireMockSystemOptions( | ||
port = 9090, | ||
removeStubAfterRequestMatched = true, | ||
afterRequest = { e, _ -> | ||
logger.info(e.request.toString()) | ||
} | ||
) | ||
} | ||
ktor( | ||
withParameters = listOf( | ||
"port=8080" | ||
), | ||
runner = { parameters -> | ||
stove.ktor.example.run(parameters) { | ||
addTestSystemDependencies() | ||
} | ||
} | ||
) | ||
}.run() | ||
``` |
File renamed without changes.
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,73 @@ | ||
# Kafka | ||
|
||
## Prerequisites | ||
|
||
### 1. Docker Image | ||
|
||
```shell | ||
docker buildx imagetools create confluentinc/cp-kafka:latest --tag YOUR_REGISTRY/confluentinc/cp-kafka:latest | ||
``` | ||
|
||
### 2. Library | ||
|
||
=== "Gradle" | ||
|
||
``` kotlin | ||
dependencies { | ||
testImplementation("com.trendyol:stove-testing-e2e-kafka:$version") | ||
} | ||
``` | ||
|
||
=== "Maven" | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.trendyol</groupId> | ||
<artifactId>stove-testing-e2e-kafka</artifactId> | ||
<version>${stove-version}</version> | ||
</dependency> | ||
``` | ||
|
||
## Configure | ||
|
||
```kotlin | ||
TestSystem(baseUrl = "http://localhost:8080") | ||
.with { | ||
// ... other deps ... | ||
bridge() | ||
kafka { | ||
stoveKafkaObjectMapperRef = objectMapperRef | ||
KafkaSystemOptions { | ||
listOf( | ||
"kafka.bootstrapServers=${it.bootstrapServers}", | ||
"kafka.interceptorClasses=com.trendyol.stove.testing.e2e.standalone.kafka.intercepting.StoveKafkaBridge" | ||
) | ||
} | ||
} | ||
}.run() | ||
|
||
``` | ||
|
||
### Configuring Object Mapper | ||
|
||
Like every `SystemOptions` object, `KafkaSystemOptions` has a `stoveKafkaObjectMapperRef` field. You can set your own | ||
object mapper to this field. If you don't set it, Stove will use its default object mapper. | ||
|
||
```kotlin | ||
var stoveKafkaObjectMapperRef: ObjectMapper = StoveObjectMapper.Default | ||
``` | ||
|
||
### Kafka Bridge With Your Application | ||
|
||
Stove Kafka bridge is a **MUST** to work with Kafka. Otherwise you can't assert any messages from your application. | ||
|
||
As you can see in the example above, you need to add a support to your application to work with interceptor that Stove provides. | ||
|
||
```kotlin | ||
"kafka.interceptorClasses=com.trendyol.stove.testing.e2e.standalone.kafka.intercepting.StoveKafkaBridge" | ||
``` | ||
|
||
!!! Important | ||
`kafka.` prefix is an assumption that you can change it with your own prefix. | ||
|
||
Make sure that `StoveKafkaBridge` is in your classpath. |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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