mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-26 19:18:12 +01:00
Remove scheduling test
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
8778e32700
commit
19be2546e6
@ -1,16 +1,12 @@
|
|||||||
package net.minestom.server;
|
package net.minestom.server;
|
||||||
|
|
||||||
import net.minestom.server.thread.TickSchedulerThread;
|
|
||||||
import net.minestom.server.timer.TaskSchedule;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.concurrent.CountDownLatch;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
public class ServerProcessTest {
|
public class ServerProcessTest {
|
||||||
|
|
||||||
@ -31,29 +27,4 @@ public class ServerProcessTest {
|
|||||||
assertDoesNotThrow(() -> ticker.tick(System.currentTimeMillis()));
|
assertDoesNotThrow(() -> ticker.tick(System.currentTimeMillis()));
|
||||||
assertDoesNotThrow(process::stop);
|
assertDoesNotThrow(process::stop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void tickScheduling() {
|
|
||||||
var process = MinecraftServer.updateProcess();
|
|
||||||
process.start(new InetSocketAddress("localhost", 25568));
|
|
||||||
AtomicLong time = new AtomicLong();
|
|
||||||
AtomicInteger counter = new AtomicInteger();
|
|
||||||
|
|
||||||
CountDownLatch latch = new CountDownLatch(1);
|
|
||||||
process.scheduler().scheduleTask(() -> {
|
|
||||||
long timeNow = System.currentTimeMillis();
|
|
||||||
long lastTime = time.get();
|
|
||||||
if (lastTime != 0) {
|
|
||||||
long diff = timeNow - lastTime;
|
|
||||||
assertEquals(MinecraftServer.TICK_MS, diff, 5);
|
|
||||||
}
|
|
||||||
time.set(timeNow);
|
|
||||||
if (counter.incrementAndGet() == 10) {
|
|
||||||
process.stop();
|
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
}, TaskSchedule.nextTick(), TaskSchedule.nextTick());
|
|
||||||
new TickSchedulerThread(process).start();
|
|
||||||
assertDoesNotThrow(() -> latch.await());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user