From aba3a41a34bf5760ea3707dcf2b7a562af1091df Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 4 Nov 2013 16:50:18 -0700 Subject: [PATCH] More fixes for Windows build --- .gitattributes | 3 ++- .../eclipse/jetty/client/HttpClientTest.java | 9 ++++++++- .../jetty/client/ssl/SslBytesServerTest.java | 5 ++++- .../websocket/client/ClientConnectTest.java | 19 ++++++++++++++++--- .../server/AnnotatedMaxMessageSizeTest.java | 2 +- 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/.gitattributes b/.gitattributes index 21f118a8c8a..362c7b13a4a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ *.sh eol=lf *.bat eol=crlf -*.txt eol=lf \ No newline at end of file +*.txt eol=lf +*.js eol=lf \ No newline at end of file diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java index d4436ee638c..35248c344c8 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java @@ -20,6 +20,7 @@ package org.eclipse.jetty.client; import static java.nio.file.StandardOpenOption.CREATE; +import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.net.HttpCookie; @@ -63,15 +64,21 @@ import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.server.handler.AbstractHandler; +import org.eclipse.jetty.toolchain.test.FS; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; +import org.eclipse.jetty.toolchain.test.TestingDir; import org.eclipse.jetty.toolchain.test.annotation.Slow; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.junit.Assert; +import org.junit.Rule; import org.junit.Test; public class HttpClientTest extends AbstractHttpClientServerTest { + @Rule + public TestingDir testdir = new TestingDir(); + public HttpClientTest(SslContextFactory sslContextFactory) { super(sslContextFactory); @@ -508,7 +515,7 @@ public class HttpClientTest extends AbstractHttpClientServerTest start(new EmptyServerHandler()); // Prepare a big file to upload - Path targetTestsDir = MavenTestingUtils.getTargetTestingDir().toPath(); + Path targetTestsDir = testdir.getEmptyDir().toPath(); Files.createDirectories(targetTestsDir); Path file = Paths.get(targetTestsDir.toString(), "http_client_conversation.big"); try (OutputStream output = Files.newOutputStream(file, CREATE)) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/SslBytesServerTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/SslBytesServerTest.java index 0cb191dcb65..424ac6efdce 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/SslBytesServerTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/SslBytesServerTest.java @@ -1109,7 +1109,10 @@ public class SslBytesServerTest extends SslBytesTest @Test public void testRequestWithBigContentReadBlockedThenReset() throws Exception { - final SSLSocket client = newClient(); + // Don't run on Windows (buggy JVM) + Assume.assumeTrue(!OS.IS_WINDOWS); + + final SSLSocket client = newClient(); SimpleProxy.AutomaticFlow automaticProxyFlow = proxy.startAutomaticFlow(); client.startHandshake(); diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientConnectTest.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientConnectTest.java index b11f0644b01..06fae5f46aa 100644 --- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientConnectTest.java +++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientConnectTest.java @@ -25,6 +25,7 @@ import static org.hamcrest.Matchers.notNullValue; import java.io.IOException; import java.net.ConnectException; +import java.net.SocketTimeoutException; import java.net.URI; import java.util.List; import java.util.concurrent.ExecutionException; @@ -32,6 +33,7 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.eclipse.jetty.toolchain.test.OS; import org.eclipse.jetty.toolchain.test.TestTracker; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.UpgradeException; @@ -62,7 +64,11 @@ public class ClientConnectTest { // Validate thrown cause Throwable cause = e.getCause(); - Assert.assertThat("ExecutionException.cause",cause,instanceOf(errorClass)); + if(!errorClass.isInstance(cause)) + { + cause.printStackTrace(System.err); + Assert.assertThat("ExecutionException.cause",cause,instanceOf(errorClass)); + } // Validate websocket captured cause Assert.assertThat("Error Queue Length",wsocket.errorQueue.size(),greaterThanOrEqualTo(1)); @@ -354,8 +360,15 @@ public class ClientConnectTest } catch (ExecutionException e) { - // Expected path - java.net.ConnectException - assertExpectedError(e,wsocket,ConnectException.class); + if(OS.IS_WINDOWS) + { + // On windows, this is a SocketTimeoutException + assertExpectedError(e, wsocket, SocketTimeoutException.class); + } else + { + // Expected path - java.net.ConnectException + assertExpectedError(e,wsocket,ConnectException.class); + } } } diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/AnnotatedMaxMessageSizeTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/AnnotatedMaxMessageSizeTest.java index c39cf357f8f..fd44ddcd0cd 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/AnnotatedMaxMessageSizeTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/AnnotatedMaxMessageSizeTest.java @@ -108,7 +108,7 @@ public class AnnotatedMaxMessageSizeTest } } - @Test + @Test(timeout=4000) public void testEchoTooBig() throws IOException, Exception { BlockheadClient client = new BlockheadClient(serverUri);