Search in sources :

Example 6 with AnotherTestEvent

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);
}
Also used : AnotherTestEvent(org.springframework.context.event.test.AnotherTestEvent) Test(org.junit.Test)

Example 7 with AnotherTestEvent

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);
}
Also used : AnotherTestEvent(org.springframework.context.event.test.AnotherTestEvent) Test(org.junit.Test)

Example 8 with AnotherTestEvent

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);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) AnotherTestEvent(org.springframework.context.event.test.AnotherTestEvent) Test(org.junit.Test)

Example 9 with AnotherTestEvent

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);
}
Also used : AnotherTestEvent(org.springframework.context.event.test.AnotherTestEvent) Test(org.junit.Test)

Example 10 with AnotherTestEvent

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);
}
Also used : AnotherTestEvent(org.springframework.context.event.test.AnotherTestEvent) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)10 AnotherTestEvent (org.springframework.context.event.test.AnotherTestEvent)10 LinkedHashSet (java.util.LinkedHashSet)1 TestEvent (org.springframework.context.event.test.TestEvent)1