use of org.springframework.context.event.test.AnotherTestEvent in project spring-framework by spring-projects.
the class AnnotationDrivenEventListenerTests method asyncProcessingAppliedWithScopedProxy.
@Test
public void asyncProcessingAppliedWithScopedProxy() throws InterruptedException {
doLoad(AsyncConfigurationWithInterfaces.class, ScopedProxyTestBean.class);
String threadName = Thread.currentThread().getName();
AnotherTestEvent event = new AnotherTestEvent(this, threadName);
SimpleService listener = this.context.getBean(SimpleService.class);
this.eventCollector.assertNoEventReceived(listener);
this.context.publishEvent(event);
this.countDownLatch.await(2, TimeUnit.SECONDS);
this.eventCollector.assertEvent(listener, event);
this.eventCollector.assertTotalEventsCount(1);
}
use of org.springframework.context.event.test.AnotherTestEvent in project spring-framework by spring-projects.
the class AnnotationDrivenEventListenerTests method arrayReply.
@Test
public void arrayReply() {
load(TestEventListener.class, ReplyEventListener.class);
AnotherTestEvent event = new AnotherTestEvent(this, new String[] { "first", "second" });
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
TestEventListener listener = this.context.getBean(TestEventListener.class);
this.eventCollector.assertNoEventReceived(listener);
this.eventCollector.assertNoEventReceived(replyEventListener);
this.context.publishEvent(event);
this.eventCollector.assertEvent(replyEventListener, event);
// reply
this.eventCollector.assertEvent(listener, "first", "second");
this.eventCollector.assertTotalEventsCount(3);
}
use of org.springframework.context.event.test.AnotherTestEvent in project spring-framework by spring-projects.
the class AnnotationDrivenEventListenerTests method replyWithPayload.
@Test
public void replyWithPayload() {
load(TestEventListener.class, ReplyEventListener.class);
AnotherTestEvent event = new AnotherTestEvent(this, "String");
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
TestEventListener listener = this.context.getBean(TestEventListener.class);
this.eventCollector.assertNoEventReceived(listener);
this.eventCollector.assertNoEventReceived(replyEventListener);
this.context.publishEvent(event);
this.eventCollector.assertEvent(replyEventListener, event);
// reply
this.eventCollector.assertEvent(listener, "String");
this.eventCollector.assertTotalEventsCount(2);
}
use of org.springframework.context.event.test.AnotherTestEvent in project spring-framework by spring-projects.
the class AnnotationDrivenEventListenerTests method exceptionNotPropagatedWithAsync.
@Test
public void exceptionNotPropagatedWithAsync() throws InterruptedException {
loadAsync(ExceptionEventListener.class);
AnotherTestEvent event = new AnotherTestEvent(this, "fail");
ExceptionEventListener listener = this.context.getBean(ExceptionEventListener.class);
this.eventCollector.assertNoEventReceived(listener);
this.context.publishEvent(event);
this.countDownLatch.await(2, TimeUnit.SECONDS);
this.eventCollector.assertEvent(listener, event);
this.eventCollector.assertTotalEventsCount(1);
}
use of org.springframework.context.event.test.AnotherTestEvent in project spring-framework by spring-projects.
the class AnnotationDrivenEventListenerTests method simpleReply.
@Test
public void simpleReply() {
load(TestEventListener.class, ReplyEventListener.class);
AnotherTestEvent event = new AnotherTestEvent(this, "dummy");
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
TestEventListener listener = this.context.getBean(TestEventListener.class);
this.eventCollector.assertNoEventReceived(listener);
this.eventCollector.assertNoEventReceived(replyEventListener);
this.context.publishEvent(event);
this.eventCollector.assertEvent(replyEventListener, event);
// reply
this.eventCollector.assertEvent(listener, new TestEvent(replyEventListener, event.getId(), "dummy"));
this.eventCollector.assertTotalEventsCount(2);
}
Aggregations