我正在使用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");
}
}