Example of standalone Apache Qpid (amqp) Junit Test

后端 未结 4 1456
失恋的感觉
失恋的感觉 2020-12-28 09:46

Does anyone have an example of using Apache Qpid within a standalone junit test.

Ideally I want to be able to create a queue on the fly which I can

4条回答
  •  [愿得一人]
    2020-12-28 10:27

    The Qpid project has a number of tests that use an embedded broker for testing. Whilst we use a base case to handle startup shutdown you could do the following to simply integrate a broker within your tests:

    public void setUp()
    {
            int port=1;
    
    // Config is actually a Configuaration File App Registry object, or Configuration Application Registry.
    
            ApplicationRegistry.initialise(config, port);
    
            TransportConnection.createVMBroker(port);        
    }
    
    public void test()
    {...}
    
    public void tearDown()
    {
                TransportConnection.killVMBroker(port);
                ApplicationRegistry.remove(port);
    }
    

    Then for the connection you need to specify the conectionURL for the broker. i.e. borkerlist='vm://1'

提交回复
热议问题