use of org.springframework.context.event.test.AnotherTestEvent in project spring-framework by spring-projects.
the class AnnotationDrivenEventListenerTests method collectionReplyNullValue.
@Test
public void collectionReplyNullValue() {
load(TestEventListener.class, ReplyEventListener.class);
AnotherTestEvent event = new AnotherTestEvent(this, Arrays.asList(null, "test"));
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);
this.eventCollector.assertEvent(listener, "test");
this.eventCollector.assertTotalEventsCount(2);
}
use of org.springframework.context.event.test.AnotherTestEvent in project spring-framework by spring-projects.
the class AnnotationDrivenEventListenerTests method asyncProcessingApplied.
@Test
public void asyncProcessingApplied() throws InterruptedException {
loadAsync(AsyncEventListener.class);
String threadName = Thread.currentThread().getName();
AnotherTestEvent event = new AnotherTestEvent(this, threadName);
AsyncEventListener listener = this.context.getBean(AsyncEventListener.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 collectionReply.
@Test
public void collectionReply() {
load(TestEventListener.class, ReplyEventListener.class);
Set<Object> replies = new LinkedHashSet<>();
replies.add("first");
replies.add(4L);
replies.add("third");
AnotherTestEvent event = new AnotherTestEvent(this, replies);
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 (no listener for 4L)
this.eventCollector.assertEvent(listener, "first", "third");
this.eventCollector.assertTotalEventsCount(3);
}
use of org.springframework.context.event.test.AnotherTestEvent in project spring-framework by spring-projects.
the class AnnotationDrivenEventListenerTests method nullReplyIgnored.
@Test
public void nullReplyIgnored() {
load(TestEventListener.class, ReplyEventListener.class);
// No response
AnotherTestEvent event = new AnotherTestEvent(this, null);
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);
this.eventCollector.assertNoEventReceived(listener);
this.eventCollector.assertTotalEventsCount(1);
}
use of org.springframework.context.event.test.AnotherTestEvent in project spring-framework by spring-projects.
the class AnnotationDrivenEventListenerTests method asyncProcessingAppliedWithInterfaceProxy.
@Test
public void asyncProcessingAppliedWithInterfaceProxy() throws InterruptedException {
doLoad(AsyncConfigurationWithInterfaces.class, SimpleProxyTestBean.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);
}
Aggregations