Skip to content

Instantly share code, notes, and snippets.

@SpringBootTest
@AutoConfigureMockMvc
class AxonIntegrationTest(@Autowired val mockMvc: MockMvc) {
@Test
fun `some test`() {
// ...
}
// ...
}
axon.axonserver.enabled: false
dependencies {
// ...
implementation("org.axonframework:axon-spring-boot-starter:4.3.5")
// ...
}
configurations {
testImplementation.get().exclude(group = "org.axonframework", module = "axon-server-connector")
}
dependencies {
// ...
implementation("org.axonframework:axon-spring-boot-starter:4.3.5") {
exclude(group = "org.axonframework", module = "axon-server-connector")
}
// ...
}
@SpringBootTest
@AutoConfigureMockMvc
@Testcontainers
class AxonIntegrationTest(@Autowired val mockMvc: MockMvc) {
companion object {
@Container val axon = AxonServerContainer
}
@Test
object AxonServerContainer : GenericContainer<AxonServerContainer>("axoniq/axonserver") {
init {
withExposedPorts(8024, 8124)
waitingFor(forLogMessage(".*Started AxonServer.*\\n", 1))
}
override fun start() {
super.start()
System.setProperty("axon.axonserver.servers", "localhost:${getMappedPort(8124)}")
}
@SpringBootTest
@AutoConfigureMockMvc
@Testcontainers
class AxonIntegrationTest(@Autowired val mockMvc: MockMvc) {
companion object {
@Container val axon = AxonServerContainer
@JvmStatic
@DynamicPropertySource
// defined as a singleton in kotlin
object AxonServerContainer : GenericContainer<AxonServerContainer>("axoniq/axonserver") {
init {
withExposedPorts(8024, 8124)
// the container is ready when the below log message is posted
waitingFor(forLogMessage(".*Started AxonServer.*\\n", 1))
}
// this will allow us to know which host/port to connect to
val servers: String get() = "localhost:${getMappedPort(8124)}"
data class Person(val name: String, val age: Int)
val treeSet = TreeSet<Int>()
val treeSetDescending = TreeSet<Int>(Collections.reverseOrder())
val hashSet = HashSet<Int>()
val random = Random()
repeat(10) {
val number = random.nextInt(100)
treeSet.add(number)
treeSetDescending.add(number)
hashSet.add(number)
}