Added port checking in test suite.
Change-Id: Ia246f5f35364f6b7b93548dbb34d0a40b595ae56
diff --git a/lite/src/main/resources/log4j2.properties b/lite/src/main/resources/log4j2.properties
index 6692040..f5e5366 100644
--- a/lite/src/main/resources/log4j2.properties
+++ b/lite/src/main/resources/log4j2.properties
@@ -14,6 +14,12 @@
rootLogger.appenderRefs = stdout
rootLogger.appenderRef.stdout.ref = STDOUT
+loggers=console
+logger.console.name=com.sun.jersey.test.framework.spi.container
+logger.console.level = info
+logger.console.appenderRefs = stdout
+logger.console.appenderRef.file.ref = STDOUT
+
#loggers=file
#logger.file.name=de.ids_mannheim.korap
#logger.file.level = error
diff --git a/lite/src/test/java/de/ids_mannheim/korap/web/service/LiteServiceTest.java b/lite/src/test/java/de/ids_mannheim/korap/web/service/LiteServiceTest.java
index 42f6ebc..9ea02c7 100644
--- a/lite/src/test/java/de/ids_mannheim/korap/web/service/LiteServiceTest.java
+++ b/lite/src/test/java/de/ids_mannheim/korap/web/service/LiteServiceTest.java
@@ -1,13 +1,15 @@
package de.ids_mannheim.korap.web.service;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.util.Iterator;
import java.util.concurrent.ThreadLocalRandom;
-import java.util.*;
import org.apache.lucene.LucenePackage;
import org.junit.Test;
@@ -60,7 +62,16 @@
@Override
protected int getPort (int defaultPort) {
- return ThreadLocalRandom.current().nextInt(5000, 8000 + 1);
+ int port = ThreadLocalRandom.current().nextInt(5000, 8000 + 1);
+ try {
+ ServerSocket socket = new ServerSocket(port);
+ socket.close();
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ port = getPort(port);
+ }
+ return port;
}
@Test