Simple Java AMQP Server
Is there a simple AMKP / broker server implementation written in Java?
I need to use it for local integration tests. I would like to start it with ant / maven and I don't need any features like clustering, persistence, performance, etc. Just mock RabbitMQ-like instance with no installation (like maven pom dependency) and configuration.
a source to share
I would argue that it is perfectly legal to write integration tests / end-to-end tests / automated user acceptance tests that test the entire application, including everything that is done in MQ. You should choose test cases that run something like this wiesely, as this dramatically slows down the feedback loop of your tests.
There is an org.apache.qpid that can simply be included in your application as an mvn / gradle (mvn central) dependency (gradle example):
testCompile 'org.apache.qpid:qpid-broker:6.0.1'
and then add Rule
one containing a ExternalResource
that starts the broker before your tests, somewhat similar to this rather simple setup:
@Rule
private static final ExternalResource embeddedAMQPBroker = new ExternalResource() {
Broker broker;
@Override
protected void before() throws Throwable {
BrokerOptions brokerOptions = new BrokerOptions();
brokerOptions.setConfigProperty("qpid.amqp_port", "55672");
broker = new Broker();
broker.startup(brokerOptions);
}
@Override
protected void after() {
broker.shutdown();
}
};
Untested as it didn't work for me because all my apps contain Jetty 9 and the QPID (still) requires Jetty <9.
a source to share
What you are looking for is AMQP Mock Object. I really don't know anything and doubt you will find anything off the shelf. If you are using JUnit for testing, then you are doing UNIT testing. Unit testing is different from integration testing and does not include actually reading / writing to the queue.
Maybe here you can rebuild your test, or even your code, to include everything but read / write to the queue?
Another option is if you wrap your AMQP in some other class for portability and then just mock that object.
a source to share