Update tests to JUnit 5

This commit is contained in:
md_5
2023-09-23 18:44:14 +10:00
parent 0509303fd3
commit f9b75c4a3a
20 changed files with 377 additions and 409 deletions

View File

@@ -1,8 +1,8 @@
package net.md_5.bungee.event;
import static org.junit.jupiter.api.Assertions.*;
import java.util.concurrent.CountDownLatch;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class EventBusTest
{
@@ -15,14 +15,14 @@ public class EventBusTest
{
bus.register( this );
bus.post( new FirstEvent() );
Assert.assertEquals( 0, latch.getCount() );
assertEquals( 0, latch.getCount() );
}
@EventHandler
public void firstListener(FirstEvent event)
{
bus.post( new SecondEvent() );
Assert.assertEquals( 1, latch.getCount() );
assertEquals( 1, latch.getCount() );
latch.countDown();
}

View File

@@ -1,8 +1,8 @@
package net.md_5.bungee.event;
import static org.junit.jupiter.api.Assertions.*;
import java.util.concurrent.CountDownLatch;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class EventPriorityTest
{
@@ -16,41 +16,41 @@ public class EventPriorityTest
bus.register( this );
bus.register( new EventPriorityListenerPartner() );
bus.post( new PriorityTestEvent() );
Assert.assertEquals( 0, latch.getCount() );
assertEquals( 0, latch.getCount() );
}
@EventHandler(priority = Byte.MIN_VALUE)
public void onMinPriority(PriorityTestEvent event)
{
Assert.assertEquals( 7, latch.getCount() );
assertEquals( 7, latch.getCount() );
latch.countDown();
}
@EventHandler(priority = EventPriority.LOWEST)
public void onLowestPriority(PriorityTestEvent event)
{
Assert.assertEquals( 6, latch.getCount() );
assertEquals( 6, latch.getCount() );
latch.countDown();
}
@EventHandler
public void onNormalPriority(PriorityTestEvent event)
{
Assert.assertEquals( 4, latch.getCount() );
assertEquals( 4, latch.getCount() );
latch.countDown();
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onHighestPriority(PriorityTestEvent event)
{
Assert.assertEquals( 2, latch.getCount() );
assertEquals( 2, latch.getCount() );
latch.countDown();
}
@EventHandler(priority = Byte.MAX_VALUE)
public void onMaxPriority(PriorityTestEvent event)
{
Assert.assertEquals( 1, latch.getCount() );
assertEquals( 1, latch.getCount() );
latch.countDown();
}
@@ -64,14 +64,14 @@ public class EventPriorityTest
@EventHandler(priority = EventPriority.HIGH)
public void onHighPriority(PriorityTestEvent event)
{
Assert.assertEquals( 3, latch.getCount() );
assertEquals( 3, latch.getCount() );
latch.countDown();
}
@EventHandler(priority = EventPriority.LOW)
public void onLowPriority(PriorityTestEvent event)
{
Assert.assertEquals( 5, latch.getCount() );
assertEquals( 5, latch.getCount() );
latch.countDown();
}
}

View File

@@ -1,8 +1,8 @@
package net.md_5.bungee.event;
import static org.junit.jupiter.api.Assertions.*;
import java.util.concurrent.CountDownLatch;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class SubclassTest extends EventBusTest
{
@@ -14,13 +14,13 @@ public class SubclassTest extends EventBusTest
public void testNestedEvents()
{
super.testNestedEvents();
Assert.assertEquals( 0, latch.getCount() );
assertEquals( 0, latch.getCount() );
}
@EventHandler
protected void extraListener(FirstEvent event)
{
Assert.assertEquals( 1, latch.getCount() );
assertEquals( 1, latch.getCount() );
latch.countDown();
}
}

View File

@@ -1,7 +1,7 @@
package net.md_5.bungee.event;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.Test;
public class UnregisteringListenerTest
{
@@ -19,7 +19,7 @@ public class UnregisteringListenerTest
@EventHandler
public void onEvent(TestEvent evt)
{
Assert.fail( "Event listener wasn't unregistered" );
fail( "Event listener wasn't unregistered" );
}
public static class TestEvent