How to set up a false queue using mockrunner to test the xml filter?

I use the mockrunner package from http://mockrunner.sourceforge.net/ to set up a false queue for JUnit testing an XML filter, which works as follows

  • sets recognized properties for the ftp server to host and receive xml input and the jms queue server that monitors jobs. Remotely there is a server waiting, which actually parses the xml after receiving a queue message.
  • creates a remote directory using ftp and starts a connection in the queue using mqconnectionfactory for the specified queue server address.
  • after entering a new entry in 2), the filter waits for a new queue message to appear, meaning that the job was completed by the remote server. The filter then captures the modified XML file from ftp and passes it to the next filter.

The JUnit test I'm working on just needs to emulate this environment by running the local ftp server and mock queue to connect the filter, then waiting for the filter to connect to the queue and place the new xml input file on the local directory through the local ftp server, wait queue messages and change the xml input a little, put the changed xml in a new directory and post another message in the queue, which means that the task is completed.

All the tutorials I found on the network used EJB and JNDI to find the queue server after it was created. If possible, I would like to get around this route by simply creating a false queue on my local machine and connecting to it in the easiest way, without using EJB and JNDI.

Thanks in advance!

+4
source share
2 answers

I would recommend taking a look at Apache Camel to create a test case. Then itโ€™s very easy to switch the test case from any of the available components and, most importantly, Camel comes with some really convenient Mock Endpoints , which makes it very easy to test complex routing logic, in particular with asynchronous operations.

If you are also using Spring, then you can start by testing these Spring unit tests with breadboard endpoints in Camel , which allow you to enter dummy endpoints to execute statements along with the ProducerTemplate object, so it is very easy to run your messages for your test case. . for example, see the last example on this page.

Start using simple endpoints such as the SEDA endpoint โ€” when you have your head around the spring / mock framework core, try using the JMS endpoint or FTP endpoints of the endpoint , etc.

+2
source

I use MockEjb , and among them there are some examples of using false queues, so take a look at info and an example. I hope this helps.

+2
source

Source: https://habr.com/ru/post/1277364/


All Articles