How to wait for @JMSListener annotated method to complete in JUnit

前端 未结 4 580
失恋的感觉
失恋的感觉 2021-01-22 03:50

So I am trying to get some integration testing of JMS processing, Spring (v4.1.6) based code.

It\'s a very standard Spring setup with @JmsListener annotate

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-22 04:20

    If you would add logging to the @JmsListener annotated method, you could do something like this in the test class

    @Rule
    public OutputCapture outputCapture = new OutputCapture();
    
    @Test
    public void test() {
        sendSomeMessage();
        //how to wait here for the @JMSListener method to complete
        Assertions.assertThat(outputCapture.toString()).contains("Message received.");
    }
    

提交回复
热议问题