编写测试以验证在JMS侦听器中收到的味精(Spring-Boot)

编写测试以验证在JMS侦听器中收到的味精(Spring-Boot),第1张

编写测试以验证在JMS侦听器中收到的味精(Spring-Boot)
@SpringBootApplicationpublic class So42803627Application {    public static void main(String[] args) {        SpringApplication.run(So42803627Application.class, args);    }    @Autowired    private JmsTemplate jmsTemplate;    @JmsListener(destination = "foo")    public void handle(String in) {        this.jmsTemplate.convertAndSend("bar", in.toUpperCase());    }}

@RunWith(SpringRunner.class)@SpringBootTestpublic class So42803627ApplicationTests {    @Autowired    private JmsTemplate jmsTemplate;    @Test    public void test() {        this.jmsTemplate.convertAndSend("foo", "Hello, world!");        this.jmsTemplate.setReceiveTimeout(10_000);        assertThat(this.jmsTemplate.receiveAndConvert("bar")).isEqualTo("HELLO, WORLD!");    }}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/zaji/5675892.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存