如何为JMS使用者创建集成测试

时间:2019-08-19 10:08:38

标签: java spring-boot junit activemq-artemis

我正在使用ActiveMQ Artemis从微服务发送Object,并在其他微服务中使用Object接收@JMSListener。我想测试接收器。如何模拟收到的Object?我已经尝试过了,但是由于比较失败而获得null,因此测试失败。

@RunWith(SpringRunner.class)
@SpringBootTest
public class ConsumerTests {

    @Autowired
    JmsTemplate jmsTemplate;

    @Test
    public void foo() throws JMSException {        
        this.jmsTemplate.convertAndSend("foo", "A");
        this.jmsTemplate.setReceiveTimeout(10_000);
        assertThat(this.jmsTemplate.receiveAndConvert("foo")).isEqualTo("A");
    }
}

0 个答案:

没有答案