From 97f795160c5c0773eec05bb8370ad327807bde74 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 16 Oct 2020 13:54:27 -0500 Subject: [PATCH] Fixing windows build/test issues. --- .../jetty/server/ErrorHandlerTest.java | 32 +++++++++++++------ .../test/resources/jetty-logging.properties | 1 + .../util/resource/FileSystemResourceTest.java | 2 +- .../jetty/util/ssl/SslContextFactoryTest.java | 3 +- .../jetty/webapp/WebAppContextTest.java | 12 +++---- 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ErrorHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ErrorHandlerTest.java index 240ca45465d..539266db9df 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ErrorHandlerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ErrorHandlerTest.java @@ -38,8 +38,8 @@ import org.eclipse.jetty.server.handler.ErrorHandler; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.ajax.JSON; import org.eclipse.jetty.util.log.StacklessLogging; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -57,12 +57,12 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class ErrorHandlerTest { - static StacklessLogging stacklessLogging; - static Server server; - static LocalConnector connector; + StacklessLogging stacklessLogging; + Server server; + LocalConnector connector; - @BeforeAll - public static void before() throws Exception + @BeforeEach + public void before() throws Exception { stacklessLogging = new StacklessLogging(HttpChannel.class); server = new Server(); @@ -134,8 +134,8 @@ public class ErrorHandlerTest server.start(); } - @AfterAll - public static void after() throws Exception + @AfterEach + public void after() throws Exception { server.stop(); stacklessLogging.close(); @@ -183,11 +183,21 @@ public class ErrorHandlerTest "\r\n"); HttpTester.Response response = HttpTester.parseResponse(rawResponse); + dump(response); + assertThat("Response status code", response.getStatus(), is(404)); assertThat("Response Content-Length", response.getField(HttpHeader.CONTENT_LENGTH).getIntValue(), is(0)); assertThat("Response Content-Type", response.getField(HttpHeader.CONTENT_TYPE), is(nullValue())); } + private void dump(HttpTester.Response response) + { + System.out.println("-------------"); + System.out.println(response); + System.out.println(response.getContent()); + System.out.println(); + } + @Test public void test404AllAccept() throws Exception { @@ -291,6 +301,8 @@ public class ErrorHandlerTest HttpTester.Response response = HttpTester.parseResponse(rawResponse); +// System.out.println("response: " + response); + assertThat("Response status code", response.getStatus(), is(404)); assertThat("Response Content-Length", response.getField(HttpHeader.CONTENT_LENGTH).getIntValue(), greaterThan(0)); assertThat("Response Content-Type", response.get(HttpHeader.CONTENT_TYPE), containsString("text/html;charset=ISO-8859-1")); @@ -454,6 +466,8 @@ public class ErrorHandlerTest HttpTester.Response response = HttpTester.parseResponse(rawResponse); + System.out.println("response: " + response); + assertThat("Response status code", response.getStatus(), is(500)); assertThat("Response Content-Length", response.getField(HttpHeader.CONTENT_LENGTH).getIntValue(), greaterThan(0)); assertThat("Response Content-Type", response.get(HttpHeader.CONTENT_TYPE), containsString("text/html;charset=UTF-8")); diff --git a/jetty-server/src/test/resources/jetty-logging.properties b/jetty-server/src/test/resources/jetty-logging.properties index 21db0759fe3..184609c3a02 100644 --- a/jetty-server/src/test/resources/jetty-logging.properties +++ b/jetty-server/src/test/resources/jetty-logging.properties @@ -1,5 +1,6 @@ org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog #org.eclipse.jetty.LEVEL=DEBUG #org.eclipse.jetty.server.LEVEL=DEBUG +#org.eclipse.jetty.servlet.LEVEL=DEBUG #org.eclipse.jetty.server.ConnectionLimit.LEVEL=DEBUG #org.eclipse.jetty.server.AcceptRateLimit.LEVEL=DEBUG diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/FileSystemResourceTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/FileSystemResourceTest.java index f8d687847df..bf7e7fd6894 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/FileSystemResourceTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/FileSystemResourceTest.java @@ -188,7 +188,7 @@ public class FileSystemResourceTest final URI alias = ritem.getAlias(); if (alias == null) { - return ritem == null; + return resource.getAlias() == null; } else { diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java index d5f8da57c5f..0ce32702e06 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java @@ -18,6 +18,7 @@ package org.eclipse.jetty.util.ssl; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -260,7 +261,7 @@ public class SslContextFactoryTest cf.setTrustStorePath("/foo"); cf.start(); }); - assertThat(x.getMessage(), equalTo("/foo is not a valid keystore")); + assertThat(x.getMessage(), containsString(File.separator + "foo is not a valid keystore")); } } diff --git a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppContextTest.java b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppContextTest.java index b6b0447e1ee..93f16756412 100644 --- a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppContextTest.java +++ b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppContextTest.java @@ -327,13 +327,13 @@ public class WebAppContextTest extLibs = extLibs.toAbsolutePath(); // Absolute reference with trailing slash and glob - references.add(Arguments.of(extLibs.toString() + File.separator + "*")); + references.add(Arguments.of("absolute extLibs with glob", extLibs.toString() + File.separator + "*")); // Establish a relative extraClassPath reference String relativeExtLibsDir = MavenTestingUtils.getBasePath().relativize(extLibs).toString(); // This will be in the String form similar to "src/test/resources/ext/*" (with trailing slash and glob) - references.add(Arguments.of(relativeExtLibsDir + File.separator + "*")); + references.add(Arguments.of("relative extLibs with glob", relativeExtLibsDir + File.separator + "*")); return references.stream(); } @@ -341,9 +341,9 @@ public class WebAppContextTest /** * Test using WebAppContext.setExtraClassPath(String) with a reference to a glob */ - @ParameterizedTest + @ParameterizedTest(name = "{0}") @MethodSource("extraClasspathGlob") - public void testExtraClasspathGlob(String extraClasspathGlobReference) throws Exception + public void testExtraClasspathGlob(String description, String extraClasspathGlobReference) throws Exception { Server server = newServer(); @@ -374,7 +374,7 @@ public class WebAppContextTest { actualPaths.add(Paths.get(url.toURI())); } - assertThat("WebAppClassLoader.urls.length", actualPaths.size(), is(expectedPaths.size())); + assertThat("[" + description + "] WebAppClassLoader.urls.length", actualPaths.size(), is(expectedPaths.size())); for (Path expectedPath : expectedPaths) { boolean found = false; @@ -385,7 +385,7 @@ public class WebAppContextTest found = true; } } - assertTrue(found, "Not able to find expected jar in WebAppClassLoader: " + expectedPath); + assertTrue(found, "[" + description + "] Not able to find expected jar in WebAppClassLoader: " + expectedPath); } }