Add EventBus test, which fails, now to fix!

This commit is contained in:
md_5 2013-05-13 18:36:12 +10:00
parent c465eca03b
commit 834ac24b38
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,42 @@
package net.md_5.bungee.api.plugin;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import java.util.concurrent.CountDownLatch;
import org.junit.Assert;
import org.junit.Test;
public class EventBusTest
{
private final EventBus bus = new EventBus();
private final CountDownLatch latch = new CountDownLatch( 1 );
@Test
public void testNestedEvents()
{
bus.register( this );
bus.post( new FirstEvent() );
}
@Subscribe
public void firstListener(FirstEvent event)
{
bus.post( new SecondEvent() );
Assert.assertEquals( latch.getCount(), 0 );
}
@Subscribe
public void secondListener(SecondEvent event)
{
latch.countDown();
}
public static class FirstEvent extends Event
{
}
public static class SecondEvent extends Event
{
}
}

View File

@ -63,6 +63,12 @@
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>