Skip to content

Commit

Permalink
fix itest due to missing dependency and with Xstream default serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
zambrovski committed Feb 29, 2024
1 parent 1065eb7 commit 87435ef
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
6 changes: 6 additions & 0 deletions serializer/spring-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.axonframework</groupId>
<artifactId>axon-spring-boot-starter</artifactId>
<scope>test</scope>
</dependency>


</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,29 @@ import bankaccount.event.MoneyWithdrawn
import bankaccount.projection.CurrentBalanceProjection
import bankaccount.query.BankAccountAuditQuery
import bankaccount.query.CurrentBalanceQueries
import io.holixon.avro.adapter.common.AvroAdapterDefault
import com.thoughtworks.xstream.XStream
import com.thoughtworks.xstream.security.AnyTypePermission
import io.holixon.avro.adapter.common.registry.InMemoryAvroSchemaReadOnlyRegistry
import io.holixon.axon.avro.serializer.AvroSerializer
import io.holixon.axon.avro.serializer.spring.AxonAvroSerializerConfiguration
import io.holixon.axon.avro.serializer.spring.AxonAvroSerializerSpringBase
import io.holixon.axon.avro.serializer.spring.AxonAvroSerializerSpringBase.PROFILE_ITEST
import io.holixon.axon.avro.serializer.spring.container.AxonServerContainer
import mu.KLogging
import org.assertj.core.api.Assertions.assertThat
import org.awaitility.kotlin.await
import org.axonframework.commandhandling.gateway.CommandGateway
import org.axonframework.queryhandling.QueryGateway
import org.axonframework.serialization.Serializer
import org.axonframework.serialization.xml.CompactDriver
import org.axonframework.serialization.xml.XStreamSerializer
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Import
import org.springframework.context.annotation.Profile
import org.springframework.context.annotation.*
import org.springframework.test.context.ActiveProfiles
import org.springframework.test.context.DynamicPropertyRegistry
import org.springframework.test.context.DynamicPropertySource
Expand Down Expand Up @@ -60,6 +63,15 @@ internal class AxonAvroSerializerConfigurationITest {
@Autowired
lateinit var auditEventQuery: BankAccountAuditQuery

@Autowired
@Qualifier("eventSerializer")
lateinit var eventSerializer: Serializer

@BeforeEach
internal fun ensure_serializer() {
assertThat(eventSerializer).isInstanceOf(AvroSerializer::class.java)
}

@Test
internal fun `create account and deposit money`() {
val accountId = UUID.randomUUID().toString()
Expand Down Expand Up @@ -94,6 +106,13 @@ internal class AxonAvroSerializerConfigurationITest {
@Profile(PROFILE_ITEST)
class AxonAvroSerializerConfigurationITestApplication {

private val serializer = XStreamSerializer
.builder()
.xStream(XStream(CompactDriver())
.apply { addPermission(AnyTypePermission()) })
.disableAxonTypeSecurity()
.build()

@Bean
fun projection() = CurrentBalanceProjection()

Expand All @@ -109,4 +128,14 @@ class AxonAvroSerializerConfigurationITestApplication {

@Bean
fun bankAccountAuditEventQuery(queryGateway: QueryGateway): BankAccountAuditQuery = BankAccountAuditQuery.create(queryGateway)


@Bean
@Primary
@Qualifier("defaultSerializer")
fun defaultSerializer(): Serializer = serializer

@Bean
@Qualifier("messageSerializer")
fun messageSerializer(): Serializer = serializer
}

0 comments on commit 87435ef

Please sign in to comment.