-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flyttet sending av acknowledgments til Kafka fra ProcessingService ti…
…l Routes. Lagt til KafkaTestContainer
- Loading branch information
1 parent
41ed359
commit 8afb687
Showing
6 changed files
with
98 additions
and
36 deletions.
There are no files selected for viewing
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
33 changes: 33 additions & 0 deletions
33
ebms-provider/src/test/kotlin/no/nav/emottak/ebms/kafka/KafkaTestContainer.kt
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,33 @@ | ||
package no.nav.emottak.ebms.kafka | ||
|
||
import org.apache.kafka.clients.admin.AdminClient | ||
import org.apache.kafka.clients.admin.AdminClientConfig | ||
import org.apache.kafka.clients.admin.NewTopic | ||
import org.testcontainers.containers.KafkaContainer | ||
import org.testcontainers.utility.DockerImageName | ||
|
||
object KafkaTestContainer { | ||
private val kafkaContainer: KafkaContainer = KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.5.0")) | ||
|
||
val bootstrapServers: String | ||
get() = kafkaContainer.bootstrapServers | ||
|
||
fun start() { | ||
kafkaContainer.start() | ||
} | ||
|
||
fun stop() { | ||
kafkaContainer.stop() | ||
} | ||
|
||
fun createTopic(topicName: String, partitions: Int = 1, replicationFactor: Short = 1) { | ||
val config = mapOf( | ||
AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG to bootstrapServers | ||
) | ||
|
||
AdminClient.create(config).use { adminClient -> | ||
val newTopic = NewTopic(topicName, partitions, replicationFactor) | ||
adminClient.createTopics(listOf(newTopic)).all().get() | ||
} | ||
} | ||
} |