Update tests to JUnit 5
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
package net.md_5.bungee;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import com.google.common.base.Ticker;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ThrottleTest
|
||||
{
|
||||
@@ -38,18 +38,18 @@ public class ThrottleTest
|
||||
address = new InetSocketAddress( InetAddress.getByName( null ), 0 );
|
||||
}
|
||||
|
||||
Assert.assertFalse( "Address should not be throttled", throttle.throttle( address ) ); // 1
|
||||
Assert.assertFalse( "Address should not be throttled", throttle.throttle( address ) ); // 2
|
||||
Assert.assertFalse( "Address should not be throttled", throttle.throttle( address ) ); // 3
|
||||
Assert.assertTrue( "Address should be throttled", throttle.throttle( address ) ); // The 3rd one must be throttled, but also increased the count to 4
|
||||
assertFalse( throttle.throttle( address ), "Address should not be throttled" ); // 1
|
||||
assertFalse( throttle.throttle( address ), "Address should not be throttled" ); // 2
|
||||
assertFalse( throttle.throttle( address ), "Address should not be throttled" ); // 3
|
||||
assertTrue( throttle.throttle( address ), "Address should be throttled" ); // The 3rd one must be throttled, but also increased the count to 4
|
||||
|
||||
throttle.unthrottle( address ); // We are back at 3, next attempt will make it 4 and throttle
|
||||
throttle.unthrottle( address ); // Now we are at 2, will not be throttled
|
||||
Assert.assertFalse( "Address should not be throttled", throttle.throttle( address ) ); // 3
|
||||
Assert.assertTrue( "Address should be throttled", throttle.throttle( address ) ); // 4
|
||||
assertFalse( throttle.throttle( address ), "Address should not be throttled" ); // 3
|
||||
assertTrue( throttle.throttle( address ), "Address should be throttled" ); // 4
|
||||
|
||||
// Now test expiration
|
||||
ticker.value += TimeUnit.MILLISECONDS.toNanos( 50 );
|
||||
Assert.assertFalse( "Address should not be throttled", throttle.throttle( address ) );
|
||||
assertFalse( throttle.throttle( address ), "Address should not be throttled" );
|
||||
}
|
||||
}
|
||||
|
@@ -1,13 +1,13 @@
|
||||
package net.md_5.bungee.scheduler;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import net.md_5.bungee.api.plugin.DummyPlugin;
|
||||
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
||||
import net.md_5.bungee.api.scheduler.TaskScheduler;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class SchedulerTest
|
||||
{
|
||||
@@ -31,7 +31,7 @@ public class SchedulerTest
|
||||
|
||||
latch.await( 5, TimeUnit.SECONDS );
|
||||
|
||||
Assert.assertEquals( 0, latch.getCount() );
|
||||
assertEquals( 0, latch.getCount() );
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -43,17 +43,17 @@ public class SchedulerTest
|
||||
ScheduledTask task = setup( scheduler, b );
|
||||
scheduler.cancel( task.getId() );
|
||||
Thread.sleep( 250 );
|
||||
Assert.assertFalse( b.get() );
|
||||
assertFalse( b.get() );
|
||||
|
||||
task = setup( scheduler, b );
|
||||
scheduler.cancel( task );
|
||||
Thread.sleep( 250 );
|
||||
Assert.assertFalse( b.get() );
|
||||
assertFalse( b.get() );
|
||||
|
||||
task = setup( scheduler, b );
|
||||
scheduler.cancel( task.getOwner() );
|
||||
Thread.sleep( 250 );
|
||||
Assert.assertFalse( b.get() );
|
||||
assertFalse( b.get() );
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -64,11 +64,11 @@ public class SchedulerTest
|
||||
|
||||
setup( scheduler, b );
|
||||
Thread.sleep( 250 );
|
||||
Assert.assertTrue( b.get() );
|
||||
assertTrue( b.get() );
|
||||
|
||||
b.set( false );
|
||||
Thread.sleep( 250 );
|
||||
Assert.assertTrue( b.get() );
|
||||
assertTrue( b.get() );
|
||||
}
|
||||
|
||||
private ScheduledTask setup(TaskScheduler scheduler, final AtomicBoolean hasRun)
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package net.md_5.bungee.util;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import java.net.InetSocketAddress;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class AddressUtilTest
|
||||
{
|
||||
@@ -11,9 +11,9 @@ public class AddressUtilTest
|
||||
public void testScope()
|
||||
{
|
||||
InetSocketAddress addr = new InetSocketAddress( "0:0:0:0:0:0:0:1%0", 25577 );
|
||||
Assert.assertEquals( "0:0:0:0:0:0:0:1", AddressUtil.sanitizeAddress( addr ) );
|
||||
assertEquals( "0:0:0:0:0:0:0:1", AddressUtil.sanitizeAddress( addr ) );
|
||||
|
||||
InetSocketAddress addr2 = new InetSocketAddress( "0:0:0:0:0:0:0:1", 25577 );
|
||||
Assert.assertEquals( "0:0:0:0:0:0:0:1", AddressUtil.sanitizeAddress( addr2 ) );
|
||||
assertEquals( "0:0:0:0:0:0:0:1", AddressUtil.sanitizeAddress( addr2 ) );
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user