Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • com.hee.tis.esr.common.transactions.test

#

Class

Description

1

BaseRabbitAndMongoTxServiceTest

This abstract class has some tests which check that Rabbit and Mongo Transactions are setup correctly. It relies on the superclass having a ‘@SpringBootTest’ which refers to the Spring Boot Application (ESR microservice ) that has Rabbit and Mongo Transactions enabled and configured correctly. The test code is common but the Configuration of the Spring Boot Application will be specific to each ESR microservice. To create an instance of this test

  1. extend BaseRabbitAndMongoTxSerfviceTest

  2. use @SpringBootTest

  3. use @LocalTransactionSupport

  4. use@EnableMongoRepositories(basePackageClasses'=<YourSpringBootApplication>.class)

  5. @UseTransactionalTestContainers
    (or some other way of pulling in a Mongodb and RabbitMQ instance for testing)

Instances of this test create their own Rabbit and Mongo Resources to check that each Spring Boot application has transactions correctly configured. A concrete example of this can be found in the ESR Data Export service - the class is com.hee.tis.esr.esrdataexport.transaction.RabbitAndMongoTxServiceTest

2

LoadTransactionSupport

A Spring annotation which Enables Mongo Repositories and loads the Spring Config from TransactionTestConfig

3

TransactionTestConfig

Test Spring Bean Configuration. Creates a test queue, sets up a RabbitMQ listener which will put any messages received from the test queue into another Spring Bean which is a simple list of Strings (for testing).

4

TxMessage

A POJO which maps to the Test Mongo Collection called txmessage.

5

TxMessageRepository

A Test Spring Data Mongo Repository interface for the TxMessage POJO & txmessage collection.

6

TxRabbitAndMongoService

A Test Spring Service which is used to test Rabbit and Mongo Transactions. The process method sends RabbitMQ messages and updates MongoDB and can conditionally throw Exceptions.

7

TxTestConstants

Contains public constants like test queue names, this package name ( for Spring Scanning), Test Spring Bean names, the Spring profile name for bringing MongoDb with ReplicaSet as a a Test Container.

  • com.hee.tis.esr.common.autoconfigure

...