Remove scheduling test

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2022-01-21 21:06:09 +01:00
parent 8778e32700
commit 19be2546e6

View File

@ -1,16 +1,12 @@
package net.minestom.server;
import net.minestom.server.thread.TickSchedulerThread;
import net.minestom.server.timer.TaskSchedule;
import org.junit.jupiter.api.Test;
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 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 {
@ -31,29 +27,4 @@ public class ServerProcessTest {
assertDoesNotThrow(() -> ticker.tick(System.currentTimeMillis()));
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());
}
}