简体   繁体   English

Spring Boot中针对ActiveMQ JMS侦听器的Spock测试

[英]Spock Test for ActiveMQ JMS listener in Spring Boot

I want to write spock test case for ActiveMQ JMS Listener using spring boot. 我想使用Spring Boot为ActiveMQ JMS Listener编写spock测试用例。 Can somebody share any idea how to do it. 有人可以分享任何想法如何做到这一点。 I have followed the steps mentioned here https://spring.io/guides/gs/messaging-jms/ to create the listener. 我已经按照此处提到的步骤https://spring.io/guides/gs/messaging-jms/创建了侦听器。 Below is the code for which I want to write unit test 下面是我要为其编写单元测试的代码

@JmsListener( containerFactory = "myFactory", destination =  "some q")
    public void  processMesg( OrderRequest order ) {
        -------------------------
    }

You need to write a small JMS client (or use an existing one) that will be called from your Spock test and it will connect to you JMS queue. 您需要编写一个小型的JMS客户端(或使用现有的客户端),该客户端将从您的Spock测试中调用,并且它将连接到您的JMS队列。

Details on how to do do not fit in a single answer. 有关操作方法的详细信息无法一概而论。

In general there is nothing specific about Spock and JMS. 通常,关于Spock和JMS并没有特定的细节。 You need to have the capability to send custom JMS messages anyway, regardless of the test framework you will use in the end. 无论最终要使用哪种测试框架,您都必须具有发送自定义JMS消息的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM