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 013dfe7c039..746cc87fdfb 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
@@ -68,7 +68,6 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.EnabledOnJre;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.JRE;
@@ -82,7 +81,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.condition.OS.LINUX;
-import static org.junit.jupiter.api.condition.OS.WINDOWS;
// Other JREs have slight differences in how TLS work
// and this test expects a very specific TLS behavior.
@@ -1027,7 +1025,6 @@ public class SslBytesServerTest extends SslBytesTest
}
@Test
- @DisabledOnOs(WINDOWS) // Don't run on Windows (buggy JVM)
public void testRequestWithBigContentWriteBlockedThenReset() throws Exception
{
final SSLSocket client = newClient();
@@ -1082,7 +1079,6 @@ public class SslBytesServerTest extends SslBytesTest
}
@Test
- @DisabledOnOs(WINDOWS) // Don't run on Windows (buggy JVM)
public void testRequestWithBigContentReadBlockedThenReset() throws Exception
{
final SSLSocket client = newClient();
diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentTempDirTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentTempDirTest.java
index 1ae25e5479a..6512cd5eaaa 100644
--- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentTempDirTest.java
+++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentTempDirTest.java
@@ -33,41 +33,49 @@ import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.toolchain.test.FS;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
+import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
+import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.Scanner;
-import org.eclipse.jetty.util.log.Log;
-import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.webapp.WebAppContext;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@ExtendWith(WorkDirExtension.class)
public class DeploymentTempDirTest
{
- private static final Logger LOG = Log.getLogger(DeploymentTempDirTest.class);
+ public WorkDir workDir;
- private final WebAppProvider webAppProvider = new WebAppProvider();
- private final ContextHandlerCollection contexts = new ContextHandlerCollection();
- private final Path testDir = MavenTestingUtils.getTargetTestingPath(DeploymentTempDirTest.class.getSimpleName());
- private final Path tmpDir = testDir.resolve("tmpDir");
- private final Path webapps = testDir.resolve("webapps");
- private final Server server = new Server();
+ private Path tmpDir;
+ private Path webapps;
+ private Server server;
+ private WebAppProvider webAppProvider;
+ private ContextHandlerCollection contexts;
private final TestListener listener = new TestListener();
@BeforeEach
public void setup() throws Exception
{
+ Path testDir = workDir.getEmptyPathDir();
+ tmpDir = testDir.resolve("tmpDir");
+ webapps = testDir.resolve("webapps");
+
+ FS.ensureDirExists(tmpDir);
+ FS.ensureDirExists(webapps);
+
+ server = new Server();
+
ServerConnector connector = new ServerConnector(server);
server.addConnector(connector);
- FS.ensureEmpty(testDir);
- FS.ensureEmpty(tmpDir);
- FS.ensureEmpty(webapps);
+ webAppProvider = new WebAppProvider();
webAppProvider.setMonitoredDirName(webapps.toString());
webAppProvider.setScanInterval(0);
@@ -75,6 +83,7 @@ public class DeploymentTempDirTest
deploymentManager.addAppProvider(webAppProvider);
server.addBean(deploymentManager);
+ contexts = new ContextHandlerCollection();
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.addHandler(contexts);
handlerCollection.addHandler(new DefaultHandler());
diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java
index 0480afc22e3..855271d6340 100644
--- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java
+++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java
@@ -26,13 +26,10 @@ import org.eclipse.jetty.util.resource.Resource;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.junit.jupiter.api.condition.OS.WINDOWS;
-
/**
* Similar in scope to {@link ScanningAppProviderStartupTest}, except is concerned with the modification of existing
* deployed webapps due to incoming changes identified by the {@link ScanningAppProvider}.
@@ -155,8 +152,6 @@ public class ScanningAppProviderRuntimeUpdatesTest
* @throws Exception on test failure
*/
@Test
- @DisabledOnOs(WINDOWS)
- // This test will not work on Windows as second war file would, not be written over the first one because of a file lock
public void testAfterStartupThenUpdateContext() throws Exception
{
jetty.copyWebapp("foo-webapp-1.war", "foo.war");
diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java
index e0ec2a8e8c4..f081b183485 100644
--- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java
+++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java
@@ -99,6 +99,8 @@ public class WebAppProviderTest
@Test
public void testStartupContext()
{
+ assumeTrue(symlinkSupported);
+
// Check Server for Handlers
jetty.assertWebAppContextsExists("/bar", "/foo", "/bob");
diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/ConcurrentStreamCreationTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/ConcurrentStreamCreationTest.java
index 26b7f459aff..902d69985b8 100644
--- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/ConcurrentStreamCreationTest.java
+++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/ConcurrentStreamCreationTest.java
@@ -29,9 +29,12 @@ import org.eclipse.jetty.http2.frames.HeadersFrame;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.Promise;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@DisabledOnOs(value = OS.WINDOWS, disabledReason = "Unable to create all of the streams")
public class ConcurrentStreamCreationTest extends AbstractTest
{
@Test
diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/SmallThreadPoolLoadTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/SmallThreadPoolLoadTest.java
index cba850eac9a..ab36b21f4a8 100644
--- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/SmallThreadPoolLoadTest.java
+++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/SmallThreadPoolLoadTest.java
@@ -98,9 +98,8 @@ public class SmallThreadPoolLoadTest extends AbstractTest
Thread testThread = Thread.currentThread();
Scheduler.Task task = client.getScheduler().schedule(() ->
{
- logger.warn("Interrupting test, it is taking too long{}Server:{}{}{}Client:{}{}",
- System.lineSeparator(), System.lineSeparator(), server.dump(),
- System.lineSeparator(), System.lineSeparator(), client.dump());
+ logger.warn("Interrupting test, it is taking too long - \nServer: \n" +
+ server.dump() + "\nClient: \n" + client.dump());
testThread.interrupt();
}, iterations * factor, TimeUnit.MILLISECONDS);
@@ -184,9 +183,8 @@ public class SmallThreadPoolLoadTest extends AbstractTest
if (success)
latch.countDown();
else
- logger.warn("Request {} took too long{}Server:{}{}{}Client:{}{}", requestId,
- System.lineSeparator(), System.lineSeparator(), server.dump(),
- System.lineSeparator(), System.lineSeparator(), client.dump());
+ logger.warn("Request {} took too long - \nServer: \n" +
+ server.dump() + "\nClient: \n" + client.dump(), requestId);
return !reset.get();
}
diff --git a/jetty-maven-plugin/pom.xml b/jetty-maven-plugin/pom.xml
index 5dac615e963..f42407280fd 100644
--- a/jetty-maven-plugin/pom.xml
+++ b/jetty-maven-plugin/pom.xml
@@ -125,6 +125,11 @@
maven-artifact-transfer
0.12.0
+
+ org.codehaus.plexus
+ plexus-utils
+ 3.4.0
+
org.apache.maven
maven-plugin-api
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/SelectiveJarResource.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/SelectiveJarResource.java
index a0ff34731ca..860db92485f 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/SelectiveJarResource.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/SelectiveJarResource.java
@@ -28,7 +28,6 @@ import java.util.jar.Manifest;
import org.codehaus.plexus.util.SelectorUtils;
import org.eclipse.jetty.util.IO;
-import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.URIUtil;
import org.eclipse.jetty.util.resource.JarResource;
import org.slf4j.Logger;
@@ -87,7 +86,7 @@ public class SelectiveJarResource extends JarResource
{
for (String include : _includes)
{
- if (SelectorUtils.matchPath(include, name, _caseSensitive))
+ if (SelectorUtils.matchPath(include, name, "/", _caseSensitive))
{
return true;
}
@@ -99,7 +98,7 @@ public class SelectiveJarResource extends JarResource
{
for (String exclude : _excludes)
{
- if (SelectorUtils.matchPath(exclude, name, _caseSensitive))
+ if (SelectorUtils.matchPath(exclude, name, "/", _caseSensitive))
{
return true;
}
@@ -140,8 +139,8 @@ public class SelectiveJarResource extends JarResource
String entryName = entry.getName();
LOG.debug("Looking at {}", entryName);
- String dotCheck = StringUtil.replace(entryName, '\\', '/');
- dotCheck = URIUtil.canonicalPath(dotCheck);
+ // make sure no access out of the root entry is present
+ String dotCheck = URIUtil.canonicalPath(entryName);
if (dotCheck == null)
{
LOG.info("Invalid entry: {}", entryName);
diff --git a/jetty-maven-plugin/src/test/java/org/eclipse/jetty/maven/plugin/TestSelectiveJarResource.java b/jetty-maven-plugin/src/test/java/org/eclipse/jetty/maven/plugin/TestSelectiveJarResource.java
index 249e7a3cb16..c08849ee221 100644
--- a/jetty-maven-plugin/src/test/java/org/eclipse/jetty/maven/plugin/TestSelectiveJarResource.java
+++ b/jetty-maven-plugin/src/test/java/org/eclipse/jetty/maven/plugin/TestSelectiveJarResource.java
@@ -13,96 +13,81 @@
package org.eclipse.jetty.maven.plugin;
-import java.io.File;
import java.net.URL;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
-import org.eclipse.jetty.util.resource.Resource;
-import org.junit.jupiter.api.BeforeEach;
+import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
+import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
-/**
- *
- *
- */
+@ExtendWith(WorkDirExtension.class)
public class TestSelectiveJarResource
{
- File unpackParent;
-
- @BeforeEach
- public void setUp() throws Exception
- {
- unpackParent = MavenTestingUtils.getTargetTestingDir("selective-jar-resource");
- unpackParent.mkdirs();
- }
-
+ public WorkDir workDir;
+
@Test
public void testIncludesNoExcludes() throws Exception
{
- File unpackDir = File.createTempFile("inc", "exc", unpackParent);
- unpackDir.delete();
- unpackDir.mkdirs();
+ Path unpackDir = workDir.getEmptyPathDir();
- File testJar = MavenTestingUtils.getTestResourceFile("selective-jar-test.jar");
- try (SelectiveJarResource sjr = new SelectiveJarResource(new URL("jar:" + Resource.toURL(testJar).toString() + "!/"));)
+ Path testJar = MavenTestingUtils.getTestResourcePathFile("selective-jar-test.jar");
+ try (SelectiveJarResource sjr = new SelectiveJarResource(new URL("jar:" + testJar.toUri().toASCIIString() + "!/")))
{
sjr.setCaseSensitive(false);
List includes = new ArrayList<>();
includes.add("**/*.html");
sjr.setIncludes(includes);
- sjr.copyTo(unpackDir);
- assertTrue(Files.exists(unpackDir.toPath().resolve("top.html")));
- assertTrue(Files.exists(unpackDir.toPath().resolve("aa/a1.html")));
- assertTrue(Files.exists(unpackDir.toPath().resolve("aa/a2.html")));
- assertTrue(Files.exists(unpackDir.toPath().resolve("aa/deep/a3.html")));
- assertTrue(Files.exists(unpackDir.toPath().resolve("bb/b1.html")));
- assertTrue(Files.exists(unpackDir.toPath().resolve("bb/b2.html")));
- assertTrue(Files.exists(unpackDir.toPath().resolve("cc/c1.html")));
- assertTrue(Files.exists(unpackDir.toPath().resolve("cc/c2.html")));
+ sjr.copyTo(unpackDir.toFile());
+ assertTrue(Files.exists(unpackDir.resolve("top.html")));
+ assertTrue(Files.exists(unpackDir.resolve("aa/a1.html")));
+ assertTrue(Files.exists(unpackDir.resolve("aa/a2.html")));
+ assertTrue(Files.exists(unpackDir.resolve("aa/deep/a3.html")));
+ assertTrue(Files.exists(unpackDir.resolve("bb/b1.html")));
+ assertTrue(Files.exists(unpackDir.resolve("bb/b2.html")));
+ assertTrue(Files.exists(unpackDir.resolve("cc/c1.html")));
+ assertTrue(Files.exists(unpackDir.resolve("cc/c2.html")));
}
}
@Test
public void testExcludesNoIncludes() throws Exception
{
- File unpackDir = File.createTempFile("exc", "inc", unpackParent);
- unpackDir.delete();
- unpackDir.mkdirs();
- File testJar = MavenTestingUtils.getTestResourceFile("selective-jar-test.jar");
-
- try (SelectiveJarResource sjr = new SelectiveJarResource(new URL("jar:" + Resource.toURL(testJar).toString() + "!/"));)
+ Path unpackDir = workDir.getEmptyPathDir();
+
+ Path testJar = MavenTestingUtils.getTestResourcePathFile("selective-jar-test.jar");
+ try (SelectiveJarResource sjr = new SelectiveJarResource(new URL("jar:" + testJar.toUri().toASCIIString() + "!/")))
{
sjr.setCaseSensitive(false);
List excludes = new ArrayList<>();
excludes.add("**/*");
sjr.setExcludes(excludes);
- sjr.copyTo(unpackDir);
- assertFalse(Files.exists(unpackDir.toPath().resolve("top.html")));
- assertFalse(Files.exists(unpackDir.toPath().resolve("aa/a1.html")));
- assertFalse(Files.exists(unpackDir.toPath().resolve("aa/a2.html")));
- assertFalse(Files.exists(unpackDir.toPath().resolve("aa/deep/a3.html")));
- assertFalse(Files.exists(unpackDir.toPath().resolve("bb/b1.html")));
- assertFalse(Files.exists(unpackDir.toPath().resolve("bb/b2.html")));
- assertFalse(Files.exists(unpackDir.toPath().resolve("cc/c1.html")));
- assertFalse(Files.exists(unpackDir.toPath().resolve("cc/c2.html")));
+ sjr.copyTo(unpackDir.toFile());
+ assertFalse(Files.exists(unpackDir.resolve("top.html")));
+ assertFalse(Files.exists(unpackDir.resolve("aa/a1.html")));
+ assertFalse(Files.exists(unpackDir.resolve("aa/a2.html")));
+ assertFalse(Files.exists(unpackDir.resolve("aa/deep/a3.html")));
+ assertFalse(Files.exists(unpackDir.resolve("bb/b1.html")));
+ assertFalse(Files.exists(unpackDir.resolve("bb/b2.html")));
+ assertFalse(Files.exists(unpackDir.resolve("cc/c1.html")));
+ assertFalse(Files.exists(unpackDir.resolve("cc/c2.html")));
}
}
@Test
public void testIncludesExcludes() throws Exception
{
- File unpackDir = File.createTempFile("exc", "andinc", unpackParent);
- unpackDir.delete();
- unpackDir.mkdirs();
- File testJar = MavenTestingUtils.getTestResourceFile("selective-jar-test.jar");
-
- try (SelectiveJarResource sjr = new SelectiveJarResource(new URL("jar:" + Resource.toURL(testJar).toString() + "!/"));)
+ Path unpackDir = workDir.getEmptyPathDir();
+
+ Path testJar = MavenTestingUtils.getTestResourcePathFile("selective-jar-test.jar");
+ try (SelectiveJarResource sjr = new SelectiveJarResource(new URL("jar:" + testJar.toUri().toASCIIString() + "!/")))
{
sjr.setCaseSensitive(false);
List excludes = new ArrayList<>();
@@ -111,15 +96,15 @@ public class TestSelectiveJarResource
List includes = new ArrayList<>();
includes.add("bb/*");
sjr.setIncludes(includes);
- sjr.copyTo(unpackDir);
- assertFalse(Files.exists(unpackDir.toPath().resolve("top.html")));
- assertFalse(Files.exists(unpackDir.toPath().resolve("aa/a1.html")));
- assertFalse(Files.exists(unpackDir.toPath().resolve("aa/a2.html")));
- assertFalse(Files.exists(unpackDir.toPath().resolve("aa/deep/a3.html")));
- assertTrue(Files.exists(unpackDir.toPath().resolve("bb/b1.html")));
- assertTrue(Files.exists(unpackDir.toPath().resolve("bb/b2.html")));
- assertFalse(Files.exists(unpackDir.toPath().resolve("cc/c1.html")));
- assertFalse(Files.exists(unpackDir.toPath().resolve("cc/c2.html")));
+ sjr.copyTo(unpackDir.toFile());
+ assertFalse(Files.exists(unpackDir.resolve("top.html")));
+ assertFalse(Files.exists(unpackDir.resolve("aa/a1.html")));
+ assertFalse(Files.exists(unpackDir.resolve("aa/a2.html")));
+ assertFalse(Files.exists(unpackDir.resolve("aa/deep/a3.html")));
+ assertTrue(Files.exists(unpackDir.resolve("bb/b1.html")));
+ assertTrue(Files.exists(unpackDir.resolve("bb/b2.html")));
+ assertFalse(Files.exists(unpackDir.resolve("cc/c1.html")));
+ assertFalse(Files.exists(unpackDir.resolve("cc/c2.html")));
}
}
}
diff --git a/jetty-maven-plugin/src/test/resources/jetty-logging.properties b/jetty-maven-plugin/src/test/resources/jetty-logging.properties
new file mode 100644
index 00000000000..c1e6a540a53
--- /dev/null
+++ b/jetty-maven-plugin/src/test/resources/jetty-logging.properties
@@ -0,0 +1,5 @@
+# Jetty Logging using jetty-slf4j-impl
+#org.eclipse.jetty.maven.plugin.LEVEL=DEBUG
+#org.eclipse.jetty.LEVEL=DEBUG
+#org.eclipse.jetty.server.LEVEL=DEBUG
+#org.eclipse.jetty.http.LEVEL=DEBUG
diff --git a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/AsyncMiddleManServletTest.java b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/AsyncMiddleManServletTest.java
index 0058c37bfab..6dda747734e 100644
--- a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/AsyncMiddleManServletTest.java
+++ b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/AsyncMiddleManServletTest.java
@@ -1290,7 +1290,7 @@ public class AsyncMiddleManServletTest
startClient();
ContentResponse response = client.newRequest("localhost", serverConnector.getLocalPort())
- .timeout(5, TimeUnit.SECONDS)
+ .timeout(10, TimeUnit.SECONDS)
.send();
assertEquals(200, response.getStatus());
diff --git a/jetty-security/src/test/java/org/eclipse/jetty/security/PropertyUserStoreTest.java b/jetty-security/src/test/java/org/eclipse/jetty/security/PropertyUserStoreTest.java
index 9aa2a715c45..926bfcad8cc 100644
--- a/jetty-security/src/test/java/org/eclipse/jetty/security/PropertyUserStoreTest.java
+++ b/jetty-security/src/test/java/org/eclipse/jetty/security/PropertyUserStoreTest.java
@@ -48,7 +48,6 @@ import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.condition.OS.MAC;
-import static org.junit.jupiter.api.condition.OS.WINDOWS;
@ExtendWith(WorkDirExtension.class)
public class PropertyUserStoreTest
@@ -277,7 +276,6 @@ public class PropertyUserStoreTest
}
@Test
- @DisabledOnOs({MAC, WINDOWS}) // File is locked on OS, cannot change.
public void testPropertyUserStoreLoadRemoveUser() throws Exception
{
testdir.ensureEmpty();
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceService.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceService.java
index afab62eed49..fd31944a40f 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceService.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceService.java
@@ -19,6 +19,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
+import java.nio.file.InvalidPathException;
import java.util.Collection;
import java.util.Enumeration;
import java.util.List;
@@ -297,6 +298,16 @@ public class ResourceService
// Send the data
releaseContent = sendData(request, response, included, content, reqRanges);
}
+ // Can be thrown from contentFactory.getContent() call when using invalid characters
+ catch (InvalidPathException e)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("InvalidPathException for pathInContext: {}", pathInContext, e);
+ if (included)
+ throw new FileNotFoundException("!" + pathInContext);
+ notFound(request, response);
+ return response.isCommitted();
+ }
catch (IllegalArgumentException e)
{
LOG.warn("Failed to serve resource: {}", pathInContext, e);
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/FileBufferedResponseHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/FileBufferedResponseHandler.java
index 201f8da802e..a849f5bb217 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/FileBufferedResponseHandler.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/FileBufferedResponseHandler.java
@@ -114,7 +114,9 @@ public class FileBufferedResponseHandler extends BufferedResponseHandler
}
catch (Throwable t)
{
- LOG.warn("Could not delete file {}", _filePath, t);
+ if (LOG.isDebugEnabled())
+ LOG.debug("Could not immediately delete file (delaying to jvm exit) {}", _filePath, t);
+ _filePath.toFile().deleteOnExit();
}
_filePath = null;
}
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/GracefulStopTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/GracefulStopTest.java
index 034162db4f5..8a182f5768d 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/GracefulStopTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/GracefulStopTest.java
@@ -149,7 +149,7 @@ public class GracefulStopTest
HttpTester.Response response = HttpTester.parseResponse(client.getInputStream());
assertThat(response.getStatus(), is(200));
- assertThat(response.getContent(), is("read 10/10\n"));
+ assertThat(response.getContent(), is("read [10/10]"));
assertThat(response.get(HttpHeader.CONNECTION), nullValue());
return client;
@@ -164,7 +164,7 @@ public class GracefulStopTest
HttpTester.Response response = HttpTester.parseResponse(client.getInputStream());
assertThat(response.getStatus(), is(200));
- assertThat(response.getContent(), is("read 10/10\n"));
+ assertThat(response.getContent(), is("read [10/10]"));
assertThat(response.get(HttpHeader.CONNECTION), nullValue());
}
@@ -224,7 +224,7 @@ public class GracefulStopTest
assertThat(response.get(HttpHeader.CONNECTION), is("close"));
else
assertThat(response.get(HttpHeader.CONNECTION), nullValue());
- assertThat(response.getContent(), is("read 10/10\n"));
+ assertThat(response.getContent(), is("read [10/10]"));
}
void assert500Response(Socket client) throws Exception
@@ -414,7 +414,7 @@ public class GracefulStopTest
}
}
- response.getWriter().printf("read %d/%d%n", c, contentLength);
+ response.getWriter().printf("read [%d/%d]", c, contentLength);
}
catch (Throwable th)
{
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ServerConnectorTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ServerConnectorTest.java
index cd5db4be13e..9d061212edf 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/ServerConnectorTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ServerConnectorTest.java
@@ -45,6 +45,8 @@ import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.util.IO;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.anyOf;
@@ -214,6 +216,7 @@ public class ServerConnectorTest
}
@Test
+ @DisabledOnOs(value = OS.WINDOWS, disabledReason = "SO_REUSEPORT not available on windows")
public void testReusePort() throws Exception
{
int port;
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java
index 606cfddc63d..43fa2319fa8 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java
@@ -30,10 +30,8 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.DisabledOnOs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,11 +40,8 @@ import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.condition.OS.MAC;
-@Disabled
@Tag("stress")
-@DisabledOnOs(MAC) // TODO: needs investigation
public class StressTest
{
private static final Logger LOG = LoggerFactory.getLogger(StressTest.class);
@@ -129,6 +124,7 @@ public class StressTest
}
@Test
+ @Tag("Slow")
public void testNonPersistent() throws Throwable
{
doThreads(20, 20, false);
@@ -145,6 +141,7 @@ public class StressTest
}
@Test
+ @Tag("Slow")
public void testPersistent() throws Throwable
{
doThreads(40, 40, true);
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/FileBufferedResponseHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/FileBufferedResponseHandlerTest.java
index 2b00666b7bb..c0427b95947 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/FileBufferedResponseHandlerTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/FileBufferedResponseHandlerTest.java
@@ -45,10 +45,14 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.toolchain.test.FS;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
+import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
+import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
import org.eclipse.jetty.util.Callback;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.OS;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,10 +64,13 @@ import static org.hamcrest.Matchers.not;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@ExtendWith(WorkDirExtension.class)
public class FileBufferedResponseHandlerTest
{
private static final Logger LOG = LoggerFactory.getLogger(FileBufferedResponseHandlerTest.class);
+ public WorkDir _workDir;
+
private final CountDownLatch _disposeLatch = new CountDownLatch(1);
private Server _server;
private LocalConnector _localConnector;
@@ -74,8 +81,7 @@ public class FileBufferedResponseHandlerTest
@BeforeEach
public void before() throws Exception
{
- _testDir = MavenTestingUtils.getTargetTestingPath(FileBufferedResponseHandlerTest.class.getName());
- FS.ensureDirExists(_testDir);
+ _testDir = _workDir.getEmptyPathDir();
_server = new Server();
HttpConfiguration config = new HttpConfiguration();
@@ -109,8 +115,6 @@ public class FileBufferedResponseHandlerTest
_bufferedHandler.getPathIncludeExclude().exclude("*.exclude");
_bufferedHandler.getMimeIncludeExclude().exclude("text/excluded");
_server.setHandler(_bufferedHandler);
-
- FS.ensureEmpty(_testDir);
}
@AfterEach
@@ -175,8 +179,13 @@ public class FileBufferedResponseHandlerTest
assertThat(responseContent, containsString("Committed: false"));
assertThat(responseContent, containsString("NumFiles: 1"));
- assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
- assertThat(getNumFiles(), is(0));
+ // Unable to verify file deletion on windows, as immediate delete not possible.
+ // only after a GC has occurred.
+ if (!OS.WINDOWS.isCurrentOs())
+ {
+ assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
+ assertThat(getNumFiles(), is(0));
+ }
}
@Test
@@ -269,8 +278,13 @@ public class FileBufferedResponseHandlerTest
assertThat(responseContent, containsString("Committed: false"));
assertThat(responseContent, containsString("NumFiles: 1"));
- assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
- assertThat(getNumFiles(), is(0));
+ // Unable to verify file deletion on windows, as immediate delete not possible.
+ // only after a GC has occurred.
+ if (!OS.WINDOWS.isCurrentOs())
+ {
+ assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
+ assertThat(getNumFiles(), is(0));
+ }
}
@Test
@@ -301,8 +315,13 @@ public class FileBufferedResponseHandlerTest
assertThat(responseContent, not(containsString("writtenAfterClose")));
assertThat(responseContent, containsString("NumFiles: 1"));
- assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
- assertThat(getNumFiles(), is(0));
+ // Unable to verify file deletion on windows, as immediate delete not possible.
+ // only after a GC has occurred.
+ if (!OS.WINDOWS.isCurrentOs())
+ {
+ assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
+ assertThat(getNumFiles(), is(0));
+ }
}
@Test
@@ -363,8 +382,13 @@ public class FileBufferedResponseHandlerTest
assertThat(response.getStatus(), is(HttpStatus.OK_200));
assertThat(responseContent, containsString("NumFiles: 0"));
- assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
- assertThat(getNumFiles(), is(0));
+ // Unable to verify file deletion on windows, as immediate delete not possible.
+ // only after a GC has occurred.
+ if (!OS.WINDOWS.isCurrentOs())
+ {
+ assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
+ assertThat(getNumFiles(), is(0));
+ }
}
@Test
@@ -400,12 +424,18 @@ public class FileBufferedResponseHandlerTest
// Resetting the response buffer will delete the file.
assertThat(response.getStatus(), is(HttpStatus.OK_200));
assertThat(responseContent, not(containsString("THIS WILL BE RESET")));
+
assertThat(responseContent, containsString("NumFilesBeforeReset: 1"));
assertThat(responseContent, containsString("NumFilesAfterReset: 0"));
assertThat(responseContent, containsString("NumFilesAfterWrite: 1"));
- assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
- assertThat(getNumFiles(), is(0));
+ // Unable to verify file deletion on windows, as immediate delete not possible.
+ // only after a GC has occurred.
+ if (!OS.WINDOWS.isCurrentOs())
+ {
+ assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
+ assertThat(getNumFiles(), is(0));
+ }
}
@Test
@@ -479,8 +509,13 @@ public class FileBufferedResponseHandlerTest
assertThat(response.get("FileSize"), is(Long.toString(fileSize)));
assertThat(received.get(), is(fileSize));
- assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
- assertThat(getNumFiles(), is(0));
+ // Unable to verify file deletion on windows, as immediate delete not possible.
+ // only after a GC has occurred.
+ if (!OS.WINDOWS.isCurrentOs())
+ {
+ assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
+ assertThat(getNumFiles(), is(0));
+ }
}
@Test
@@ -553,9 +588,14 @@ public class FileBufferedResponseHandlerTest
Throwable error = errorFuture.get(5, TimeUnit.SECONDS);
assertThat(error.getMessage(), containsString("intentionally throwing from interceptor"));
- // All files were deleted.
- assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
- assertThat(getNumFiles(), is(0));
+ // Unable to verify file deletion on windows, as immediate delete not possible.
+ // only after a GC has occurred.
+ if (!OS.WINDOWS.isCurrentOs())
+ {
+ // All files were deleted.
+ assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
+ assertThat(getNumFiles(), is(0));
+ }
}
@Test
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/ServerConnectorSslServerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/ServerConnectorSslServerTest.java
index 4a8d0af7a9b..8570c6ebfd5 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/ServerConnectorSslServerTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/ServerConnectorSslServerTest.java
@@ -17,7 +17,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
-import java.net.SocketException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.security.KeyStore;
@@ -26,7 +25,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManagerFactory;
import javax.servlet.ServletException;
@@ -49,7 +47,6 @@ import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.DisabledOnOs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -59,7 +56,6 @@ import static org.hamcrest.Matchers.emptyOrNullString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.condition.OS.WINDOWS;
/**
* HttpServer Tester for SSL based ServerConnector
@@ -124,43 +120,6 @@ public class ServerConnectorSslServerTest extends HttpServerTestBase
return socket;
}
- @Override
- @DisabledOnOs(WINDOWS) // Don't run on Windows (buggy JVM)
- public void testFullMethod() throws Exception
- {
- try
- {
- super.testFullMethod();
- }
- catch (SocketException e)
- {
- // TODO This needs to be investigated #2244
- LOG.warn("Close overtook 400 response", e);
- }
- catch (SSLException e)
- {
- // TODO This needs to be investigated #2244
- if (e.getCause() instanceof SocketException)
- LOG.warn("Close overtook 400 response", e);
- else
- throw e;
- }
- }
-
- @Override
- @DisabledOnOs(WINDOWS) // Don't run on Windows (buggy JVM)
- public void testFullURI() throws Exception
- {
- try
- {
- super.testFullURI();
- }
- catch (SocketException e)
- {
- LOG.warn("Close overtook 400 response", e);
- }
- }
-
@Override
public void testFullHeader() throws Exception
{
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SniSslConnectionFactoryTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SniSslConnectionFactoryTest.java
index 91954a40065..2440fe8b734 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SniSslConnectionFactoryTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SniSslConnectionFactoryTest.java
@@ -235,8 +235,8 @@ public class SniSslConnectionFactoryTest
assertThat(response, Matchers.containsString("Invalid SNI"));
}
+ @DisabledOnOs(value = OS.WINDOWS, disabledReason = "See Issue #6609 - TLSv1.3 behavior differences between Linux and Windows")
@Test
- @DisabledOnOs(OS.WINDOWS)
public void testWrongSNIRejectedConnection() throws Exception
{
start(ssl ->
@@ -275,8 +275,8 @@ public class SniSslConnectionFactoryTest
assertThat(response.getStatus(), is(400));
}
+ @DisabledOnOs(value = OS.WINDOWS, disabledReason = "See Issue #6609 - TLSv1.3 behavior differences between Linux and Windows")
@Test
- @DisabledOnOs(OS.WINDOWS)
public void testWrongSNIRejectedFunction() throws Exception
{
start((ssl, customizer) ->
@@ -302,8 +302,8 @@ public class SniSslConnectionFactoryTest
assertThat(response.getStatus(), is(400));
}
+ @DisabledOnOs(value = OS.WINDOWS, disabledReason = "See Issue #6609 - TLSv1.3 behavior differences between Linux and Windows")
@Test
- @DisabledOnOs(OS.WINDOWS)
public void testWrongSNIRejectedConnectionWithNonSNIKeystore() throws Exception
{
start(ssl ->
diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/WelcomeFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/WelcomeFilter.java
index d5abac44bda..2a6c899a906 100644
--- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/WelcomeFilter.java
+++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/WelcomeFilter.java
@@ -37,6 +37,7 @@ import org.eclipse.jetty.util.URIUtil;
* will be handled by any servlets mapped to that URL.
*
* Requests to "/some/directory" will be redirected to "/some/directory/".
+ * @deprecated no replacement is offered, use standard Servlet web.xml welcome features
*/
@Deprecated
public class WelcomeFilter implements Filter
diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java
index 265e3382af8..06905344f5f 100644
--- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java
+++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java
@@ -45,6 +45,7 @@ import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.lessThan;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -289,7 +290,8 @@ public abstract class AbstractDoSFilterTest
String responses = doRequests(request1 + request2 + request1 + request2 + request1, 2, 1100, 1100, last);
assertEquals(11, count(responses, "HTTP/1.1 200 OK"));
- assertEquals(0, count(responses, "DoSFilter: delayed"));
+ // This test is system speed dependent, so allow some (20%-ish) requests to be delayed, but not more.
+ assertThat("delayed count", count(responses, "DoSFilter: delayed"), lessThan(2));
// alternate between sessions
responses = doRequests(request1 + request2 + request1 + request2 + request1, 2, 250, 250, last);
diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/WelcomeFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/WelcomeFilterTest.java
index 2e3cbae9952..7f5a1733a76 100644
--- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/WelcomeFilterTest.java
+++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/WelcomeFilterTest.java
@@ -25,6 +25,7 @@ import org.eclipse.jetty.http.UriCompliance;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.LocalConnector;
import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.webapp.WebAppContext;
@@ -80,6 +81,8 @@ public class WelcomeFilterTest
}
WebAppContext context = new WebAppContext(server, directoryPath.toString(), "/");
+ // Turn off memory-mapped behavior in DefaultServlet for Windows testing reasons.
+ context.setInitParameter(DefaultServlet.CONTEXT_INIT + "useFileMappedBuffer", "false");
server.setHandler(context);
String concatPath = "/*";
diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingServiceProvider.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingServiceProvider.java
index 2b1f7a21932..fa48a15dcae 100644
--- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingServiceProvider.java
+++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingServiceProvider.java
@@ -24,10 +24,8 @@ public class JettyLoggingServiceProvider implements SLF4JServiceProvider
{
/**
* Declare the version of the SLF4J API this implementation is compiled against.
- * The value of this field is modified with each major release.
*/
- // to avoid constant folding by the compiler, this field must *not* be final
- public static String REQUESTED_API_VERSION = "1.8.99"; // !final
+ private static final String REQUESTED_API_VERSION = "2.0";
private JettyLoggerFactory loggerFactory;
private BasicMarkerFactory markerFactory;
diff --git a/jetty-start/src/test/resources/usecases/empty.addModule.assert.txt b/jetty-start/src/test/resources/usecases/empty.addModule.assert.txt
index 5b85abf8491..f861cba93cf 100644
--- a/jetty-start/src/test/resources/usecases/empty.addModule.assert.txt
+++ b/jetty-start/src/test/resources/usecases/empty.addModule.assert.txt
@@ -22,12 +22,12 @@ EXISTS|maindir/
EXISTS|start.ini
# Output Assertions [regex!] (order is irrelevant)
-OUTPUT|INFO : mkdir ..jetty.base./start.d
-OUTPUT|INFO : extra initialized in \$\{jetty.base\}/start.d/extra.ini
+OUTPUT|INFO : mkdir ..jetty.base.[/\\]start.d
+OUTPUT|INFO : extra initialized in \$\{jetty.base\}[/\\]start.d[/\\]extra.ini
OUTPUT|INFO : main transitively enabled, ini template available with --add-module=main
-OUTPUT|INFO : optional initialized in \$\{jetty.base\}/start.d/optional.ini
+OUTPUT|INFO : optional initialized in \$\{jetty.base\}[/\\]start.d[/\\]optional.ini
OUTPUT|INFO : base transitively enabled
-OUTPUT|INFO : mkdir ..jetty.base./maindir
+OUTPUT|INFO : mkdir ..jetty.base.[/\\]maindir
OUTPUT|INFO : Base directory was modified
diff --git a/jetty-start/src/test/resources/usecases/empty.addModuleCreateStartIni.assert.txt b/jetty-start/src/test/resources/usecases/empty.addModuleCreateStartIni.assert.txt
index 8c767ba8ff4..010e760a6f2 100644
--- a/jetty-start/src/test/resources/usecases/empty.addModuleCreateStartIni.assert.txt
+++ b/jetty-start/src/test/resources/usecases/empty.addModuleCreateStartIni.assert.txt
@@ -22,12 +22,12 @@ EXISTS|maindir/
EXISTS|start.ini
# Output Assertions [regex!] (order is irrelevant)
-OUTPUT|INFO : create ..jetty.base./start.ini
-OUTPUT|INFO : extra initialized in ..jetty.base./start.ini
+OUTPUT|INFO : create ..jetty.base.[/\\]start.ini
+OUTPUT|INFO : extra initialized in ..jetty.base.[/\\]start.ini
OUTPUT|INFO : main transitively enabled, ini template available with --add-module=main
-OUTPUT|INFO : optional initialized in ..jetty.base./start.ini
+OUTPUT|INFO : optional initialized in ..jetty.base.[/\\]start.ini
OUTPUT|INFO : base transitively enabled
-OUTPUT|INFO : mkdir ..jetty.base./maindir
+OUTPUT|INFO : mkdir ..jetty.base.[/\\]maindir
OUTPUT|INFO : Base directory was modified
diff --git a/jetty-start/src/test/resources/usecases/minimal-start-d.alreadyEnabled.assert.txt b/jetty-start/src/test/resources/usecases/minimal-start-d.alreadyEnabled.assert.txt
index dcd3d29c6bf..546e1fca67a 100644
--- a/jetty-start/src/test/resources/usecases/minimal-start-d.alreadyEnabled.assert.txt
+++ b/jetty-start/src/test/resources/usecases/minimal-start-d.alreadyEnabled.assert.txt
@@ -14,4 +14,4 @@ PROP|main.prop=value0
EXISTS|maindir/
EXISTS|start.d/main.ini
-OUTPUT|INFO : main already enabled by \[\$\{jetty.base}[\\/]start.d/main.ini\]
+OUTPUT|INFO : main already enabled by \[\$\{jetty.base}[/\\]start.d[/\\]main.ini\]
diff --git a/jetty-start/src/test/resources/usecases/minimal-start-d.createStartIni.assert.txt b/jetty-start/src/test/resources/usecases/minimal-start-d.createStartIni.assert.txt
index 5e6bd45e669..c4c75dc8bcc 100644
--- a/jetty-start/src/test/resources/usecases/minimal-start-d.createStartIni.assert.txt
+++ b/jetty-start/src/test/resources/usecases/minimal-start-d.createStartIni.assert.txt
@@ -17,7 +17,7 @@ PROP|optional.prop=value0
EXISTS|maindir/
EXISTS|start.ini
-OUTPUT|INFO : copy ..jetty.base./start.d/main.ini into ..jetty.base./start.ini
-OUTPUT|INFO : optional initialized in ..jetty.base./start.ini
-OUTPUT|INFO : mkdir ..jetty.base./maindir
+OUTPUT|INFO : copy ..jetty.base.[/\\]start.d[/\\]main.ini into ..jetty.base.[/\\]start.ini
+OUTPUT|INFO : optional initialized in ..jetty.base.[/\\]start.ini
+OUTPUT|INFO : mkdir ..jetty.base.[/\\]maindir
OUTPUT|INFO : Base directory was modified
diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/PathWatcherTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/PathWatcherTest.java
index 65cacdcd07c..b2093dba4e3 100644
--- a/jetty-util/src/test/java/org/eclipse/jetty/util/PathWatcherTest.java
+++ b/jetty-util/src/test/java/org/eclipse/jetty/util/PathWatcherTest.java
@@ -362,7 +362,7 @@ public class PathWatcherTest
capture.finishedLatch.await(LONG_TIME, TimeUnit.MILLISECONDS);
long end = System.nanoTime();
capture.assertEvents(expected);
- assertThat(end - start, greaterThan(TimeUnit.MILLISECONDS.toNanos(2 * QUIET_TIME)));
+ assertThat(end - start, greaterThan(TimeUnit.MILLISECONDS.toNanos(2L * QUIET_TIME)));
Thread.sleep(WAIT_TIME);
capture.assertEvents(expected);
diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/ScannerTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/ScannerTest.java
index 534f65c30fa..aca6710e800 100644
--- a/jetty-util/src/test/java/org/eclipse/jetty/util/ScannerTest.java
+++ b/jetty-util/src/test/java/org/eclipse/jetty/util/ScannerTest.java
@@ -17,6 +17,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.util.ArrayList;
@@ -28,40 +29,38 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.toolchain.test.FS;
-import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
+import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
+import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
import org.eclipse.jetty.util.Scanner.Notification;
+import org.eclipse.jetty.util.component.LifeCycle;
import org.hamcrest.Matchers;
-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.Tag;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.extension.ExtendWith;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.condition.OS.WINDOWS;
+@ExtendWith(WorkDirExtension.class)
public class ScannerTest
{
- static File _directory;
- static Scanner _scanner;
- static BlockingQueue _queue = new LinkedBlockingQueue<>();
- static BlockingQueue> _bulk = new LinkedBlockingQueue<>();
+ public WorkDir workDir;
+ private Path _directory;
+ private Scanner _scanner;
+ private BlockingQueue _queue = new LinkedBlockingQueue<>();
+ private BlockingQueue> _bulk = new LinkedBlockingQueue<>();
- @BeforeAll
- public static void setUpBeforeClass() throws Exception
+ @BeforeEach
+ public void setupScanner() throws Exception
{
- File testDir = MavenTestingUtils.getTargetTestingDir(ScannerTest.class.getSimpleName());
- FS.ensureEmpty(testDir);
-
- // Use full path, pointing to a real directory (for FileSystems that are case-insensitive, like Windows and OSX to use)
- // This is only needed for the various comparisons below to make sense.
- _directory = testDir.toPath().toRealPath().toFile();
-
+ _directory = workDir.getEmptyPathDir();
_scanner = new Scanner();
- _scanner.addDirectory(_directory.toPath());
+ _scanner.addDirectory(_directory);
_scanner.setScanInterval(0);
_scanner.setReportDirs(false);
_scanner.setReportExistingFilesOnStartup(false);
@@ -94,11 +93,10 @@ public class ScannerTest
assertTrue(_bulk.isEmpty());
}
- @AfterAll
- public static void tearDownAfterClass() throws Exception
+ @AfterEach
+ public void cleanup() throws Exception
{
- _scanner.stop();
- IO.delete(_directory);
+ LifeCycle.stop(_scanner);
}
static class Event
@@ -139,7 +137,7 @@ public class ScannerTest
@Test
public void testDepth() throws Exception
{
- File root = new File(_directory, "root");
+ File root = new File(_directory.toFile(), "root");
FS.ensureDirExists(root);
FS.touch(new File(root, "foo.foo"));
FS.touch(new File(root, "foo2.foo"));
@@ -215,7 +213,7 @@ public class ScannerTest
public void testPatterns() throws Exception
{
//test include and exclude patterns
- File root = new File(_directory, "proot");
+ File root = new File(_directory.toFile(), "proot");
FS.ensureDirExists(root);
File ttt = new File(root, "ttt.txt");
@@ -288,7 +286,7 @@ public class ScannerTest
}
@Test
- @DisabledOnOs(WINDOWS) // TODO: needs review
+ @Tag("Slow")
public void testAddedChangeRemove() throws Exception
{
touch("a0");
@@ -299,7 +297,7 @@ public class ScannerTest
Event event = _queue.poll(5, TimeUnit.SECONDS);
assertNotNull(event, "Event should not be null");
- assertEquals(_directory + "/a0", event._filename);
+ assertEquals(_directory.resolve("a0").toString(), event._filename);
assertEquals(Notification.ADDED, event._notification);
// add 3 more files
@@ -323,8 +321,8 @@ public class ScannerTest
List actualEvents = new ArrayList<>();
_queue.drainTo(actualEvents);
assertEquals(2, actualEvents.size());
- Event a1 = new Event(_directory + "/a1", Notification.ADDED);
- Event a3 = new Event(_directory + "/a3", Notification.REMOVED);
+ Event a1 = new Event(_directory.resolve("a1").toString(), Notification.ADDED);
+ Event a3 = new Event(_directory.resolve("a3").toString(), Notification.REMOVED);
assertThat(actualEvents, Matchers.containsInAnyOrder(a1, a3));
assertTrue(_queue.isEmpty());
@@ -332,7 +330,7 @@ public class ScannerTest
_scanner.scan();
event = _queue.poll();
assertNotNull(event);
- assertEquals(_directory + "/a2", event._filename);
+ assertEquals(_directory.resolve("a2").toString(), event._filename);
assertEquals(Notification.ADDED, event._notification);
assertTrue(_queue.isEmpty());
@@ -353,7 +351,7 @@ public class ScannerTest
_scanner.scan();
event = _queue.poll();
assertNotNull(event);
- assertEquals(_directory + "/a1", event._filename);
+ assertEquals(_directory.resolve("a1").toString(), event._filename);
assertEquals(Notification.CHANGED, event._notification);
assertTrue(_queue.isEmpty());
@@ -361,7 +359,7 @@ public class ScannerTest
_scanner.scan();
event = _queue.poll();
assertNotNull(event);
- assertEquals(_directory + "/a2", event._filename);
+ assertEquals(_directory.resolve("a2").toString(), event._filename);
assertEquals(Notification.CHANGED, event._notification);
assertTrue(_queue.isEmpty());
@@ -371,8 +369,8 @@ public class ScannerTest
//Immediate notification of deletes.
_scanner.scan();
- a1 = new Event(_directory + "/a1", Notification.REMOVED);
- Event a2 = new Event(_directory + "/a2", Notification.REMOVED);
+ a1 = new Event(_directory.resolve("a1").toString(), Notification.REMOVED);
+ Event a2 = new Event(_directory.resolve("a2").toString(), Notification.REMOVED);
actualEvents = new ArrayList<>();
_queue.drainTo(actualEvents);
assertEquals(2, actualEvents.size());
@@ -392,13 +390,12 @@ public class ScannerTest
_scanner.scan();
event = _queue.poll();
assertNotNull(event);
- assertEquals(_directory + "/a2", event._filename);
+ assertEquals(_directory.resolve("a2").toString(), event._filename);
assertEquals(Notification.ADDED, event._notification);
assertTrue(_queue.isEmpty());
}
@Test
- @DisabledOnOs(WINDOWS) // TODO: needs review
public void testSizeChange() throws Exception
{
touch("tsc0");
@@ -408,12 +405,12 @@ public class ScannerTest
// takes 2 scans to notice tsc0 and check that it is stable.
Event event = _queue.poll();
assertNotNull(event);
- assertEquals(_directory + "/tsc0", event._filename);
+ assertEquals(_directory.resolve("tsc0").toString(), event._filename);
assertEquals(Notification.ADDED, event._notification);
// Create a new file by writing to it.
long now = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
- File file = new File(_directory, "st");
+ File file = new File(_directory.toFile(), "st");
try (OutputStream out = new FileOutputStream(file, true))
{
out.write('x');
@@ -439,7 +436,7 @@ public class ScannerTest
_scanner.scan();
event = _queue.poll();
assertNotNull(event);
- assertEquals(_directory + "/st", event._filename);
+ assertEquals(_directory.resolve("st").toString(), event._filename);
assertEquals(Notification.ADDED, event._notification);
// Modify size only
@@ -456,21 +453,20 @@ public class ScannerTest
_scanner.scan();
event = _queue.poll();
assertNotNull(event);
- assertEquals(_directory + "/st", event._filename);
+ assertEquals(_directory.resolve("st").toString(), event._filename);
assertEquals(Notification.CHANGED, event._notification);
}
}
- private void delete(String string)
+ private void delete(String string) throws IOException
{
- File file = new File(_directory, string);
- if (file.exists())
- IO.delete(file);
+ Path file = _directory.resolve(string);
+ Files.deleteIfExists(file);
}
private void touch(String string) throws IOException
{
- File file = new File(_directory, string);
+ File file = new File(_directory.toFile(), string);
if (file.exists())
file.setLastModified(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()));
else
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 75e9ced163b..420ea8c3af4 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
@@ -46,7 +46,6 @@ import org.eclipse.jetty.util.BufferUtil;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
-import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -641,7 +640,6 @@ public class FileSystemResourceTest
@ParameterizedTest
@MethodSource("fsResourceProvider")
- @DisabledOnOs(WINDOWS)
public void testSymlink(Class resourceClass) throws Exception
{
Path dir = workDir.getEmptyPathDir();
@@ -649,18 +647,20 @@ public class FileSystemResourceTest
Path foo = dir.resolve("foo");
Path bar = dir.resolve("bar");
+ boolean symlinkSupported;
try
{
Files.createFile(foo);
Files.createSymbolicLink(bar, foo);
+ symlinkSupported = true;
}
catch (UnsupportedOperationException | FileSystemException e)
{
- // if unable to create symlink, no point testing the rest
- // this is the path that Microsoft Windows takes.
- assumeTrue(true, "Not supported");
+ symlinkSupported = false;
}
+ assumeTrue(symlinkSupported, "Symlink not supported");
+
try (Resource base = newResource(resourceClass, dir.toFile()))
{
Resource resFoo = base.addPath("foo");
@@ -683,7 +683,6 @@ public class FileSystemResourceTest
@ParameterizedTest
@ValueSource(classes = PathResource.class) // FileResource does not support this
- @DisabledOnOs(WINDOWS)
public void testNonExistantSymlink(Class resourceClass) throws Exception
{
Path dir = workDir.getEmptyPathDir();
@@ -692,17 +691,19 @@ public class FileSystemResourceTest
Path foo = dir.resolve("foo");
Path bar = dir.resolve("bar");
+ boolean symlinkSupported;
try
{
Files.createSymbolicLink(bar, foo);
+ symlinkSupported = true;
}
catch (UnsupportedOperationException | FileSystemException e)
{
- // if unable to create symlink, no point testing the rest
- // this is the path that Microsoft Windows takes.
- assumeTrue(true, "Not supported");
+ symlinkSupported = false;
}
+ assumeTrue(symlinkSupported, "Symlink not supported");
+
try (Resource base = newResource(resourceClass, dir.toFile()))
{
Resource resFoo = base.addPath("foo");
@@ -835,8 +836,7 @@ public class FileSystemResourceTest
}
catch (InvalidPathException e)
{
- // NTFS filesystem streams are unsupported on some platforms.
- assumeTrue(true, "Not supported");
+ assumeTrue(false, "NTFS simple streams not supported");
}
}
}
@@ -883,8 +883,7 @@ public class FileSystemResourceTest
}
catch (InvalidPathException e)
{
- // NTFS filesystem streams are unsupported on some platforms.
- assumeTrue(true, "Not supported");
+ assumeTrue(false, "NTFS $DATA streams not supported");
}
}
}
@@ -929,15 +928,13 @@ public class FileSystemResourceTest
}
catch (InvalidPathException e)
{
- // NTFS filesystem streams are unsupported on some platforms.
- assumeTrue(true, "Not supported on this OS");
+ assumeTrue(false, "NTFS $DATA streams not supported");
}
}
}
@ParameterizedTest
@MethodSource("fsResourceProvider")
- @DisabledOnOs(WINDOWS)
public void testSemicolon(Class resourceClass) throws Exception
{
Path dir = workDir.getEmptyPathDir();
@@ -948,11 +945,9 @@ public class FileSystemResourceTest
Path foo = dir.resolve("foo;");
Files.createFile(foo);
}
- catch (Exception e)
+ catch (InvalidPathException e)
{
- // if unable to create file, no point testing the rest.
- // this is the path that Microsoft Windows takes.
- assumeTrue(true, "Not supported on this OS");
+ assumeTrue(false, "Unable to create file with semicolon");
}
try (Resource base = newResource(resourceClass, dir.toFile()))
@@ -964,7 +959,6 @@ public class FileSystemResourceTest
@ParameterizedTest
@MethodSource("fsResourceProvider")
- @DisabledOnOs(WINDOWS)
public void testSingleQuote(Class resourceClass) throws Exception
{
Path dir = workDir.getEmptyPathDir();
@@ -976,11 +970,9 @@ public class FileSystemResourceTest
Path foo = dir.resolve("foo' bar");
Files.createFile(foo);
}
- catch (Exception e)
+ catch (InvalidPathException e)
{
- // if unable to create file, no point testing the rest.
- // this is the path that Microsoft Windows takes.
- assumeTrue(true, "Not supported on this OS");
+ assumeTrue(false, "Unable to create file with single quote");
}
try (Resource base = newResource(resourceClass, dir.toFile()))
@@ -992,7 +984,6 @@ public class FileSystemResourceTest
@ParameterizedTest
@MethodSource("fsResourceProvider")
- @DisabledOnOs(WINDOWS)
public void testSingleBackTick(Class resourceClass) throws Exception
{
Path dir = workDir.getEmptyPathDir();
@@ -1004,11 +995,9 @@ public class FileSystemResourceTest
Path foo = dir.resolve("foo` bar");
Files.createFile(foo);
}
- catch (Exception e)
+ catch (InvalidPathException e)
{
- // if unable to create file, no point testing the rest.
- // this is the path that Microsoft Windows takes.
- assumeTrue(true, "Not supported on this OS");
+ assumeTrue(false, "Unable to create file with single back tick");
}
try (Resource base = newResource(resourceClass, dir.toFile()))
@@ -1020,7 +1009,6 @@ public class FileSystemResourceTest
@ParameterizedTest
@MethodSource("fsResourceProvider")
- @DisabledOnOs(WINDOWS)
public void testBrackets(Class resourceClass) throws Exception
{
Path dir = workDir.getEmptyPathDir();
@@ -1032,11 +1020,9 @@ public class FileSystemResourceTest
Path foo = dir.resolve("foo[1]");
Files.createFile(foo);
}
- catch (Exception e)
+ catch (InvalidPathException e)
{
- // if unable to create file, no point testing the rest.
- // this is the path that Microsoft Windows takes.
- assumeTrue(true, "Not supported on this OS");
+ assumeTrue(false, "Unable to create file with square brackets");
}
try (Resource base = newResource(resourceClass, dir.toFile()))
@@ -1048,7 +1034,6 @@ public class FileSystemResourceTest
@ParameterizedTest
@ValueSource(classes = PathResource.class) // FileResource does not support this
- @DisabledOnOs(WINDOWS)
public void testBraces(Class resourceClass) throws Exception
{
Path dir = workDir.getEmptyPathDir();
@@ -1060,11 +1045,9 @@ public class FileSystemResourceTest
Path foo = dir.resolve("foo.{bar}.txt");
Files.createFile(foo);
}
- catch (Exception e)
+ catch (InvalidPathException e)
{
- // if unable to create file, no point testing the rest.
- // this is the path that Microsoft Windows takes.
- assumeTrue(true, "Not supported on this OS");
+ assumeTrue(false, "Unable to create file with squiggle braces");
}
try (Resource base = newResource(resourceClass, dir.toFile()))
@@ -1076,7 +1059,6 @@ public class FileSystemResourceTest
@ParameterizedTest
@ValueSource(classes = PathResource.class) // FileResource does not support this
- @DisabledOnOs(WINDOWS)
public void testCaret(Class resourceClass) throws Exception
{
Path dir = workDir.getEmptyPathDir();
@@ -1088,11 +1070,9 @@ public class FileSystemResourceTest
Path foo = dir.resolve("foo^3.txt");
Files.createFile(foo);
}
- catch (Exception e)
+ catch (InvalidPathException e)
{
- // if unable to create file, no point testing the rest.
- // this is the path that Microsoft Windows takes.
- assumeTrue(true, "Not supported on this OS");
+ assumeTrue(false, "Unable to create file with caret");
}
try (Resource base = newResource(resourceClass, dir.toFile()))
@@ -1104,7 +1084,6 @@ public class FileSystemResourceTest
@ParameterizedTest
@ValueSource(classes = PathResource.class) // FileResource does not support this
- @DisabledOnOs(WINDOWS)
public void testPipe(Class resourceClass) throws Exception
{
Path dir = workDir.getEmptyPathDir();
@@ -1116,11 +1095,9 @@ public class FileSystemResourceTest
Path foo = dir.resolve("foo|bar.txt");
Files.createFile(foo);
}
- catch (Exception e)
+ catch (InvalidPathException e)
{
- // if unable to create file, no point testing the rest.
- // this is the path that Microsoft Windows takes.
- assumeTrue(true, "Not supported on this OS");
+ assumeTrue(false, "Unable to create file with pipe symbol");
}
try (Resource base = newResource(resourceClass, dir.toFile()))
@@ -1477,10 +1454,7 @@ public class FileSystemResourceTest
}
catch (InvalidPathException e)
{
- // if unable to create file, no point testing the rest.
- // this is the path that occurs if you have a system that doesn't support UTF-8
- // directory names (or you simply don't have a Locale set properly)
- assumeTrue(true, "Not supported on this OS");
+ assumeTrue(false, "Unable to create directory with utf-8 character");
return;
}
diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java
index b1787fe2d72..6e44ceb17da 100644
--- a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java
+++ b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java
@@ -19,6 +19,7 @@ import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
+import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.stream.Stream;
@@ -29,7 +30,6 @@ import org.eclipse.jetty.util.IO;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.params.ParameterizedTest;
@@ -43,6 +43,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
public class ResourceTest
{
@@ -287,15 +288,23 @@ public class ResourceTest
}
@Test
- @DisabledOnOs(OS.WINDOWS) // this uses forbidden characters on some Windows Environments
public void testGlobPath() throws IOException
{
Path testDir = MavenTestingUtils.getTargetTestingPath("testGlobPath");
FS.ensureEmpty(testDir);
- String globReference = testDir.toAbsolutePath().toString() + File.separator + '*';
- Resource globResource = Resource.newResource(globReference);
- assertNotNull(globResource, "Should have produced a Resource");
+ try
+ {
+ String globReference = testDir.toAbsolutePath() + File.separator + '*';
+ Resource globResource = Resource.newResource(globReference);
+ assertNotNull(globResource, "Should have produced a Resource");
+ }
+ catch (InvalidPathException e)
+ {
+ // if unable to reference the glob file, no point testing the rest.
+ // this is the path that Microsoft Windows takes.
+ assumeTrue(false, "Glob not supported on this OS");
+ }
}
@Test
diff --git a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/HugeResourceTest.java b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/HugeResourceTest.java
index 2fa8c222e53..c129dfb0479 100644
--- a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/HugeResourceTest.java
+++ b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/HugeResourceTest.java
@@ -123,9 +123,22 @@ public class HugeResourceTest
@AfterAll
public static void cleanupTestFiles()
{
- FS.ensureDeleted(staticBase);
- FS.ensureDeleted(outputDir);
- FS.ensureDeleted(multipartTempDir);
+ quietlyDelete(staticBase);
+ quietlyDelete(outputDir);
+ quietlyDelete(multipartTempDir);
+ }
+
+ private static void quietlyDelete(Path path)
+ {
+ try
+ {
+ if (path != null)
+ FS.ensureDeleted(path);
+ }
+ catch (Throwable ignore)
+ {
+ // ignore
+ }
}
private static void makeStaticFile(Path staticFile, long size) throws IOException
diff --git a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/TempDirTest.java b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/TempDirTest.java
index 4f95f09fd1d..e31399daf11 100644
--- a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/TempDirTest.java
+++ b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/TempDirTest.java
@@ -25,9 +25,10 @@ import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.util.IO;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
@@ -295,6 +296,7 @@ public class TempDirTest
* so we _will_ have permission to write to this directory.
*/
@DisabledIfSystemProperty(named = "env", matches = "ci")
+ @DisabledOnOs(value = OS.WINDOWS, disabledReason = "Test/Temp directory is always writable")
@Test
public void attributeWithInvalidPermissions()
{
diff --git a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppDefaultServletTest.java b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppDefaultServletTest.java
index 2ab5aeb110b..b28a0ad4818 100644
--- a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppDefaultServletTest.java
+++ b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppDefaultServletTest.java
@@ -23,10 +23,11 @@ import org.eclipse.jetty.http.UriCompliance;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.LocalConnector;
import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
-import org.eclipse.jetty.util.IO;
+import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
+import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
@@ -35,8 +36,10 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+@ExtendWith(WorkDirExtension.class)
public class WebAppDefaultServletTest
{
+ public WorkDir workDir;
private Server server;
private LocalConnector connector;
@@ -48,9 +51,7 @@ public class WebAppDefaultServletTest
connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setUriCompliance(UriCompliance.RFC3986);
server.addConnector(connector);
- Path directoryPath = MavenTestingUtils.getTargetTestingDir().toPath();
- IO.delete(directoryPath.toFile());
- Files.createDirectories(directoryPath);
+ Path directoryPath = workDir.getEmptyPathDir();
Path welcomeResource = directoryPath.resolve("index.html");
try (OutputStream output = Files.newOutputStream(welcomeResource))
{
diff --git a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/WebSocketOverHTTP2Test.java b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/WebSocketOverHTTP2Test.java
index d2d76a79463..875e184e6de 100644
--- a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/WebSocketOverHTTP2Test.java
+++ b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/WebSocketOverHTTP2Test.java
@@ -63,6 +63,8 @@ import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerI
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsStringIgnoringCase;
@@ -234,6 +236,7 @@ public class WebSocketOverHTTP2Test
}
@Test
+ @DisabledOnOs(value = OS.WINDOWS, disabledReason = "Issue #6660 - Windows does not throw ConnectException")
public void testWebSocketConnectPortDoesNotExist() throws Exception
{
startServer();
diff --git a/pom.xml b/pom.xml
index 9ed71656e0f..7f3a5be5a4e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -79,7 +79,8 @@
src/it/settings.xml
false
0
- 1.15.1
+ 1.16.0
+ 5.8.0
2.7.0
@@ -1151,7 +1152,7 @@
net.java.dev.jna
jna
- 5.6.0
+ ${jna.version}
diff --git a/tests/test-distribution/pom.xml b/tests/test-distribution/pom.xml
index 304f6da8356..a533301f2d1 100644
--- a/tests/test-distribution/pom.xml
+++ b/tests/test-distribution/pom.xml
@@ -191,6 +191,11 @@
gcloud
test
+
+ org.testcontainers
+ junit-jupiter
+ test
+
org.mariadb.jdbc
mariadb-java-client
diff --git a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java
index 1201ac5c170..a051e06e42b 100644
--- a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java
+++ b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java
@@ -275,7 +275,7 @@ public class DistributionTests extends AbstractJettyHomeTest
}
@Test
- @DisabledOnOs(OS.WINDOWS) // jnr not supported on windows
+ @DisabledOnOs(value = OS.WINDOWS, disabledReason = "jnr not supported on windows")
public void testUnixSocket() throws Exception
{
String dir = System.getProperty("jetty.unixdomain.dir");
diff --git a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/LoggingOptionsTests.java b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/LoggingOptionsTests.java
index 3d3278b4399..c21e49eb0d7 100644
--- a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/LoggingOptionsTests.java
+++ b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/LoggingOptionsTests.java
@@ -42,8 +42,8 @@ public class LoggingOptionsTests extends AbstractJettyHomeTest
return Stream.of(
Arguments.of("logging-jetty",
Arrays.asList(
- "\\$\\{jetty.home\\}/lib/logging/slf4j-api-.*\\.jar",
- "\\$\\{jetty.home\\}/lib/logging/jetty-slf4j-impl-.*\\.jar"),
+ "\\$\\{jetty.home\\}[/\\\\]lib[/\\\\]logging[/\\\\]slf4j-api-.*\\.jar",
+ "\\$\\{jetty.home\\}[/\\\\]lib[/\\\\]logging[/\\\\]jetty-slf4j-impl-.*\\.jar"),
Arrays.asList(
"logging/slf4j",
"logging-jetty"
@@ -51,9 +51,9 @@ public class LoggingOptionsTests extends AbstractJettyHomeTest
),
Arguments.of("logging-logback",
Arrays.asList(
- "\\$\\{jetty.home\\}/lib/logging/slf4j-api-.*\\.jar",
- "\\$\\{jetty.base\\}/lib/logging/logback-classic-.*\\.jar",
- "\\$\\{jetty.base\\}/lib/logging/logback-core-.*\\.jar"
+ "\\$\\{jetty.home\\}[/\\\\]lib[/\\\\]logging[/\\\\]slf4j-api-.*\\.jar",
+ "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]logback-classic-.*\\.jar",
+ "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]logback-core-.*\\.jar"
),
Arrays.asList(
"logging/slf4j",
@@ -62,8 +62,8 @@ public class LoggingOptionsTests extends AbstractJettyHomeTest
),
Arguments.of("logging-jul",
Arrays.asList(
- "\\$\\{jetty.home\\}/lib/logging/slf4j-api-.*\\.jar",
- "\\$\\{jetty.base\\}/lib/logging/slf4j-jdk14-.*\\.jar"
+ "\\$\\{jetty.home\\}[/\\\\]lib[/\\\\]logging[/\\\\]slf4j-api-.*\\.jar",
+ "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]slf4j-jdk14-.*\\.jar"
),
Arrays.asList(
"logging/slf4j",
@@ -72,8 +72,8 @@ public class LoggingOptionsTests extends AbstractJettyHomeTest
),
Arguments.of("logging-log4j1",
Arrays.asList(
- "\\$\\{jetty.home\\}/lib/logging/slf4j-api-.*\\.jar",
- "\\$\\{jetty.base\\}/lib/logging/slf4j-log4j12-.*\\.jar"
+ "\\$\\{jetty.home\\}[/\\\\]lib[/\\\\]logging[/\\\\]slf4j-api-.*\\.jar",
+ "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]slf4j-log4j12-.*\\.jar"
),
Arrays.asList(
"logging/slf4j",
@@ -82,10 +82,10 @@ public class LoggingOptionsTests extends AbstractJettyHomeTest
),
Arguments.of("logging-log4j2",
Arrays.asList(
- "\\$\\{jetty.home\\}/lib/logging/slf4j-api-.*\\.jar",
- "\\$\\{jetty.base\\}/lib/logging/log4j-slf4j18-impl-.*\\.jar",
- "\\$\\{jetty.base\\}/lib/logging/log4j-api-.*\\.jar",
- "\\$\\{jetty.base\\}/lib/logging/log4j-core-.*\\.jar"
+ "\\$\\{jetty.home\\}[/\\\\]lib[/\\\\]logging[/\\\\]slf4j-api-.*\\.jar",
+ "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]log4j-slf4j18-impl-.*\\.jar",
+ "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]log4j-api-.*\\.jar",
+ "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]log4j-core-.*\\.jar"
),
Arrays.asList(
"logging/slf4j",
@@ -95,7 +95,7 @@ public class LoggingOptionsTests extends AbstractJettyHomeTest
// Disabled, as slf4j noop is not supported by output/log monitoring of AbstractJettyHomeTest
/* Arguments.of("logging-noop",
Arrays.asList(
- "\\$\\{jetty.home\\}/lib/logging/slf4j-api-.*\\.jar"
+ "\\$\\{jetty.home\\}[/\\\\]lib[/\\\\]logging[/\\\\]slf4j-api-.*\\.jar"
), Arrays.asList(
"logging/slf4j",
"logging-log4j2"
@@ -103,12 +103,12 @@ public class LoggingOptionsTests extends AbstractJettyHomeTest
),*/
Arguments.of("logging-logback,logging-jcl-capture,logging-jul-capture,logging-log4j1-capture",
Arrays.asList(
- "\\$\\{jetty.home\\}/lib/logging/slf4j-api-.*\\.jar",
- "\\$\\{jetty.base\\}/lib/logging/logback-classic-.*\\.jar",
- "\\$\\{jetty.base\\}/lib/logging/logback-core-.*\\.jar",
- "\\$\\{jetty.base\\}/lib/logging/jcl-over-slf4j-.*\\.jar",
- "\\$\\{jetty.base\\}/lib/logging/jul-to-slf4j-.*\\.jar",
- "\\$\\{jetty.base\\}/lib/logging/log4j-over-slf4j-.*\\.jar"
+ "\\$\\{jetty.home\\}[/\\\\]lib[/\\\\]logging[/\\\\]slf4j-api-.*\\.jar",
+ "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]logback-classic-.*\\.jar",
+ "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]logback-core-.*\\.jar",
+ "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]jcl-over-slf4j-.*\\.jar",
+ "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]jul-to-slf4j-.*\\.jar",
+ "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]log4j-over-slf4j-.*\\.jar"
),
Arrays.asList(
"logging/slf4j",
diff --git a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/AbstractSessionDistributionTests.java b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/AbstractSessionDistributionTests.java
index c35171cd5fa..6871d2eb1c0 100644
--- a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/AbstractSessionDistributionTests.java
+++ b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/AbstractSessionDistributionTests.java
@@ -32,12 +32,14 @@ import org.eclipse.jetty.tests.distribution.AbstractJettyHomeTest;
import org.eclipse.jetty.tests.distribution.JettyHomeTester;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.testcontainers.junit.jupiter.Testcontainers;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@Testcontainers(disabledWithoutDocker = true)
public abstract class AbstractSessionDistributionTests extends AbstractJettyHomeTest
{
diff --git a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/FileSessionDistributionTests.java b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/FileSessionDistributionTests.java
index 025bee15b69..614b89a5e47 100644
--- a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/FileSessionDistributionTests.java
+++ b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/FileSessionDistributionTests.java
@@ -16,9 +16,12 @@ package org.eclipse.jetty.tests.distribution.session;
import java.util.Collections;
import java.util.List;
-/**
- *
- */
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+@Testcontainers(disabledWithoutDocker = false)
public class FileSessionDistributionTests extends AbstractSessionDistributionTests
{
@@ -52,4 +55,11 @@ public class FileSessionDistributionTests extends AbstractSessionDistributionTes
return Collections.emptyList();
}
+ @Override
+ @Test
+ @DisabledOnOs(value = OS.WINDOWS, disabledReason = "File always locked between stop/start")
+ public void stopRestartWebappTestSessionContentSaved() throws Exception
+ {
+ super.stopRestartWebappTestSessionContentSaved();
+ }
}
diff --git a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/FileSessionWithMemcacheDistributionTests.java b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/FileSessionWithMemcacheDistributionTests.java
index 70973d96415..63e4b8616fd 100644
--- a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/FileSessionWithMemcacheDistributionTests.java
+++ b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/FileSessionWithMemcacheDistributionTests.java
@@ -43,6 +43,7 @@ public class FileSessionWithMemcacheDistributionTests extends AbstractSessionDis
{
memcached =
new GenericContainer("memcached:" + System.getProperty("memcached.docker.version", "1.6.6"))
+ .withExposedPorts(11211)
.withLogConsumer(new Slf4jLogConsumer(MEMCACHED_LOG));
memcached.start();
this.host = memcached.getContainerIpAddress();
diff --git a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/HazelcastSessionDistributionTests.java b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/HazelcastSessionDistributionTests.java
index 338391e766f..7e541697e2d 100644
--- a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/HazelcastSessionDistributionTests.java
+++ b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/HazelcastSessionDistributionTests.java
@@ -30,9 +30,13 @@ import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.tests.distribution.JettyHomeTester;
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.testcontainers.DockerClientFactory;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
@@ -43,22 +47,24 @@ import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
-/**
- * This simulate the onlyClient option which means the JVM running Jetty is only an Hazelcast client and not part
- * of the cluster
- */
public class HazelcastSessionDistributionTests extends AbstractSessionDistributionTests
{
private static final Logger HAZELCAST_LOG = LoggerFactory.getLogger("org.eclipse.jetty.tests.distribution.session.HazelcastLogs");
private static final Logger LOGGER = LoggerFactory.getLogger(HazelcastSessionDistributionTests.class);
- private GenericContainer hazelcast = new GenericContainer("hazelcast/hazelcast:" + System.getProperty("hazelcast.version", "4.1"))
+ private GenericContainer> hazelcast;
+
+ private Path hazelcastJettyPath;
+
+ @BeforeEach
+ public void setupHazelcast()
+ {
+ hazelcast = new GenericContainer<>("hazelcast/hazelcast:" + System.getProperty("hazelcast.version", "4.1"))
.withExposedPorts(5701)
.waitingFor(Wait.forListeningPort())
.withLogConsumer(new Slf4jLogConsumer(HAZELCAST_LOG));
-
- private Path hazelcastJettyPath;
+ }
@Override
public void startExternalSessionStorage() throws Exception
@@ -75,12 +81,12 @@ public class HazelcastSessionDistributionTests extends AbstractSessionDistributi
tokenValues.put("hazelcast_port", Integer.toString(hazelcastPort));
this.hazelcastJettyPath = Paths.get("target/hazelcast-client.xml");
transformFileWithHostAndPort(Paths.get("src/test/resources/hazelcast-client.xml"),
- hazelcastJettyPath,
- tokenValues);
+ hazelcastJettyPath,
+ tokenValues);
}
@Override
- public void stopExternalSessionStorage() throws Exception
+ public void stopExternalSessionStorage()
{
hazelcast.stop();
}
@@ -101,31 +107,32 @@ public class HazelcastSessionDistributionTests extends AbstractSessionDistributi
public List getSecondStartExtraArgs()
{
return Arrays.asList(
- "jetty.session.hazelcast.configurationLocation=" + hazelcastJettyPath.toAbsolutePath(),
- "jetty.session.hazelcast.onlyClient=true"
- );
+ "jetty.session.hazelcast.configurationLocation=" + hazelcastJettyPath.toAbsolutePath(),
+ "jetty.session.hazelcast.onlyClient=true"
+ );
}
- @Disabled("not working see https://github.com/hazelcast/hazelcast/issues/18508")
/**
* This test simulate Hazelcast instance within Jetty a cluster member with an external Hazelcast instance
*/
+ @Test
+ @Disabled("not working see https://github.com/hazelcast/hazelcast/issues/18508")
public void testHazelcastRemoteAndPartOfCluster() throws Exception
{
Map env = new HashMap<>();
// -Dhazelcast.local.publicAddress=127.0.0.1:5701
env.put("JAVA_OPTS", "-Dhazelcast.config=/opt/hazelcast/config_ext/hazelcast.xml");
- try (GenericContainer hazelcast =
- new GenericContainer("hazelcast/hazelcast:" + System.getProperty("hazelcast.version", "4.1"))
+ try (GenericContainer> hazelcast =
+ new GenericContainer<>("hazelcast/hazelcast:" + System.getProperty("hazelcast.version", "4.1"))
.withExposedPorts(5701, 5705)
.withEnv(env)
.waitingFor(Wait.forLogMessage(".*is STARTED.*", 1))
//.withNetworkMode("host")
//.waitingFor(Wait.forListeningPort())
.withClasspathResourceMapping("hazelcast-server.xml",
- "/opt/hazelcast/config_ext/hazelcast.xml",
- BindMode.READ_ONLY)
+ "/opt/hazelcast/config_ext/hazelcast.xml",
+ BindMode.READ_ONLY)
.withLogConsumer(new Slf4jLogConsumer(HAZELCAST_LOG)))
{
hazelcast.start();
@@ -141,8 +148,8 @@ public class HazelcastSessionDistributionTests extends AbstractSessionDistributi
// tokenValues.put("hazelcast_multicast_port", Integer.toString(hazelcastMultiCastPort));
Path hazelcastJettyPath = Paths.get("target/hazelcast-jetty.xml");
transformFileWithHostAndPort(Paths.get("src/test/resources/hazelcast-jetty.xml"),
- hazelcastJettyPath,
- tokenValues);
+ hazelcastJettyPath,
+ tokenValues);
String jettyVersion = System.getProperty("jettyVersion");
JettyHomeTester distribution = JettyHomeTester.Builder.newInstance()
@@ -195,7 +202,6 @@ public class HazelcastSessionDistributionTests extends AbstractSessionDistributi
assertThat(response.getContentAsString(), containsString("SESSION READ CHOCOLATE THE BEST:FRENCH"));
}
}
-
}
}
@@ -220,13 +226,11 @@ public class HazelcastSessionDistributionTests extends AbstractSessionDistributi
newLine.setLength(0);
newLine.append(interpolated);
});
- fileContent.append(newLine.toString());
+ fileContent.append(newLine);
fileContent.append(System.lineSeparator());
});
-
outputStream.write(fileContent.toString().getBytes(StandardCharsets.UTF_8));
}
}
-
}
diff --git a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/MongodbSessionDistributionTests.java b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/MongodbSessionDistributionTests.java
index 80558f61d3c..56a0a6d32df 100644
--- a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/MongodbSessionDistributionTests.java
+++ b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/session/MongodbSessionDistributionTests.java
@@ -32,12 +32,13 @@ public class MongodbSessionDistributionTests extends AbstractSessionDistribution
private static final Logger MONGO_LOG = LoggerFactory.getLogger("org.eclipse.jetty.tests.distribution.session.mongo");
+ private static final int MONGO_PORT = 27017;
+
final String imageName = "mongo:" + System.getProperty("mongo.docker.version", "2.2.7");
final GenericContainer mongoDBContainer =
new GenericContainer(imageName)
.withLogConsumer(new Slf4jLogConsumer(MONGO_LOG))
- .waitingFor(new LogMessageWaitStrategy()
- .withRegEx(".*waiting for connections.*"));
+ .withExposedPorts(MONGO_PORT);
private String host;
private int port;
@@ -46,7 +47,7 @@ public class MongodbSessionDistributionTests extends AbstractSessionDistribution
{
mongoDBContainer.start();
host = mongoDBContainer.getHost();
- port = mongoDBContainer.getMappedPort(27017);
+ port = mongoDBContainer.getMappedPort(MONGO_PORT);
}
@Override
diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/KeyStoreScannerTest.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/KeyStoreScannerTest.java
index c264b14e5ae..d5d78f26b95 100644
--- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/KeyStoreScannerTest.java
+++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/KeyStoreScannerTest.java
@@ -13,7 +13,9 @@
package org.eclipse.jetty.test;
+import java.io.IOException;
import java.net.URL;
+import java.nio.file.FileSystemException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
@@ -35,22 +37,23 @@ import org.eclipse.jetty.server.SecureRequestCustomizer;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
+import org.eclipse.jetty.toolchain.test.FS;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
+import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.util.ssl.KeyStoreScanner;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.extension.ExtendWith;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.condition.OS.WINDOWS;
+import static org.junit.jupiter.api.Assumptions.assumeFalse;
@ExtendWith(WorkDirExtension.class)
public class KeyStoreScannerTest
@@ -107,7 +110,7 @@ public class KeyStoreScannerTest
@AfterEach
public void stop() throws Exception
{
- server.stop();
+ LifeCycle.stop(server);
}
@Test
@@ -176,9 +179,9 @@ public class KeyStoreScannerTest
}
@Test
- @DisabledOnOs(WINDOWS) // does not support symbolic link
public void testReloadChangingSymbolicLink() throws Exception
{
+ assumeFileSystemSupportsSymlink();
Path keystorePath = keystoreDir.resolve("symlinkKeystore");
start(sslContextFactory ->
{
@@ -203,9 +206,9 @@ public class KeyStoreScannerTest
}
@Test
- @DisabledOnOs(WINDOWS) // does not support symbolic link
public void testReloadChangingTargetOfSymbolicLink() throws Exception
{
+ assumeFileSystemSupportsSymlink();
Path keystoreLink = keystoreDir.resolve("symlinkKeystore");
Path oldKeystoreSrc = MavenTestingUtils.getTestResourcePathFile("oldKeystore");
Path newKeystoreSrc = MavenTestingUtils.getTestResourcePathFile("newKeystore");
@@ -273,6 +276,28 @@ public class KeyStoreScannerTest
return (X509Certificate)certs[0];
}
+ private void assumeFileSystemSupportsSymlink() throws IOException
+ {
+ // Make symlink
+ Path dir = MavenTestingUtils.getTargetTestingPath("symlink-test");
+ FS.ensureEmpty(dir);
+
+ Path foo = dir.resolve("foo");
+ Path bar = dir.resolve("bar");
+
+ try
+ {
+ Files.createFile(foo);
+ Files.createSymbolicLink(bar, foo);
+ }
+ catch (UnsupportedOperationException | FileSystemException e)
+ {
+ // if unable to create symlink, no point testing the rest
+ // this is the path that Microsoft Windows takes.
+ assumeFalse(true, "Not supported");
+ }
+ }
+
private static class DefaultTrustManager implements X509TrustManager
{
@Override
diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616BaseTest.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616BaseTest.java
index 66d37d262e9..14b91147467 100644
--- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616BaseTest.java
+++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616BaseTest.java
@@ -96,7 +96,6 @@ public abstract class RFC2616BaseTest
server = testableserver;
server.load();
server.start();
- //server.getServer().dumpStdErr();
}
@BeforeEach
diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616NIOHttpsTest.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616NIOHttpsTest.java
index 6681f4ebb7a..5f8d06d8aa9 100644
--- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616NIOHttpsTest.java
+++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616NIOHttpsTest.java
@@ -18,13 +18,10 @@ import org.eclipse.jetty.test.support.XmlBasedJettyServer;
import org.eclipse.jetty.test.support.rawhttp.HttpSocket;
import org.eclipse.jetty.test.support.rawhttp.HttpsSocketImpl;
import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Disabled;
/**
* Perform the RFC2616 tests against a server running with the Jetty NIO Connector and listening on HTTPS (HTTP over SSL).
- * TODO
*/
-@Disabled("TODO")
public class RFC2616NIOHttpsTest extends RFC2616BaseTest
{
@BeforeAll
@@ -35,6 +32,7 @@ public class RFC2616NIOHttpsTest extends RFC2616BaseTest
server.addXmlConfiguration("RFC2616Base.xml");
server.addXmlConfiguration("RFC2616_Redirects.xml");
server.addXmlConfiguration("RFC2616_Filters.xml");
+ server.addXmlConfiguration("ssl.xml");
server.addXmlConfiguration("NIOHttps.xml");
setUpServer(server, RFC2616NIOHttpsTest.class);
}
diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/XmlBasedJettyServer.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/XmlBasedJettyServer.java
index 060c44b4ba4..e19387c95fd 100644
--- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/XmlBasedJettyServer.java
+++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/XmlBasedJettyServer.java
@@ -77,6 +77,10 @@ public class XmlBasedJettyServer
Path webappsDir = MavenTestingUtils.getTargetPath("webapps");
properties.setProperty("test.webapps", webappsDir.toString());
+ Path keystorePath = MavenTestingUtils.getTestResourcePathFile("keystore.p12");
+ properties.setProperty("jetty.sslContext.keyStorePath", keystorePath.toString());
+ properties.setProperty("jetty.sslContext.keyStorePassword", "storepwd");
+
// Write out configuration for use by ConfigurationManager.
Path testConfig = targetDir.resolve("testable-jetty-server-config.properties");
try (OutputStream out = Files.newOutputStream(testConfig))
diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/rawhttp/HttpsSocketImpl.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/rawhttp/HttpsSocketImpl.java
index 424bb7d1f05..1ebe471dc2c 100644
--- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/rawhttp/HttpsSocketImpl.java
+++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/rawhttp/HttpsSocketImpl.java
@@ -18,9 +18,7 @@ import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
-import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
@@ -40,21 +38,8 @@ public class HttpsSocketImpl implements HttpSocket
public HttpsSocketImpl() throws Exception
{
- @SuppressWarnings("unused")
- HostnameVerifier hostnameVerifier = new HostnameVerifier()
- {
- @Override
- public boolean verify(String urlHostName, SSLSession session)
- {
- LOG.warn("Warning: URL Host: " + urlHostName + " vs." + session.getPeerHost());
- return true;
- }
- };
-
- // Install the all-trusting trust manager
try
{
- // TODO real trust manager
this.sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, SslContextFactory.TRUST_ALL_CERTS, new java.security.SecureRandom());
}
@@ -70,7 +55,6 @@ public class HttpsSocketImpl implements HttpSocket
public Socket connect(InetAddress host, int port) throws IOException
{
SSLSocket sslsock = (SSLSocket)sslfactory.createSocket();
- sslsock.setEnabledProtocols(new String[]{"TLSv1"});
SocketAddress address = new InetSocketAddress(host, port);
sslsock.connect(address);
return sslsock;
diff --git a/tests/test-integration/src/test/resources/NIOHttps.xml b/tests/test-integration/src/test/resources/NIOHttps.xml
index b08409060f8..db2513ef8b9 100644
--- a/tests/test-integration/src/test/resources/NIOHttps.xml
+++ b/tests/test-integration/src/test/resources/NIOHttps.xml
@@ -1,36 +1,31 @@
-
+
-
-
-
+
+
+
-
-
- -
-
- http/1.1
-
-
-
- -
-
-
-
-
-
-
-
- 30000
-
+
+
+ -
+
+ http/1.1
+
+
+
+ -
+
+
+
+
+
+
+
-
-
-
diff --git a/tests/test-integration/src/test/resources/ssl.xml b/tests/test-integration/src/test/resources/ssl.xml
index df45814de18..88d6cf3e16f 100644
--- a/tests/test-integration/src/test/resources/ssl.xml
+++ b/tests/test-integration/src/test/resources/ssl.xml
@@ -1,22 +1,9 @@
- /
+
+
-
- /
-
-
-
- - SSL_RSA_WITH_DES_CBC_SHA
- - SSL_DHE_RSA_WITH_DES_CBC_SHA
- - SSL_DHE_DSS_WITH_DES_CBC_SHA
- - SSL_RSA_EXPORT_WITH_RC4_40_MD5
- - SSL_RSA_EXPORT_WITH_DES40_CBC_SHA
- - SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA
- - SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA
-
-
@@ -27,7 +14,12 @@
-
+
+
+ false
+ false
+
+
diff --git a/tests/test-integration/src/test/resources/webapp-contexts/RFC2616/rfc2616-webapp.xml b/tests/test-integration/src/test/resources/webapp-contexts/RFC2616/rfc2616-webapp.xml
index 55cd5a5c847..7c7a5934411 100644
--- a/tests/test-integration/src/test/resources/webapp-contexts/RFC2616/rfc2616-webapp.xml
+++ b/tests/test-integration/src/test/resources/webapp-contexts/RFC2616/rfc2616-webapp.xml
@@ -10,4 +10,12 @@
+
+ org.slf4j.
+ org.eclipse.jetty.logging.
+
+
+ -org.slf4j.
+ -org.eclipse.jetty.logging.
+
diff --git a/tests/test-sessions/test-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/MemcachedTestHelper.java b/tests/test-sessions/test-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/MemcachedTestHelper.java
index a9407c92376..0d5e3662971 100644
--- a/tests/test-sessions/test-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/MemcachedTestHelper.java
+++ b/tests/test-sessions/test-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/MemcachedTestHelper.java
@@ -149,7 +149,8 @@ public class MemcachedTestHelper
@SuppressWarnings({"rawtypes", "unchecked"})
static GenericContainer memcached =
new GenericContainer("memcached:" + System.getProperty("memcached.docker.version", "1.6.6"))
- .withLogConsumer(new Slf4jLogConsumer(MEMCACHED_LOG));
+ .withExposedPorts(11211)
+ .withLogConsumer(new Slf4jLogConsumer(MEMCACHED_LOG));
static
{
diff --git a/tests/test-sessions/test-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/MongoTestHelper.java b/tests/test-sessions/test-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/MongoTestHelper.java
index 6c5dd31c072..ef3f8188798 100644
--- a/tests/test-sessions/test-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/MongoTestHelper.java
+++ b/tests/test-sessions/test-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/MongoTestHelper.java
@@ -47,12 +47,13 @@ public class MongoTestHelper
public static final String DB_NAME = "HttpSessions";
public static final String COLLECTION_NAME = "testsessions";
+
+ private static final int MONGO_PORT = 27017;
static GenericContainer mongo =
new GenericContainer("mongo:" + System.getProperty("mongo.docker.version", "2.2.7"))
.withLogConsumer(new Slf4jLogConsumer(MONGO_LOG))
- .waitingFor(new LogMessageWaitStrategy()
- .withRegEx(".*waiting for connections.*"));
+ .withExposedPorts(MONGO_PORT);
static MongoClient mongoClient;
@@ -66,7 +67,7 @@ public class MongoTestHelper
long start = System.currentTimeMillis();
mongo.start();
mongoHost = mongo.getHost();
- mongoPort = mongo.getMappedPort(27017);
+ mongoPort = mongo.getMappedPort(MONGO_PORT);
LOG.info("Mongo container started for {}:{} - {}ms", mongoHost, mongoPort,
System.currentTimeMillis() - start);
mongoClient = new MongoClient(mongoHost, mongoPort);