RootBeanDefinition listenerDef = new RootBeanDefinition(BeanThatListens.class);
listenerDef.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference("broadcaster"));
context.registerBeanDefinition("listener", listenerDef);
context.refresh();
BeanThatBroadcasts broadcaster = context.getBean("broadcaster", BeanThatBroadcasts.class);
context.publishEvent(new MyEvent(context));
assertEquals("The event was not received by the listener", 2, broadcaster.receivedCount);
context.close();
}