StaticApplicationContext ctx = new StaticApplicationContext();
ctx.registerSingleton("myListener", MyApplicationListener.class);
ctx.registerSingleton("myListenerAndRepo", MyApplicationListenerAndRepository.class);
ctx.refresh();
MyApplicationListener listener = ctx.getBean(MyApplicationListener.class);
MyApplicationListenerAndRepository listenerAndRepo = ctx.getBean(MyApplicationListenerAndRepository.class);
MyEvent event = new MyEvent("fubar");
ctx.publishEvent(event);
assertSame("Mismatched listener event", event, listener.getLastEvent());
assertSame("Mismatched listener&repo event", event, listenerAndRepo.getLastEvent());
List<Operation> opsList = ((OperationListCollector) spiedOperationCollector).getCollectedOperations();
assertEquals("Mismatched number of collected operations", 2, ListUtil.size(opsList));