2021年4月3日星期六

Micronaut spock test issues with embedded ActiveMQ Artemis

I'm trying to use Micronaut-jms to integrate ActiveMQ Artemis into my application. Everything worked perfectly until I started writing unit tests.

The issue I'm facing is that since my test's are annotated with @MicronautTest when I run a test the whole application boots up. All would be fine except the application will look for ActiveMQ Artemis, and as it is embedded and has not started yet, the application will throw an error and the test will fail.

Here is a demo application.

How can I ensure that the embedded ActiveMQ Artemis is available for the application?

The test itself:

@MicronautTest  class DemoControllerSpec extends Specification {        @Shared      ActiveMQServer server        void setup() {          Configuration config = new ConfigurationImpl()          config.addAcceptorConfiguration("in-vm", "vm://0")          //config.addAcceptorConfiguration("tcp", "tcp://127.0.0.1:61616")          server = new ActiveMQServerImpl(config)          server.start()      }        void 'is server active'() {          expect:          server.active      }    }  
https://stackoverflow.com/questions/66906716/micronaut-spock-test-issues-with-embedded-activemq-artemis April 01, 2021 at 10:47PM

没有评论:

发表评论