Moved unittests to JUnit 5

This commit is contained in:
lieght
2025-09-10 22:17:27 +02:00
parent 182ee6c6f0
commit 04e7939d80
3 changed files with 14 additions and 20 deletions

View File

@@ -27,12 +27,6 @@
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>

View File

@@ -7,10 +7,9 @@ import org.toop.eventbus.GlobalEventBus;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.*;
public class TestGlobalEventBus {
public class GlobalEventBusTest {
// Sample event class
public static class TestEvent {

View File

@@ -1,50 +1,51 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.toop.server.Server;
import org.toop.server.backend.*;
public class TestServerTest {
import static org.junit.jupiter.api.Assertions.*;
public class ServerTest {
private Server server;
@Before
@BeforeEach
public void setUp() {
server = new Server(Server.ServerBackend.LOCAL, "127.0.0.1", "8080");
}
@Test
public void testConstructorSetsValues() {
Assert.assertEquals("127.0.0.1", server.getIp());
Assert.assertEquals("8080", server.getPort());
assertEquals("127.0.0.1", server.getIp());
assertEquals("8080", server.getPort());
}
@Test
public void testSetIpUpdatesValue() {
server.setIp("192.168.1.1");
Assert.assertEquals("192.168.1.1", server.getIp());
assertEquals("192.168.1.1", server.getIp());
}
@Test
public void testSetPortUpdatesValue() {
server.setPort("9090");
Assert.assertEquals("9090", server.getPort());
assertEquals("9090", server.getPort());
}
@Test
public void testSetLocalBackend() {
Assert.assertEquals(new Local(), server.getBackend());
assertEquals(new Local(), server.getBackend());
}
@Test
public void testSetRemoteBackend() {
server.setBackend(Server.ServerBackend.REMOTE);
Assert.assertEquals(new Remote(), server.getBackend());
assertEquals(new Remote(), server.getBackend());
}
@Test
public void testNotNullAfterConstruction() {
Assert.assertNotNull(server);
assertNotNull(server);
}
}