3

I am looking into the spring domain event features in spring 4.2 and it looks really greate. it is however, a bit messy to test.

Given the following business logic :

public DomainEvent<Order> CreateOrder(Order order) throws OrderRejectedException {
//INSERT BUSINESS LOGIC HERE
 this.publisher.publishEvent(new OrderAccepted(order)); 
}

The publisher is inserted in the constructor, so I can mock it quite easilly,

In my junit class i would like to assert that the applicationEvent is published from my service. Idially this should be done without mocks. Does anyone know if there exists a "test publisher" that keeps all the events being published, so i can inject that in my service during test and assert on this test instance of the publisher ? I can ofcause write my own, but this sounds like a general problem so it should in MHO exist a default test instane

0 Answers0