From d2e35e239a5dbfbe27e9b52f826b4bad733ccd24 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 9 Mar 2017 06:51:57 -0700 Subject: [PATCH 1/4] Windows Test Issue + Changing from @Test(expect=) to @Rule ExpectedException for ... * no exception occuring when one is expected is a test failure * wrong exception is a test failure * wrong cause is a test failure --- .../jetty/client/HttpClientURITest.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientURITest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientURITest.java index 4f175384f1b..00d6feb8a85 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientURITest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientURITest.java @@ -18,6 +18,8 @@ package org.eclipse.jetty.client; +import static org.hamcrest.CoreMatchers.instanceOf; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -47,10 +49,15 @@ import org.eclipse.jetty.util.Fields; import org.eclipse.jetty.util.URIUtil; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.junit.Assert; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; public class HttpClientURITest extends AbstractHttpClientServerTest { + @Rule + public ExpectedException expectedException = ExpectedException.none(); + public HttpClientURITest(SslContextFactory sslContextFactory) { super(sslContextFactory); @@ -74,14 +81,15 @@ public class HttpClientURITest extends AbstractHttpClientServerTest Assert.assertEquals(HttpStatus.OK_200, request.send().getStatus()); } - @Test(expected = IllegalArgumentException.class) + @Test public void testIDNHost() throws Exception { startClient(); + expectedException.expect(IllegalArgumentException.class); client.newRequest(scheme + "://пример.рф"); // example.com-like host in IDN domain } - @Test(expected = IllegalArgumentException.class) + @Test public void testIDNRedirect() throws Exception { // Internationalized Domain Name. @@ -104,19 +112,12 @@ public class HttpClientURITest extends AbstractHttpClientServerTest HttpField location = response.getHeaders().getField(HttpHeader.LOCATION); Assert.assertEquals(incorrectlyDecoded, location.getValue()); - try - { - client.newRequest("localhost", server.getLocalPort()) - .timeout(5, TimeUnit.SECONDS) - .followRedirects(true) - .send(); - } - catch (ExecutionException x) - { - Throwable cause = x.getCause(); - if (cause instanceof IllegalArgumentException) - throw (IllegalArgumentException)cause; - } + expectedException.expect(ExecutionException.class); + expectedException.expectCause(instanceOf(IllegalArgumentException.class)); + client.newRequest("localhost", server.getLocalPort()) + .timeout(5, TimeUnit.SECONDS) + .followRedirects(true) + .send(); } finally { From 76c6377ed7bd56775b599feb44782811328ed366 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 9 Mar 2017 06:58:45 -0700 Subject: [PATCH 2/4] Windows Test Issue + Adding slf4j-simple to test scope to attempt to capture reason for the test setup failure: "org.osgi.framework.BundleException: Error while renaming bundle file to final location C:\" --- jetty-osgi/test-jetty-osgi/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jetty-osgi/test-jetty-osgi/pom.xml b/jetty-osgi/test-jetty-osgi/pom.xml index 00c35b7e6f7..8af07c1c15f 100644 --- a/jetty-osgi/test-jetty-osgi/pom.xml +++ b/jetty-osgi/test-jetty-osgi/pom.xml @@ -385,6 +385,12 @@ jetty-test-helper test + + org.slf4j + slf4j-simple + ${slf4j-version} + test + From e796063acea316df4d2ad27cd43d2c8126500fdc Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 9 Mar 2017 07:43:26 -0700 Subject: [PATCH 3/4] Issue #1049 - Upgrading paxexam, downgrading surefire --- jetty-osgi/test-jetty-osgi/pom.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jetty-osgi/test-jetty-osgi/pom.xml b/jetty-osgi/test-jetty-osgi/pom.xml index 8af07c1c15f..b8175b78350 100644 --- a/jetty-osgi/test-jetty-osgi/pom.xml +++ b/jetty-osgi/test-jetty-osgi/pom.xml @@ -14,7 +14,7 @@ ${project.groupId}.boot.test.osgi http://download.eclipse.org/jetty/orbit/ target/distribution - 3.5.0 + 4.9.2 1.5.2 1.0 @@ -396,6 +396,8 @@ maven-surefire-plugin + + 2.18.1 From 1eeac2af6b325d22d491a13dd3fa9d77f1fd973e Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 9 Mar 2017 14:17:05 -0700 Subject: [PATCH 4/4] Fixing test --- .../websocket/client/ClientCloseTest.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientCloseTest.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientCloseTest.java index 633439e55a6..78d9681513f 100644 --- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientCloseTest.java +++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientCloseTest.java @@ -19,7 +19,6 @@ package org.eclipse.jetty.websocket.client; import static org.hamcrest.Matchers.allOf; -import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; @@ -103,7 +102,7 @@ public class ClientCloseTest public void assertReceivedCloseEvent(int clientTimeoutMs, Matcher statusCodeMatcher, Matcher reasonMatcher) throws InterruptedException { - long maxTimeout = clientTimeoutMs * 2; + long maxTimeout = clientTimeoutMs * 4; assertThat("Client Close Event Occurred",closeLatch.await(maxTimeout,TimeUnit.MILLISECONDS),is(true)); assertThat("Client Close Event Count",closeCount.get(),is(1)); @@ -144,7 +143,7 @@ public class ClientCloseTest @Override public void onWebSocketError(Throwable cause) { - LOG.debug("onWebSocketError",cause); + LOG.warn("onWebSocketError",cause); assertThat("Unique Error Event", error.compareAndSet(null, cause), is(true)); errorLatch.countDown(); } @@ -417,16 +416,11 @@ public class ClientCloseTest writeCount++; writeSize += msg.length; } - LOG.debug("Wrote {} frames totalling {} bytes of payload before congestion kicked in",writeCount,writeSize); + LOG.info("Wrote {} frames totalling {} bytes of payload before congestion kicked in",writeCount,writeSize); - // Verify that there are no errors - assertThat("Error events",clientSocket.error.get(),nullValue()); - - // client idle timeout triggers close event on client ws-endpoint - // client close event on ws-endpoint - clientSocket.assertReceivedCloseEvent(timeout, - anyOf(is(StatusCode.SHUTDOWN),is(StatusCode.ABNORMAL)), - anyOf(containsString("Timeout"),containsString("timeout"),containsString("Write"))); + // Verify timeout error + assertThat("OnError Latch", clientSocket.errorLatch.await(2, TimeUnit.SECONDS), is(true)); + assertThat("OnError", clientSocket.error.get(), instanceOf(SocketTimeoutException.class)); } @Test