How to SpringBoot test service with AxonServer?

Hey folks,

I have a SpringBoot app designed to be used with AxonServer. One particular case, that I would like to test, is that an Aggregate cannot be created twice, when the create command with the same AggregateIdentifier is sent and that my REST-API returns an appropriate HttpStatus

This case is answered by AxonServer with an AxonServerRemoteCommandHandlingException wrapped in CommandExecutionException and that is what my error handling is based on.

I tried different ways how to test that in a SpringBoot integration test:

  • AxonServer in Testcontainers - behaves exactly the same, but is really slow and required dind when it should run in pipelines
  • InMemoryEventStorageEngine - this case isn’t handled at all, both commands are executed without any exception
  • JpaEventStore with InMemory H2 - sending the 2nd command results in JdbcSQLIntegrityConstraintViolationException wrapped in AggregateStreamCreationException. So it somehow behaves correctly, but my error handling does not recognize that, so the test is pretty useless.

So what’s the best way to test that? Is Testcontainers really the only way? Why do the different implementations behave differently or, if they behave the same, throw different exceptions?

Any input would be appreciated!

Cheers,
Stefan