Address reviews on jakarta migration.
Fix JettyServerTest, init package, and some java docs.
Make scope extraction more flexible.
Bumped Kustvakt version to 0.72-SNAPSHOT
Updated changes file
Change-Id: I9ba8620e244106b706e95d82dc2e3aeaceb37ae5
diff --git a/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java b/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java
index 02c4642..95af5dc 100644
--- a/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java
@@ -59,7 +59,11 @@
QueryType.VIRTUAL_CORPUS, User.CorpusAccess.FREE,
"corpusSigle=GOE", "definition", "description", "experimental",
false, "system", null, null);
- });
+ });
+
+ assertEquals(exception.getMessage(),
+ "Converting `org.hibernate.exception.GenericJDBCException` "
+ + "to JPA `PersistenceException` : could not execute statement");
}
@Test
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/JettyServerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/JettyServerTest.java
index 0255c45..571c15c 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/JettyServerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/JettyServerTest.java
@@ -4,38 +4,43 @@
import java.io.IOException;
import java.net.HttpURLConnection;
+import java.net.ServerSocket;
import java.net.URL;
-import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.ServerConnector;
-import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ShutdownHandler;
import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
* @author margaretha
*/
-@Disabled
public class JettyServerTest {
+ static int selectedPort = 0;
+
@BeforeAll
static void testServerStarts() throws Exception {
- Server server = new Server();
- ServerConnector connector = new ServerConnector(server);
- connector.setPort(8000);
- server.setConnectors(new Connector[]{connector});
- HandlerList handlers = new HandlerList();
- handlers.addHandler(new ShutdownHandler("secret", false, true));
- server.setHandler(handlers);
+
+
+ for (int port = 1000; port <= 2000; port++) {
+ try (ServerSocket ignored = new ServerSocket(port)) {
+ selectedPort = port;
+ break;
+ } catch (IOException ignored) {
+ // Port is already in use, try the next one
+ }
+ }
+
+ Server server = new Server(selectedPort);
+ ShutdownHandler shutdownHandler = new ShutdownHandler("secret");
+ server.setHandler(shutdownHandler);
server.start();
}
-
+
@Test
public void testShutdown() throws IOException {
- URL url = new URL("http://localhost:8000/shutdown?token=secret");
+ URL url = new URL("http://localhost:"+selectedPort+"/shutdown?token=secret");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
assertEquals(200, connection.getResponseCode());
diff --git a/full/src/test/resources/test-config-icc.xml b/full/src/test/resources/test-config-icc.xml
index 466b052..9d65017 100644
--- a/full/src/test/resources/test-config-icc.xml
+++ b/full/src/test/resources/test-config-icc.xml
@@ -177,7 +177,7 @@
<constructor-arg name="properties" ref="props" />
</bean>
- <bean id="initializator" class="de.ids_mannheim.de.init.Initializator"
+ <bean id="initializator" class="de.ids_mannheim.korap.init.Initializator"
init-method="initTest">
</bean>
diff --git a/full/src/test/resources/test-config.xml b/full/src/test/resources/test-config.xml
index 6abc135..b3ae6f3 100644
--- a/full/src/test/resources/test-config.xml
+++ b/full/src/test/resources/test-config.xml
@@ -172,7 +172,7 @@
<constructor-arg name="properties" ref="props" />
</bean>
- <bean id="initializator" class="de.ids_mannheim.de.init.Initializator"
+ <bean id="initializator" class="de.ids_mannheim.korap.init.Initializator"
init-method="initTest">
</bean>
diff --git a/full/src/test/resources/test-resource-config.xml b/full/src/test/resources/test-resource-config.xml
index 8b5e7d5..28eea3e 100644
--- a/full/src/test/resources/test-resource-config.xml
+++ b/full/src/test/resources/test-resource-config.xml
@@ -16,7 +16,7 @@
http://www.springframework.org/schema/util/spring-util.xsd">
<import resource="classpath:test-config.xml"/>
- <bean id="initializator" class="de.ids_mannheim.de.init.Initializator"
+ <bean id="initializator" class="de.ids_mannheim.korap.init.Initializator"
init-method="initResourceTest">
</bean>