Provisional integration tests, currently setting the timeouts manually
diff --git a/pom.xml b/pom.xml
index bc5a25f..86da21d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -83,5 +83,11 @@
<version>5.4.2</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.6</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/uca/impl/IntegrationTest.java b/src/test/java/org/apache/sling/uca/impl/IntegrationTest.java
index d9a1d7c..31ba3bf 100644
--- a/src/test/java/org/apache/sling/uca/impl/IntegrationTest.java
+++ b/src/test/java/org/apache/sling/uca/impl/IntegrationTest.java
@@ -43,33 +43,30 @@
public void connectTimeout() throws IOException {
SocketTimeoutException exception = assertThrows(SocketTimeoutException.class,
- () -> assertTimeout(ofSeconds(5), () -> runTest(false))
+ () -> assertTimeout(ofSeconds(5), () -> runTest("http://sling.apache.org:81"))
);
- assertEquals("Connect timed out", exception.getMessage());
+ assertEquals("connect timed out", exception.getMessage());
}
@Test
public void readTimeout() throws IOException {
SocketTimeoutException exception = assertThrows(SocketTimeoutException.class,
- () -> assertTimeout(ofSeconds(10), () -> runTest(false))
+ () -> assertTimeout(ofSeconds(10), () -> runTest("http://localhost:" + ServerRule.getLocalPort()))
);
assertEquals("Read timed out", exception.getMessage());
}
- private void runTest(boolean shouldConnect) throws MalformedURLException, IOException {
+ private void runTest(String urlSpec) throws MalformedURLException, IOException {
- URL url = new URL("http://localhost:" + ServerRule.getLocalPort());
- LOG.info("connecting");
+ URL url = new URL(urlSpec);
+ LOG.info("connecting to {}", url);
URLConnection connection = url.openConnection();
// TODO - remove when running through the harness
connection.setConnectTimeout((int) TimeUnit.SECONDS.toMillis(3));
connection.setReadTimeout((int) TimeUnit.SECONDS.toMillis(3));
connection.connect();
- /*
- * if ( !shouldConnect ) fail("Connection should not be succesful");
- */
LOG.info("connected");
try ( InputStream is = connection.getInputStream()) {
while ( is.read() != -1)
diff --git a/src/test/java/org/apache/sling/uca/impl/ServerRule.java b/src/test/java/org/apache/sling/uca/impl/ServerRule.java
index c047afd..a799b55 100644
--- a/src/test/java/org/apache/sling/uca/impl/ServerRule.java
+++ b/src/test/java/org/apache/sling/uca/impl/ServerRule.java
@@ -44,7 +44,6 @@
private static final int LOCAL_PORT = 12312;
-
public static int getLocalPort() {
return LOCAL_PORT;
}
@@ -53,6 +52,7 @@
@Override
public void beforeAll(ExtensionContext context) throws Exception {
+
server = new Server(LOCAL_PORT);
ServerConnector connector = new ServerConnector(server) {
@Override
diff --git a/src/test/resources/simplelogger.properties b/src/test/resources/simplelogger.properties
new file mode 100644
index 0000000..6dfc7aa
--- /dev/null
+++ b/src/test/resources/simplelogger.properties
@@ -0,0 +1 @@
+org.slf4j.simpleLogger.showDateTime=true
\ No newline at end of file