At the start of the application, I am creating the below channel and associated queues
@Singleton
public class ChannelPoolListener extends ChannelInitializer {
@Override
public void initialize(Channel channel) throws IOException {
channel.exchangeDeclare("micronaut", BuiltinExchangeType.DIRECT, true);
channel.queueDeclare("inventory", true, false, false, null);
channel.queueBind("inventory", "micronaut", "books.inventory");
channel.queueDeclare("catalogue", true, false, false, null);
channel.queueBind("catalogue", "micronaut", "books.catalogue");
}
}
I want to write the JUnit 5 test to check if queues are created and bind to the exchange using the rabbitMq Test container.
From the RabbitMq java API, I know we have a method for the channel. But not sure how can I inject the Channel in JUnit 5
GetResponse response = rabbitChannel.basicGet(QUEUE_NAME, BOOLEAN_NOACK);