Skip to content

Commit 5cb4c41

Browse files
committed
Fixed a few tests that failed
1 parent 2f8ffc5 commit 5cb4c41

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ dependencies {
2323
implementation("com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20240325.1")
2424
implementation("org.jline:jline:3.30.6") // for better console input handling
2525

26-
testImplementation("org.junit.jupiter:junit-jupiter:5.10.0") // using JUnit 5 (latest)
26+
testImplementation("org.junit.jupiter:junit-jupiter:5.13.4") // using JUnit 5 (latest)
27+
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
2728
}
2829

2930
tasks.test {

src/main/java/de/igslandstuhl/database/server/webserver/WebPath.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public static void registerPath(String path, RequestType type, String handlerTyp
1414
Registry.webPathRegistry().register(path, new WebPath(type, handlerType, namespaces, context, accessLevel));
1515
}
1616
public static void registerPaths() throws IOException {
17+
if (Registry.webPathRegistry().stream().count() > 0) return; // already registered
1718
ResourceLocation metaLocation = new ResourceLocation("meta", "paths", "get_paths.json");
1819
Map<String, ?> pathData = ResourceHelper.readJsonResourceAsMap(metaLocation);
1920
pathData.keySet().forEach((path) -> {

src/main/java/de/igslandstuhl/database/server/webserver/handlers/GetRequestHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public static GetResponse handleSQLRequest(GetRequest request) {
4444
}
4545

4646
public final void registerHandlers() {
47+
if (Registry.getRequestHandlerRegistry().stream().count() > 0) return; // already registered
4748
List<String> getPaths = Registry.webPathRegistry().keyStream().filter((p) -> Registry.webPathRegistry().get(p).type() == RequestType.GET).toList();
4849
for (String path : getPaths) {
4950
WebPath webPath = Registry.webPathRegistry().get(path);

src/test/java/de/igslandstuhl/database/server/webserver/AccessManagerTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import static org.junit.jupiter.api.Assertions.assertFalse;
44
import static org.junit.jupiter.api.Assertions.assertTrue;
55

6+
import java.io.IOException;
67
import java.sql.SQLException;
78

9+
import org.junit.jupiter.api.BeforeAll;
810
import org.junit.jupiter.api.BeforeEach;
911
import org.junit.jupiter.api.Test;
1012

@@ -18,6 +20,11 @@ public class AccessManagerTest {
1820
private User admin;
1921
private User anonymous;
2022

23+
@BeforeAll
24+
public static void setup() throws IOException {
25+
WebPath.registerPaths();
26+
}
27+
2128
@BeforeEach
2229
public void setupUsers() {
2330
admin = new User() {

0 commit comments

Comments
 (0)