mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
Reformatted tests
This commit is contained in:
@@ -53,7 +53,8 @@ public class LoggingTest {
|
|||||||
void testDisableLogsForClass_addsLoggerWithOff() {
|
void testDisableLogsForClass_addsLoggerWithOff() {
|
||||||
Logging.disableLogsForClass(LoggingTest.class);
|
Logging.disableLogsForClass(LoggingTest.class);
|
||||||
|
|
||||||
LoggerConfig loggerConfig = ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
LoggerConfig loggerConfig =
|
||||||
|
ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
||||||
assertNotNull(loggerConfig);
|
assertNotNull(loggerConfig);
|
||||||
assertEquals(Level.OFF, loggerConfig.getLevel());
|
assertEquals(Level.OFF, loggerConfig.getLevel());
|
||||||
}
|
}
|
||||||
@@ -62,7 +63,8 @@ public class LoggingTest {
|
|||||||
void testEnableLogsForClass_addsLoggerWithLevel() {
|
void testEnableLogsForClass_addsLoggerWithLevel() {
|
||||||
Logging.enableLogsForClass(LoggingTest.class, Level.ERROR);
|
Logging.enableLogsForClass(LoggingTest.class, Level.ERROR);
|
||||||
|
|
||||||
LoggerConfig loggerConfig = ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
LoggerConfig loggerConfig =
|
||||||
|
ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
||||||
assertNotNull(loggerConfig);
|
assertNotNull(loggerConfig);
|
||||||
assertEquals(Level.ERROR, loggerConfig.getLevel());
|
assertEquals(Level.ERROR, loggerConfig.getLevel());
|
||||||
}
|
}
|
||||||
@@ -71,7 +73,8 @@ public class LoggingTest {
|
|||||||
void testEnableLogsForClass_withStringLevel() {
|
void testEnableLogsForClass_withStringLevel() {
|
||||||
Logging.enableLogsForClass(LoggingTest.class.getName(), "INFO");
|
Logging.enableLogsForClass(LoggingTest.class.getName(), "INFO");
|
||||||
|
|
||||||
LoggerConfig loggerConfig = ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
LoggerConfig loggerConfig =
|
||||||
|
ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
||||||
assertNotNull(loggerConfig);
|
assertNotNull(loggerConfig);
|
||||||
assertEquals(Level.INFO, loggerConfig.getLevel());
|
assertEquals(Level.INFO, loggerConfig.getLevel());
|
||||||
}
|
}
|
||||||
@@ -80,7 +83,8 @@ public class LoggingTest {
|
|||||||
void testEnableDebugLogsForClass_setsDebug() {
|
void testEnableDebugLogsForClass_setsDebug() {
|
||||||
Logging.enableDebugLogsForClass(LoggingTest.class);
|
Logging.enableDebugLogsForClass(LoggingTest.class);
|
||||||
|
|
||||||
LoggerConfig loggerConfig = ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
LoggerConfig loggerConfig =
|
||||||
|
ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
||||||
assertNotNull(loggerConfig);
|
assertNotNull(loggerConfig);
|
||||||
assertEquals(Level.DEBUG, loggerConfig.getLevel());
|
assertEquals(Level.DEBUG, loggerConfig.getLevel());
|
||||||
}
|
}
|
||||||
@@ -89,7 +93,8 @@ public class LoggingTest {
|
|||||||
void testEnableInfoLogsForClass_setsInfo() {
|
void testEnableInfoLogsForClass_setsInfo() {
|
||||||
Logging.enableInfoLogsForClass(LoggingTest.class);
|
Logging.enableInfoLogsForClass(LoggingTest.class);
|
||||||
|
|
||||||
LoggerConfig loggerConfig = ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
LoggerConfig loggerConfig =
|
||||||
|
ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
||||||
assertNotNull(loggerConfig);
|
assertNotNull(loggerConfig);
|
||||||
assertEquals(Level.INFO, loggerConfig.getLevel());
|
assertEquals(Level.INFO, loggerConfig.getLevel());
|
||||||
}
|
}
|
||||||
@@ -98,7 +103,8 @@ public class LoggingTest {
|
|||||||
void testDisableLogsForNonexistentClass_doesNothing() {
|
void testDisableLogsForNonexistentClass_doesNothing() {
|
||||||
Logging.disableLogsForClass("org.toop.DoesNotExist");
|
Logging.disableLogsForClass("org.toop.DoesNotExist");
|
||||||
|
|
||||||
LoggerConfig loggerConfig = ctx.getConfiguration().getLoggers().get("org.toop.DoesNotExist");
|
LoggerConfig loggerConfig =
|
||||||
|
ctx.getConfiguration().getLoggers().get("org.toop.DoesNotExist");
|
||||||
assertNull(loggerConfig); // class doesn't exist, so no logger added
|
assertNull(loggerConfig); // class doesn't exist, so no logger added
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
package org.toop.backend;
|
package org.toop.backend;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import org.toop.backend.tictactoe.ParsedCommand;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import org.junit.jupiter.api.*;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
class TcpServerTest {
|
class TcpServerTest {
|
||||||
|
|
||||||
@@ -39,7 +37,8 @@ class TcpServerTest {
|
|||||||
server.stop();
|
server.stop();
|
||||||
try {
|
try {
|
||||||
serverThread.join(1000);
|
serverThread.join(1000);
|
||||||
} catch (InterruptedException ignored) {}
|
} catch (InterruptedException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -78,16 +77,16 @@ class TcpServerTest {
|
|||||||
client.close();
|
client.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
// void testGetNewestCommand() throws InterruptedException {
|
// void testGetNewestCommand() throws InterruptedException {
|
||||||
// String command = "move 1 2";
|
// String command = "move 1 2";
|
||||||
// server.receivedQueue.put(command);
|
// server.receivedQueue.put(command);
|
||||||
//
|
//
|
||||||
// ParsedCommand parsed = server.getNewestCommand();
|
// ParsedCommand parsed = server.getNewestCommand();
|
||||||
// System.out.println(parsed);
|
// System.out.println(parsed);
|
||||||
// assertNotNull(parsed);
|
// assertNotNull(parsed);
|
||||||
// assertEquals(command, parsed.returnMessage); TODO: Test later
|
// assertEquals(command, parsed.returnMessage); TODO: Test later
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testMultipleClients() throws IOException, InterruptedException {
|
void testMultipleClients() throws IOException, InterruptedException {
|
||||||
@@ -106,4 +105,4 @@ class TcpServerTest {
|
|||||||
client1.close();
|
client1.close();
|
||||||
client2.close();
|
client2.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ package org.toop.eventbus;
|
|||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
import com.google.common.eventbus.EventBus;
|
import com.google.common.eventbus.EventBus;
|
||||||
import org.junit.jupiter.api.*;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import org.junit.jupiter.api.*;
|
||||||
|
|
||||||
class GlobalEventBusTest {
|
class GlobalEventBusTest {
|
||||||
|
|
||||||
@@ -70,16 +69,16 @@ class GlobalEventBusTest {
|
|||||||
assertFalse(called.get(), "Consumer should not be called after unregister");
|
assertFalse(called.get(), "Consumer should not be called after unregister");
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
// void testPost_storesEventInRegistry() {
|
// void testPost_storesEventInRegistry() {
|
||||||
// // Simple EventMeta check
|
// // Simple EventMeta check
|
||||||
// class MyEvent {}
|
// class MyEvent {}
|
||||||
//
|
//
|
||||||
// MyEvent event = new MyEvent();
|
// MyEvent event = new MyEvent();
|
||||||
// GlobalEventBus.post(event);
|
// GlobalEventBus.post(event);
|
||||||
//
|
//
|
||||||
// EventMeta<MyEvent> stored = EventRegistry.getStoredEvent(MyEvent.class);
|
// EventMeta<MyEvent> stored = EventRegistry.getStoredEvent(MyEvent.class);
|
||||||
// assertNotNull(stored, "EventMeta should be stored");
|
// assertNotNull(stored, "EventMeta should be stored");
|
||||||
// assertEquals(event, stored.event(), "Stored event should match the posted one");
|
// assertEquals(event, stored.event(), "Stored event should match the posted one");
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,26 +35,26 @@ class BoundsTest {
|
|||||||
@Test
|
@Test
|
||||||
void testCheckInsideBounds() {
|
void testCheckInsideBounds() {
|
||||||
// Points inside the bounds
|
// Points inside the bounds
|
||||||
assertTrue(bounds.check(10, 20)); // top-left corner
|
assertTrue(bounds.check(10, 20)); // top-left corner
|
||||||
assertTrue(bounds.check(110, 70)); // bottom-right corner
|
assertTrue(bounds.check(110, 70)); // bottom-right corner
|
||||||
assertTrue(bounds.check(60, 45)); // inside
|
assertTrue(bounds.check(60, 45)); // inside
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCheckOutsideBounds() {
|
void testCheckOutsideBounds() {
|
||||||
// Points outside the bounds
|
// Points outside the bounds
|
||||||
assertFalse(bounds.check(9, 20)); // left
|
assertFalse(bounds.check(9, 20)); // left
|
||||||
assertFalse(bounds.check(10, 19)); // above
|
assertFalse(bounds.check(10, 19)); // above
|
||||||
assertFalse(bounds.check(111, 70)); // right
|
assertFalse(bounds.check(111, 70)); // right
|
||||||
assertFalse(bounds.check(110, 71)); // below
|
assertFalse(bounds.check(110, 71)); // below
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCheckOnEdgeBounds() {
|
void testCheckOnEdgeBounds() {
|
||||||
// Points on the edges should be considered inside
|
// Points on the edges should be considered inside
|
||||||
assertTrue(bounds.check(10, 20)); // top-left
|
assertTrue(bounds.check(10, 20)); // top-left
|
||||||
assertTrue(bounds.check(110, 20)); // top-right
|
assertTrue(bounds.check(110, 20)); // top-right
|
||||||
assertTrue(bounds.check(10, 70)); // bottom-left
|
assertTrue(bounds.check(10, 70)); // bottom-left
|
||||||
assertTrue(bounds.check(110, 70)); // bottom-right
|
assertTrue(bounds.check(110, 70)); // bottom-right
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,4 +79,4 @@ class GameBaseTest {
|
|||||||
assertEquals(GameBase.State.INVALID, game.play(-1));
|
assertEquals(GameBase.State.INVALID, game.play(-1));
|
||||||
assertEquals(GameBase.State.INVALID, game.play(9));
|
assertEquals(GameBase.State.INVALID, game.play(9));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user