Search in sources :

Example 1 with AnotherTestEvent

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

Example 2 with AnotherTestEvent

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

Example 3 with AnotherTestEvent

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

Example 4 with AnotherTestEvent

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

Example 5 with AnotherTestEvent

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