Issue #5684 - Windows test overhaul (#6581)

Issue #5684 - Window's test overhaul

+ Migrate from @DisabledOnOs(WINDOWS) to assumptions on capabilities instead.
+ Fix other outstanding windows testing issues.
+ Cleanup FileBufferedResponseHandlerTest expectations on Windows.
+ PathWatcher scan interval is variable on windows
+ If unable to start testcase based on assumption,
  the stop shouldn't fail testcase
+ Increase various wait timeouts
+ Make tests less strict due to system speed issues
+ Disable Sni tests due to TLS behaviors differences in Windows
  + Windows TLSv1.3 seems to introduce this difference
  + If we restrict to TLSv1.2 this passes.
  + On Linux TLSv.13 on client side will always return a
  + javax.net.ssl.SSLHandshakeException in those test cases that expect it.
  + However, on Windows, Only the TLSv1.2 implementation will return a javax.net.ssl.SSLHandshakeException,
  + All other TLS versions on Windows will result in a
  + javax.net.ssl.SSLException: Software caused connection abort: recv failed
+ Disable ConcurrentStreamCreationTest
  + Not possible to create all of these streams.
+ Fixing DeploymentTempDirTest
  + Using unique workdir per testcase.
  + Don't expect to delete files / directories between tests
    (not supported on windows due to file locking anyway)
 + Fixing line ending difference on windows
 + InvalidPathException is a 404 Not Found
 + Cannot reuse test directory between runs due to memory mapped files that are still in use from previous run.
 + java.nio.file.FileSystemException: C:\code\jetty.project\jetty-webapp\target\tests\welcome#\index.html: The requested operation cannot be performed on a file with a user-mapped section open.

	at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
	at java.base/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:235)
	at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:478)
	at java.base/java.nio.file.Files.newOutputStream(Files.java:220)
	at org.eclipse.jetty.webapp/org.eclipse.jetty.webapp.WebAppDefaultServletTest.prepareServer(WebAppDefaultServletTest.java:84)

 + As is typical on windows, we are often unable to delete a file due to file locking issues.
 + Use a unique resource base between tests.
   This is to avoid file locking behaviors that prevent the
   resource base from being reused too quickly on windows.
 + Prevent test run if symlinks not supported
 + Allowing for Windows slosh char as well in asserts
 + SelectorUtils is File.separator dependent
 + Regex is now FS.separator independent
 + Using SelectorUtils from plexus correctly for include/exclude
 + Turning off mapped files for testing reasons.
 + Fix and re-enable RFC2616NIOHttpsTest
 + Issue #6552 - Fix test failures due to slf4j dep
 + Issue #6552 - upgrade testcontainers
 + Issue #6552 - move to assumption based docker existence
 + Issue #6552 - Fix enforcer rule violation on jna.
  Addresses the following side effect of upgrading testcontainers.

[WARNING] Rule 3: org.apache.maven.plugins.enforcer.RequireUpperBoundDeps failed with message:
Failed while enforcing RequireUpperBoundDeps. The error(s) are [
Require upper bound dependencies error for net.java.dev.jna:jna:5.6.0 paths to dependency are:
+-org.eclipse.jetty:infinispan-remote-query:10.0.7-SNAPSHOT
  +-org.testcontainers:testcontainers:1.16.0
    +-com.github.docker-java:docker-java-transport-zerodep:3.2.11
      +-net.java.dev.jna:jna:5.6.0 (managed) <-- net.java.dev.jna:jna:5.8.0

 + use annotation to disable test when docker not available and needed
 + Disabling FileSessionDistributionTests.stopRestartWebappTestSessionContentSaved on Windows
 + Using TLS basic
 + Programmatic removal of memory mapped behavior during testing
 + Fixing slf4j warning

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Co-authored-by: Olivier Lamy <oliver.lamy@gmail.com>
This commit is contained in:
Joakim Erdfelt 2021-08-26 11:26:46 -05:00 committed by GitHub
parent 2689cf75d1
commit c5a33e27d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
55 changed files with 461 additions and 421 deletions

View File

@ -68,7 +68,6 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; 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.EnabledOnJre;
import org.junit.jupiter.api.condition.EnabledOnOs; import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.JRE; 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.assertTrue;
import static org.junit.jupiter.api.Assertions.fail; 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.LINUX;
import static org.junit.jupiter.api.condition.OS.WINDOWS;
// Other JREs have slight differences in how TLS work // Other JREs have slight differences in how TLS work
// and this test expects a very specific TLS behavior. // and this test expects a very specific TLS behavior.
@ -1027,7 +1025,6 @@ public class SslBytesServerTest extends SslBytesTest
} }
@Test @Test
@DisabledOnOs(WINDOWS) // Don't run on Windows (buggy JVM)
public void testRequestWithBigContentWriteBlockedThenReset() throws Exception public void testRequestWithBigContentWriteBlockedThenReset() throws Exception
{ {
final SSLSocket client = newClient(); final SSLSocket client = newClient();
@ -1082,7 +1079,6 @@ public class SslBytesServerTest extends SslBytesTest
} }
@Test @Test
@DisabledOnOs(WINDOWS) // Don't run on Windows (buggy JVM)
public void testRequestWithBigContentReadBlockedThenReset() throws Exception public void testRequestWithBigContentReadBlockedThenReset() throws Exception
{ {
final SSLSocket client = newClient(); final SSLSocket client = newClient();

View File

@ -33,41 +33,49 @@ import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerCollection; import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.toolchain.test.FS; import org.eclipse.jetty.toolchain.test.FS;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils; 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.IO;
import org.eclipse.jetty.util.Scanner; 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.eclipse.jetty.webapp.WebAppContext;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNotSame; import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
@ExtendWith(WorkDirExtension.class)
public class DeploymentTempDirTest public class DeploymentTempDirTest
{ {
private static final Logger LOG = Log.getLogger(DeploymentTempDirTest.class); public WorkDir workDir;
private final WebAppProvider webAppProvider = new WebAppProvider(); private Path tmpDir;
private final ContextHandlerCollection contexts = new ContextHandlerCollection(); private Path webapps;
private final Path testDir = MavenTestingUtils.getTargetTestingPath(DeploymentTempDirTest.class.getSimpleName()); private Server server;
private final Path tmpDir = testDir.resolve("tmpDir"); private WebAppProvider webAppProvider;
private final Path webapps = testDir.resolve("webapps"); private ContextHandlerCollection contexts;
private final Server server = new Server();
private final TestListener listener = new TestListener(); private final TestListener listener = new TestListener();
@BeforeEach @BeforeEach
public void setup() throws Exception 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); ServerConnector connector = new ServerConnector(server);
server.addConnector(connector); server.addConnector(connector);
FS.ensureEmpty(testDir); webAppProvider = new WebAppProvider();
FS.ensureEmpty(tmpDir);
FS.ensureEmpty(webapps);
webAppProvider.setMonitoredDirName(webapps.toString()); webAppProvider.setMonitoredDirName(webapps.toString());
webAppProvider.setScanInterval(0); webAppProvider.setScanInterval(0);
@ -75,6 +83,7 @@ public class DeploymentTempDirTest
deploymentManager.addAppProvider(webAppProvider); deploymentManager.addAppProvider(webAppProvider);
server.addBean(deploymentManager); server.addBean(deploymentManager);
contexts = new ContextHandlerCollection();
HandlerCollection handlerCollection = new HandlerCollection(); HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.addHandler(contexts); handlerCollection.addHandler(contexts);
handlerCollection.addHandler(new DefaultHandler()); handlerCollection.addHandler(new DefaultHandler());

View File

@ -26,13 +26,10 @@ import org.eclipse.jetty.util.resource.Resource;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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 * 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}. * deployed webapps due to incoming changes identified by the {@link ScanningAppProvider}.
@ -155,8 +152,6 @@ public class ScanningAppProviderRuntimeUpdatesTest
* @throws Exception on test failure * @throws Exception on test failure
*/ */
@Test @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 public void testAfterStartupThenUpdateContext() throws Exception
{ {
jetty.copyWebapp("foo-webapp-1.war", "foo.war"); jetty.copyWebapp("foo-webapp-1.war", "foo.war");

View File

@ -99,6 +99,8 @@ public class WebAppProviderTest
@Test @Test
public void testStartupContext() public void testStartupContext()
{ {
assumeTrue(symlinkSupported);
// Check Server for Handlers // Check Server for Handlers
jetty.assertWebAppContextsExists("/bar", "/foo", "/bob"); jetty.assertWebAppContextsExists("/bar", "/foo", "/bob");

View File

@ -29,9 +29,12 @@ import org.eclipse.jetty.http2.frames.HeadersFrame;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.Promise;
import org.junit.jupiter.api.Test; 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; 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 public class ConcurrentStreamCreationTest extends AbstractTest
{ {
@Test @Test

View File

@ -98,9 +98,8 @@ public class SmallThreadPoolLoadTest extends AbstractTest
Thread testThread = Thread.currentThread(); Thread testThread = Thread.currentThread();
Scheduler.Task task = client.getScheduler().schedule(() -> Scheduler.Task task = client.getScheduler().schedule(() ->
{ {
logger.warn("Interrupting test, it is taking too long{}Server:{}{}{}Client:{}{}", logger.warn("Interrupting test, it is taking too long - \nServer: \n" +
System.lineSeparator(), System.lineSeparator(), server.dump(), server.dump() + "\nClient: \n" + client.dump());
System.lineSeparator(), System.lineSeparator(), client.dump());
testThread.interrupt(); testThread.interrupt();
}, iterations * factor, TimeUnit.MILLISECONDS); }, iterations * factor, TimeUnit.MILLISECONDS);
@ -184,9 +183,8 @@ public class SmallThreadPoolLoadTest extends AbstractTest
if (success) if (success)
latch.countDown(); latch.countDown();
else else
logger.warn("Request {} took too long{}Server:{}{}{}Client:{}{}", requestId, logger.warn("Request {} took too long - \nServer: \n" +
System.lineSeparator(), System.lineSeparator(), server.dump(), server.dump() + "\nClient: \n" + client.dump(), requestId);
System.lineSeparator(), System.lineSeparator(), client.dump());
return !reset.get(); return !reset.get();
} }

View File

@ -125,6 +125,11 @@
<artifactId>maven-artifact-transfer</artifactId> <artifactId>maven-artifact-transfer</artifactId>
<version>0.12.0</version> <version>0.12.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.4.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId> <artifactId>maven-plugin-api</artifactId>

View File

@ -28,7 +28,6 @@ import java.util.jar.Manifest;
import org.codehaus.plexus.util.SelectorUtils; import org.codehaus.plexus.util.SelectorUtils;
import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.URIUtil; import org.eclipse.jetty.util.URIUtil;
import org.eclipse.jetty.util.resource.JarResource; import org.eclipse.jetty.util.resource.JarResource;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -87,7 +86,7 @@ public class SelectiveJarResource extends JarResource
{ {
for (String include : _includes) for (String include : _includes)
{ {
if (SelectorUtils.matchPath(include, name, _caseSensitive)) if (SelectorUtils.matchPath(include, name, "/", _caseSensitive))
{ {
return true; return true;
} }
@ -99,7 +98,7 @@ public class SelectiveJarResource extends JarResource
{ {
for (String exclude : _excludes) for (String exclude : _excludes)
{ {
if (SelectorUtils.matchPath(exclude, name, _caseSensitive)) if (SelectorUtils.matchPath(exclude, name, "/", _caseSensitive))
{ {
return true; return true;
} }
@ -140,8 +139,8 @@ public class SelectiveJarResource extends JarResource
String entryName = entry.getName(); String entryName = entry.getName();
LOG.debug("Looking at {}", entryName); LOG.debug("Looking at {}", entryName);
String dotCheck = StringUtil.replace(entryName, '\\', '/'); // make sure no access out of the root entry is present
dotCheck = URIUtil.canonicalPath(dotCheck); String dotCheck = URIUtil.canonicalPath(entryName);
if (dotCheck == null) if (dotCheck == null)
{ {
LOG.info("Invalid entry: {}", entryName); LOG.info("Invalid entry: {}", entryName);

View File

@ -13,96 +13,81 @@
package org.eclipse.jetty.maven.plugin; package org.eclipse.jetty.maven.plugin;
import java.io.File;
import java.net.URL; import java.net.URL;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
import org.junit.jupiter.api.BeforeEach; import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
import org.junit.jupiter.api.Test; 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.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
/** @ExtendWith(WorkDirExtension.class)
*
*
*/
public class TestSelectiveJarResource public class TestSelectiveJarResource
{ {
File unpackParent; public WorkDir workDir;
@BeforeEach
public void setUp() throws Exception
{
unpackParent = MavenTestingUtils.getTargetTestingDir("selective-jar-resource");
unpackParent.mkdirs();
}
@Test @Test
public void testIncludesNoExcludes() throws Exception public void testIncludesNoExcludes() throws Exception
{ {
File unpackDir = File.createTempFile("inc", "exc", unpackParent); Path unpackDir = workDir.getEmptyPathDir();
unpackDir.delete();
unpackDir.mkdirs();
File testJar = MavenTestingUtils.getTestResourceFile("selective-jar-test.jar"); Path testJar = MavenTestingUtils.getTestResourcePathFile("selective-jar-test.jar");
try (SelectiveJarResource sjr = new SelectiveJarResource(new URL("jar:" + Resource.toURL(testJar).toString() + "!/"));) try (SelectiveJarResource sjr = new SelectiveJarResource(new URL("jar:" + testJar.toUri().toASCIIString() + "!/")))
{ {
sjr.setCaseSensitive(false); sjr.setCaseSensitive(false);
List<String> includes = new ArrayList<>(); List<String> includes = new ArrayList<>();
includes.add("**/*.html"); includes.add("**/*.html");
sjr.setIncludes(includes); sjr.setIncludes(includes);
sjr.copyTo(unpackDir); sjr.copyTo(unpackDir.toFile());
assertTrue(Files.exists(unpackDir.toPath().resolve("top.html"))); assertTrue(Files.exists(unpackDir.resolve("top.html")));
assertTrue(Files.exists(unpackDir.toPath().resolve("aa/a1.html"))); assertTrue(Files.exists(unpackDir.resolve("aa/a1.html")));
assertTrue(Files.exists(unpackDir.toPath().resolve("aa/a2.html"))); assertTrue(Files.exists(unpackDir.resolve("aa/a2.html")));
assertTrue(Files.exists(unpackDir.toPath().resolve("aa/deep/a3.html"))); assertTrue(Files.exists(unpackDir.resolve("aa/deep/a3.html")));
assertTrue(Files.exists(unpackDir.toPath().resolve("bb/b1.html"))); assertTrue(Files.exists(unpackDir.resolve("bb/b1.html")));
assertTrue(Files.exists(unpackDir.toPath().resolve("bb/b2.html"))); assertTrue(Files.exists(unpackDir.resolve("bb/b2.html")));
assertTrue(Files.exists(unpackDir.toPath().resolve("cc/c1.html"))); assertTrue(Files.exists(unpackDir.resolve("cc/c1.html")));
assertTrue(Files.exists(unpackDir.toPath().resolve("cc/c2.html"))); assertTrue(Files.exists(unpackDir.resolve("cc/c2.html")));
} }
} }
@Test @Test
public void testExcludesNoIncludes() throws Exception public void testExcludesNoIncludes() throws Exception
{ {
File unpackDir = File.createTempFile("exc", "inc", unpackParent); Path unpackDir = workDir.getEmptyPathDir();
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 testJar = MavenTestingUtils.getTestResourcePathFile("selective-jar-test.jar");
try (SelectiveJarResource sjr = new SelectiveJarResource(new URL("jar:" + testJar.toUri().toASCIIString() + "!/")))
{ {
sjr.setCaseSensitive(false); sjr.setCaseSensitive(false);
List<String> excludes = new ArrayList<>(); List<String> excludes = new ArrayList<>();
excludes.add("**/*"); excludes.add("**/*");
sjr.setExcludes(excludes); sjr.setExcludes(excludes);
sjr.copyTo(unpackDir); sjr.copyTo(unpackDir.toFile());
assertFalse(Files.exists(unpackDir.toPath().resolve("top.html"))); assertFalse(Files.exists(unpackDir.resolve("top.html")));
assertFalse(Files.exists(unpackDir.toPath().resolve("aa/a1.html"))); assertFalse(Files.exists(unpackDir.resolve("aa/a1.html")));
assertFalse(Files.exists(unpackDir.toPath().resolve("aa/a2.html"))); assertFalse(Files.exists(unpackDir.resolve("aa/a2.html")));
assertFalse(Files.exists(unpackDir.toPath().resolve("aa/deep/a3.html"))); assertFalse(Files.exists(unpackDir.resolve("aa/deep/a3.html")));
assertFalse(Files.exists(unpackDir.toPath().resolve("bb/b1.html"))); assertFalse(Files.exists(unpackDir.resolve("bb/b1.html")));
assertFalse(Files.exists(unpackDir.toPath().resolve("bb/b2.html"))); assertFalse(Files.exists(unpackDir.resolve("bb/b2.html")));
assertFalse(Files.exists(unpackDir.toPath().resolve("cc/c1.html"))); assertFalse(Files.exists(unpackDir.resolve("cc/c1.html")));
assertFalse(Files.exists(unpackDir.toPath().resolve("cc/c2.html"))); assertFalse(Files.exists(unpackDir.resolve("cc/c2.html")));
} }
} }
@Test @Test
public void testIncludesExcludes() throws Exception public void testIncludesExcludes() throws Exception
{ {
File unpackDir = File.createTempFile("exc", "andinc", unpackParent); Path unpackDir = workDir.getEmptyPathDir();
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 testJar = MavenTestingUtils.getTestResourcePathFile("selective-jar-test.jar");
try (SelectiveJarResource sjr = new SelectiveJarResource(new URL("jar:" + testJar.toUri().toASCIIString() + "!/")))
{ {
sjr.setCaseSensitive(false); sjr.setCaseSensitive(false);
List<String> excludes = new ArrayList<>(); List<String> excludes = new ArrayList<>();
@ -111,15 +96,15 @@ public class TestSelectiveJarResource
List<String> includes = new ArrayList<>(); List<String> includes = new ArrayList<>();
includes.add("bb/*"); includes.add("bb/*");
sjr.setIncludes(includes); sjr.setIncludes(includes);
sjr.copyTo(unpackDir); sjr.copyTo(unpackDir.toFile());
assertFalse(Files.exists(unpackDir.toPath().resolve("top.html"))); assertFalse(Files.exists(unpackDir.resolve("top.html")));
assertFalse(Files.exists(unpackDir.toPath().resolve("aa/a1.html"))); assertFalse(Files.exists(unpackDir.resolve("aa/a1.html")));
assertFalse(Files.exists(unpackDir.toPath().resolve("aa/a2.html"))); assertFalse(Files.exists(unpackDir.resolve("aa/a2.html")));
assertFalse(Files.exists(unpackDir.toPath().resolve("aa/deep/a3.html"))); assertFalse(Files.exists(unpackDir.resolve("aa/deep/a3.html")));
assertTrue(Files.exists(unpackDir.toPath().resolve("bb/b1.html"))); assertTrue(Files.exists(unpackDir.resolve("bb/b1.html")));
assertTrue(Files.exists(unpackDir.toPath().resolve("bb/b2.html"))); assertTrue(Files.exists(unpackDir.resolve("bb/b2.html")));
assertFalse(Files.exists(unpackDir.toPath().resolve("cc/c1.html"))); assertFalse(Files.exists(unpackDir.resolve("cc/c1.html")));
assertFalse(Files.exists(unpackDir.toPath().resolve("cc/c2.html"))); assertFalse(Files.exists(unpackDir.resolve("cc/c2.html")));
} }
} }
} }

View File

@ -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

View File

@ -1290,7 +1290,7 @@ public class AsyncMiddleManServletTest
startClient(); startClient();
ContentResponse response = client.newRequest("localhost", serverConnector.getLocalPort()) ContentResponse response = client.newRequest("localhost", serverConnector.getLocalPort())
.timeout(5, TimeUnit.SECONDS) .timeout(10, TimeUnit.SECONDS)
.send(); .send();
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());

View File

@ -48,7 +48,6 @@ import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.notNullValue;
import static org.junit.jupiter.api.Assertions.assertThrows; 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.MAC;
import static org.junit.jupiter.api.condition.OS.WINDOWS;
@ExtendWith(WorkDirExtension.class) @ExtendWith(WorkDirExtension.class)
public class PropertyUserStoreTest public class PropertyUserStoreTest
@ -277,7 +276,6 @@ public class PropertyUserStoreTest
} }
@Test @Test
@DisabledOnOs({MAC, WINDOWS}) // File is locked on OS, cannot change.
public void testPropertyUserStoreLoadRemoveUser() throws Exception public void testPropertyUserStoreLoadRemoveUser() throws Exception
{ {
testdir.ensureEmpty(); testdir.ensureEmpty();

View File

@ -19,6 +19,7 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.InvalidPathException;
import java.util.Collection; import java.util.Collection;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
@ -297,6 +298,16 @@ public class ResourceService
// Send the data // Send the data
releaseContent = sendData(request, response, included, content, reqRanges); 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) catch (IllegalArgumentException e)
{ {
LOG.warn("Failed to serve resource: {}", pathInContext, e); LOG.warn("Failed to serve resource: {}", pathInContext, e);

View File

@ -114,7 +114,9 @@ public class FileBufferedResponseHandler extends BufferedResponseHandler
} }
catch (Throwable t) 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; _filePath = null;
} }

View File

@ -149,7 +149,7 @@ public class GracefulStopTest
HttpTester.Response response = HttpTester.parseResponse(client.getInputStream()); HttpTester.Response response = HttpTester.parseResponse(client.getInputStream());
assertThat(response.getStatus(), is(200)); 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()); assertThat(response.get(HttpHeader.CONNECTION), nullValue());
return client; return client;
@ -164,7 +164,7 @@ public class GracefulStopTest
HttpTester.Response response = HttpTester.parseResponse(client.getInputStream()); HttpTester.Response response = HttpTester.parseResponse(client.getInputStream());
assertThat(response.getStatus(), is(200)); 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()); assertThat(response.get(HttpHeader.CONNECTION), nullValue());
} }
@ -224,7 +224,7 @@ public class GracefulStopTest
assertThat(response.get(HttpHeader.CONNECTION), is("close")); assertThat(response.get(HttpHeader.CONNECTION), is("close"));
else else
assertThat(response.get(HttpHeader.CONNECTION), nullValue()); 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 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) catch (Throwable th)
{ {

View File

@ -45,6 +45,8 @@ import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.IO;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test; 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.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.anyOf;
@ -214,6 +216,7 @@ public class ServerConnectorTest
} }
@Test @Test
@DisabledOnOs(value = OS.WINDOWS, disabledReason = "SO_REUSEPORT not available on windows")
public void testReusePort() throws Exception public void testReusePort() throws Exception
{ {
int port; int port;

View File

@ -30,10 +30,8 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -42,11 +40,8 @@ import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.startsWith; import static org.hamcrest.Matchers.startsWith;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.condition.OS.MAC;
@Disabled
@Tag("stress") @Tag("stress")
@DisabledOnOs(MAC) // TODO: needs investigation
public class StressTest public class StressTest
{ {
private static final Logger LOG = LoggerFactory.getLogger(StressTest.class); private static final Logger LOG = LoggerFactory.getLogger(StressTest.class);
@ -129,6 +124,7 @@ public class StressTest
} }
@Test @Test
@Tag("Slow")
public void testNonPersistent() throws Throwable public void testNonPersistent() throws Throwable
{ {
doThreads(20, 20, false); doThreads(20, 20, false);
@ -145,6 +141,7 @@ public class StressTest
} }
@Test @Test
@Tag("Slow")
public void testPersistent() throws Throwable public void testPersistent() throws Throwable
{ {
doThreads(40, 40, true); doThreads(40, 40, true);

View File

@ -45,10 +45,14 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.toolchain.test.FS; import org.eclipse.jetty.toolchain.test.FS;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils; 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.eclipse.jetty.util.Callback;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; 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.Logger;
import org.slf4j.LoggerFactory; 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.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
@ExtendWith(WorkDirExtension.class)
public class FileBufferedResponseHandlerTest public class FileBufferedResponseHandlerTest
{ {
private static final Logger LOG = LoggerFactory.getLogger(FileBufferedResponseHandlerTest.class); private static final Logger LOG = LoggerFactory.getLogger(FileBufferedResponseHandlerTest.class);
public WorkDir _workDir;
private final CountDownLatch _disposeLatch = new CountDownLatch(1); private final CountDownLatch _disposeLatch = new CountDownLatch(1);
private Server _server; private Server _server;
private LocalConnector _localConnector; private LocalConnector _localConnector;
@ -74,8 +81,7 @@ public class FileBufferedResponseHandlerTest
@BeforeEach @BeforeEach
public void before() throws Exception public void before() throws Exception
{ {
_testDir = MavenTestingUtils.getTargetTestingPath(FileBufferedResponseHandlerTest.class.getName()); _testDir = _workDir.getEmptyPathDir();
FS.ensureDirExists(_testDir);
_server = new Server(); _server = new Server();
HttpConfiguration config = new HttpConfiguration(); HttpConfiguration config = new HttpConfiguration();
@ -109,8 +115,6 @@ public class FileBufferedResponseHandlerTest
_bufferedHandler.getPathIncludeExclude().exclude("*.exclude"); _bufferedHandler.getPathIncludeExclude().exclude("*.exclude");
_bufferedHandler.getMimeIncludeExclude().exclude("text/excluded"); _bufferedHandler.getMimeIncludeExclude().exclude("text/excluded");
_server.setHandler(_bufferedHandler); _server.setHandler(_bufferedHandler);
FS.ensureEmpty(_testDir);
} }
@AfterEach @AfterEach
@ -175,9 +179,14 @@ public class FileBufferedResponseHandlerTest
assertThat(responseContent, containsString("Committed: false")); assertThat(responseContent, containsString("Committed: false"));
assertThat(responseContent, containsString("NumFiles: 1")); assertThat(responseContent, containsString("NumFiles: 1"));
// 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)); assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
assertThat(getNumFiles(), is(0)); assertThat(getNumFiles(), is(0));
} }
}
@Test @Test
public void testExcludedByPath() throws Exception public void testExcludedByPath() throws Exception
@ -269,9 +278,14 @@ public class FileBufferedResponseHandlerTest
assertThat(responseContent, containsString("Committed: false")); assertThat(responseContent, containsString("Committed: false"));
assertThat(responseContent, containsString("NumFiles: 1")); assertThat(responseContent, containsString("NumFiles: 1"));
// 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)); assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
assertThat(getNumFiles(), is(0)); assertThat(getNumFiles(), is(0));
} }
}
@Test @Test
public void testClosed() throws Exception public void testClosed() throws Exception
@ -301,9 +315,14 @@ public class FileBufferedResponseHandlerTest
assertThat(responseContent, not(containsString("writtenAfterClose"))); assertThat(responseContent, not(containsString("writtenAfterClose")));
assertThat(responseContent, containsString("NumFiles: 1")); assertThat(responseContent, containsString("NumFiles: 1"));
// 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)); assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
assertThat(getNumFiles(), is(0)); assertThat(getNumFiles(), is(0));
} }
}
@Test @Test
public void testBufferSizeBig() throws Exception public void testBufferSizeBig() throws Exception
@ -363,9 +382,14 @@ public class FileBufferedResponseHandlerTest
assertThat(response.getStatus(), is(HttpStatus.OK_200)); assertThat(response.getStatus(), is(HttpStatus.OK_200));
assertThat(responseContent, containsString("NumFiles: 0")); assertThat(responseContent, containsString("NumFiles: 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)); assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
assertThat(getNumFiles(), is(0)); assertThat(getNumFiles(), is(0));
} }
}
@Test @Test
public void testReset() throws Exception public void testReset() throws Exception
@ -400,13 +424,19 @@ public class FileBufferedResponseHandlerTest
// Resetting the response buffer will delete the file. // Resetting the response buffer will delete the file.
assertThat(response.getStatus(), is(HttpStatus.OK_200)); assertThat(response.getStatus(), is(HttpStatus.OK_200));
assertThat(responseContent, not(containsString("THIS WILL BE RESET"))); assertThat(responseContent, not(containsString("THIS WILL BE RESET")));
assertThat(responseContent, containsString("NumFilesBeforeReset: 1")); assertThat(responseContent, containsString("NumFilesBeforeReset: 1"));
assertThat(responseContent, containsString("NumFilesAfterReset: 0")); assertThat(responseContent, containsString("NumFilesAfterReset: 0"));
assertThat(responseContent, containsString("NumFilesAfterWrite: 1")); assertThat(responseContent, containsString("NumFilesAfterWrite: 1"));
// 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)); assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
assertThat(getNumFiles(), is(0)); assertThat(getNumFiles(), is(0));
} }
}
@Test @Test
public void testFileLargerThanMaxInteger() throws Exception public void testFileLargerThanMaxInteger() throws Exception
@ -479,9 +509,14 @@ public class FileBufferedResponseHandlerTest
assertThat(response.get("FileSize"), is(Long.toString(fileSize))); assertThat(response.get("FileSize"), is(Long.toString(fileSize)));
assertThat(received.get(), is(fileSize)); assertThat(received.get(), is(fileSize));
// 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)); assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
assertThat(getNumFiles(), is(0)); assertThat(getNumFiles(), is(0));
} }
}
@Test @Test
public void testNextInterceptorFailed() throws Exception public void testNextInterceptorFailed() throws Exception
@ -553,10 +588,15 @@ public class FileBufferedResponseHandlerTest
Throwable error = errorFuture.get(5, TimeUnit.SECONDS); Throwable error = errorFuture.get(5, TimeUnit.SECONDS);
assertThat(error.getMessage(), containsString("intentionally throwing from interceptor")); assertThat(error.getMessage(), containsString("intentionally throwing from interceptor"));
// 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. // All files were deleted.
assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS)); assertTrue(_disposeLatch.await(5, TimeUnit.SECONDS));
assertThat(getNumFiles(), is(0)); assertThat(getNumFiles(), is(0));
} }
}
@Test @Test
public void testFileWriteFailed() throws Exception public void testFileWriteFailed() throws Exception

View File

@ -17,7 +17,6 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.Socket; import java.net.Socket;
import java.net.SocketException;
import java.net.URI; import java.net.URI;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.security.KeyStore; import java.security.KeyStore;
@ -26,7 +25,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.TrustManagerFactory;
import javax.servlet.ServletException; import javax.servlet.ServletException;
@ -49,7 +47,6 @@ import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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.is;
import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.not;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.condition.OS.WINDOWS;
/** /**
* HttpServer Tester for SSL based ServerConnector * HttpServer Tester for SSL based ServerConnector
@ -124,43 +120,6 @@ public class ServerConnectorSslServerTest extends HttpServerTestBase
return socket; 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 @Override
public void testFullHeader() throws Exception public void testFullHeader() throws Exception
{ {

View File

@ -235,8 +235,8 @@ public class SniSslConnectionFactoryTest
assertThat(response, Matchers.containsString("Invalid SNI")); assertThat(response, Matchers.containsString("Invalid SNI"));
} }
@DisabledOnOs(value = OS.WINDOWS, disabledReason = "See Issue #6609 - TLSv1.3 behavior differences between Linux and Windows")
@Test @Test
@DisabledOnOs(OS.WINDOWS)
public void testWrongSNIRejectedConnection() throws Exception public void testWrongSNIRejectedConnection() throws Exception
{ {
start(ssl -> start(ssl ->
@ -275,8 +275,8 @@ public class SniSslConnectionFactoryTest
assertThat(response.getStatus(), is(400)); assertThat(response.getStatus(), is(400));
} }
@DisabledOnOs(value = OS.WINDOWS, disabledReason = "See Issue #6609 - TLSv1.3 behavior differences between Linux and Windows")
@Test @Test
@DisabledOnOs(OS.WINDOWS)
public void testWrongSNIRejectedFunction() throws Exception public void testWrongSNIRejectedFunction() throws Exception
{ {
start((ssl, customizer) -> start((ssl, customizer) ->
@ -302,8 +302,8 @@ public class SniSslConnectionFactoryTest
assertThat(response.getStatus(), is(400)); assertThat(response.getStatus(), is(400));
} }
@DisabledOnOs(value = OS.WINDOWS, disabledReason = "See Issue #6609 - TLSv1.3 behavior differences between Linux and Windows")
@Test @Test
@DisabledOnOs(OS.WINDOWS)
public void testWrongSNIRejectedConnectionWithNonSNIKeystore() throws Exception public void testWrongSNIRejectedConnectionWithNonSNIKeystore() throws Exception
{ {
start(ssl -> start(ssl ->

View File

@ -37,6 +37,7 @@ import org.eclipse.jetty.util.URIUtil;
* will be handled by any servlets mapped to that URL. * will be handled by any servlets mapped to that URL.
* *
* Requests to "/some/directory" will be redirected to "/some/directory/". * Requests to "/some/directory" will be redirected to "/some/directory/".
* @deprecated no replacement is offered, use standard Servlet web.xml welcome features
*/ */
@Deprecated @Deprecated
public class WelcomeFilter implements Filter public class WelcomeFilter implements Filter

View File

@ -45,6 +45,7 @@ import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is; 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.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue; 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); String responses = doRequests(request1 + request2 + request1 + request2 + request1, 2, 1100, 1100, last);
assertEquals(11, count(responses, "HTTP/1.1 200 OK")); 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 // alternate between sessions
responses = doRequests(request1 + request2 + request1 + request2 + request1, 2, 250, 250, last); responses = doRequests(request1 + request2 + request1 + request2 + request1, 2, 250, 250, last);

View File

@ -25,6 +25,7 @@ import org.eclipse.jetty.http.UriCompliance;
import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.LocalConnector; import org.eclipse.jetty.server.LocalConnector;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.FilterHolder; import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
@ -80,6 +81,8 @@ public class WelcomeFilterTest
} }
WebAppContext context = new WebAppContext(server, directoryPath.toString(), "/"); 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); server.setHandler(context);
String concatPath = "/*"; String concatPath = "/*";

View File

@ -24,10 +24,8 @@ public class JettyLoggingServiceProvider implements SLF4JServiceProvider
{ {
/** /**
* Declare the version of the SLF4J API this implementation is compiled against. * 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 private static final String REQUESTED_API_VERSION = "2.0";
public static String REQUESTED_API_VERSION = "1.8.99"; // !final
private JettyLoggerFactory loggerFactory; private JettyLoggerFactory loggerFactory;
private BasicMarkerFactory markerFactory; private BasicMarkerFactory markerFactory;

View File

@ -22,12 +22,12 @@ EXISTS|maindir/
EXISTS|start.ini EXISTS|start.ini
# Output Assertions [regex!] (order is irrelevant) # Output Assertions [regex!] (order is irrelevant)
OUTPUT|INFO : mkdir ..jetty.base./start.d OUTPUT|INFO : mkdir ..jetty.base.[/\\]start.d
OUTPUT|INFO : extra initialized in \$\{jetty.base\}/start.d/extra.ini 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 : 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 : base transitively enabled
OUTPUT|INFO : mkdir ..jetty.base./maindir OUTPUT|INFO : mkdir ..jetty.base.[/\\]maindir
OUTPUT|INFO : Base directory was modified OUTPUT|INFO : Base directory was modified

View File

@ -22,12 +22,12 @@ EXISTS|maindir/
EXISTS|start.ini EXISTS|start.ini
# Output Assertions [regex!] (order is irrelevant) # Output Assertions [regex!] (order is irrelevant)
OUTPUT|INFO : create ..jetty.base./start.ini OUTPUT|INFO : create ..jetty.base.[/\\]start.ini
OUTPUT|INFO : extra initialized in ..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 : 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 : base transitively enabled
OUTPUT|INFO : mkdir ..jetty.base./maindir OUTPUT|INFO : mkdir ..jetty.base.[/\\]maindir
OUTPUT|INFO : Base directory was modified OUTPUT|INFO : Base directory was modified

View File

@ -14,4 +14,4 @@ PROP|main.prop=value0
EXISTS|maindir/ EXISTS|maindir/
EXISTS|start.d/main.ini 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\]

View File

@ -17,7 +17,7 @@ PROP|optional.prop=value0
EXISTS|maindir/ EXISTS|maindir/
EXISTS|start.ini EXISTS|start.ini
OUTPUT|INFO : copy ..jetty.base./start.d/main.ini into ..jetty.base./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 : optional initialized in ..jetty.base.[/\\]start.ini
OUTPUT|INFO : mkdir ..jetty.base./maindir OUTPUT|INFO : mkdir ..jetty.base.[/\\]maindir
OUTPUT|INFO : Base directory was modified OUTPUT|INFO : Base directory was modified

View File

@ -362,7 +362,7 @@ public class PathWatcherTest
capture.finishedLatch.await(LONG_TIME, TimeUnit.MILLISECONDS); capture.finishedLatch.await(LONG_TIME, TimeUnit.MILLISECONDS);
long end = System.nanoTime(); long end = System.nanoTime();
capture.assertEvents(expected); 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); Thread.sleep(WAIT_TIME);
capture.assertEvents(expected); capture.assertEvents(expected);

View File

@ -17,6 +17,7 @@ import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.PathMatcher; import java.nio.file.PathMatcher;
import java.util.ArrayList; import java.util.ArrayList;
@ -28,40 +29,38 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.toolchain.test.FS; 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.Scanner.Notification;
import org.eclipse.jetty.util.component.LifeCycle;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test; 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.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.condition.OS.WINDOWS;
@ExtendWith(WorkDirExtension.class)
public class ScannerTest public class ScannerTest
{ {
static File _directory; public WorkDir workDir;
static Scanner _scanner; private Path _directory;
static BlockingQueue<Event> _queue = new LinkedBlockingQueue<>(); private Scanner _scanner;
static BlockingQueue<Set<String>> _bulk = new LinkedBlockingQueue<>(); private BlockingQueue<Event> _queue = new LinkedBlockingQueue<>();
private BlockingQueue<Set<String>> _bulk = new LinkedBlockingQueue<>();
@BeforeAll @BeforeEach
public static void setUpBeforeClass() throws Exception public void setupScanner() throws Exception
{ {
File testDir = MavenTestingUtils.getTargetTestingDir(ScannerTest.class.getSimpleName()); _directory = workDir.getEmptyPathDir();
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();
_scanner = new Scanner(); _scanner = new Scanner();
_scanner.addDirectory(_directory.toPath()); _scanner.addDirectory(_directory);
_scanner.setScanInterval(0); _scanner.setScanInterval(0);
_scanner.setReportDirs(false); _scanner.setReportDirs(false);
_scanner.setReportExistingFilesOnStartup(false); _scanner.setReportExistingFilesOnStartup(false);
@ -94,11 +93,10 @@ public class ScannerTest
assertTrue(_bulk.isEmpty()); assertTrue(_bulk.isEmpty());
} }
@AfterAll @AfterEach
public static void tearDownAfterClass() throws Exception public void cleanup() throws Exception
{ {
_scanner.stop(); LifeCycle.stop(_scanner);
IO.delete(_directory);
} }
static class Event static class Event
@ -139,7 +137,7 @@ public class ScannerTest
@Test @Test
public void testDepth() throws Exception public void testDepth() throws Exception
{ {
File root = new File(_directory, "root"); File root = new File(_directory.toFile(), "root");
FS.ensureDirExists(root); FS.ensureDirExists(root);
FS.touch(new File(root, "foo.foo")); FS.touch(new File(root, "foo.foo"));
FS.touch(new File(root, "foo2.foo")); FS.touch(new File(root, "foo2.foo"));
@ -215,7 +213,7 @@ public class ScannerTest
public void testPatterns() throws Exception public void testPatterns() throws Exception
{ {
//test include and exclude patterns //test include and exclude patterns
File root = new File(_directory, "proot"); File root = new File(_directory.toFile(), "proot");
FS.ensureDirExists(root); FS.ensureDirExists(root);
File ttt = new File(root, "ttt.txt"); File ttt = new File(root, "ttt.txt");
@ -288,7 +286,7 @@ public class ScannerTest
} }
@Test @Test
@DisabledOnOs(WINDOWS) // TODO: needs review @Tag("Slow")
public void testAddedChangeRemove() throws Exception public void testAddedChangeRemove() throws Exception
{ {
touch("a0"); touch("a0");
@ -299,7 +297,7 @@ public class ScannerTest
Event event = _queue.poll(5, TimeUnit.SECONDS); Event event = _queue.poll(5, TimeUnit.SECONDS);
assertNotNull(event, "Event should not be null"); assertNotNull(event, "Event should not be null");
assertEquals(_directory + "/a0", event._filename); assertEquals(_directory.resolve("a0").toString(), event._filename);
assertEquals(Notification.ADDED, event._notification); assertEquals(Notification.ADDED, event._notification);
// add 3 more files // add 3 more files
@ -323,8 +321,8 @@ public class ScannerTest
List<Event> actualEvents = new ArrayList<>(); List<Event> actualEvents = new ArrayList<>();
_queue.drainTo(actualEvents); _queue.drainTo(actualEvents);
assertEquals(2, actualEvents.size()); assertEquals(2, actualEvents.size());
Event a1 = new Event(_directory + "/a1", Notification.ADDED); Event a1 = new Event(_directory.resolve("a1").toString(), Notification.ADDED);
Event a3 = new Event(_directory + "/a3", Notification.REMOVED); Event a3 = new Event(_directory.resolve("a3").toString(), Notification.REMOVED);
assertThat(actualEvents, Matchers.containsInAnyOrder(a1, a3)); assertThat(actualEvents, Matchers.containsInAnyOrder(a1, a3));
assertTrue(_queue.isEmpty()); assertTrue(_queue.isEmpty());
@ -332,7 +330,7 @@ public class ScannerTest
_scanner.scan(); _scanner.scan();
event = _queue.poll(); event = _queue.poll();
assertNotNull(event); assertNotNull(event);
assertEquals(_directory + "/a2", event._filename); assertEquals(_directory.resolve("a2").toString(), event._filename);
assertEquals(Notification.ADDED, event._notification); assertEquals(Notification.ADDED, event._notification);
assertTrue(_queue.isEmpty()); assertTrue(_queue.isEmpty());
@ -353,7 +351,7 @@ public class ScannerTest
_scanner.scan(); _scanner.scan();
event = _queue.poll(); event = _queue.poll();
assertNotNull(event); assertNotNull(event);
assertEquals(_directory + "/a1", event._filename); assertEquals(_directory.resolve("a1").toString(), event._filename);
assertEquals(Notification.CHANGED, event._notification); assertEquals(Notification.CHANGED, event._notification);
assertTrue(_queue.isEmpty()); assertTrue(_queue.isEmpty());
@ -361,7 +359,7 @@ public class ScannerTest
_scanner.scan(); _scanner.scan();
event = _queue.poll(); event = _queue.poll();
assertNotNull(event); assertNotNull(event);
assertEquals(_directory + "/a2", event._filename); assertEquals(_directory.resolve("a2").toString(), event._filename);
assertEquals(Notification.CHANGED, event._notification); assertEquals(Notification.CHANGED, event._notification);
assertTrue(_queue.isEmpty()); assertTrue(_queue.isEmpty());
@ -371,8 +369,8 @@ public class ScannerTest
//Immediate notification of deletes. //Immediate notification of deletes.
_scanner.scan(); _scanner.scan();
a1 = new Event(_directory + "/a1", Notification.REMOVED); a1 = new Event(_directory.resolve("a1").toString(), Notification.REMOVED);
Event a2 = new Event(_directory + "/a2", Notification.REMOVED); Event a2 = new Event(_directory.resolve("a2").toString(), Notification.REMOVED);
actualEvents = new ArrayList<>(); actualEvents = new ArrayList<>();
_queue.drainTo(actualEvents); _queue.drainTo(actualEvents);
assertEquals(2, actualEvents.size()); assertEquals(2, actualEvents.size());
@ -392,13 +390,12 @@ public class ScannerTest
_scanner.scan(); _scanner.scan();
event = _queue.poll(); event = _queue.poll();
assertNotNull(event); assertNotNull(event);
assertEquals(_directory + "/a2", event._filename); assertEquals(_directory.resolve("a2").toString(), event._filename);
assertEquals(Notification.ADDED, event._notification); assertEquals(Notification.ADDED, event._notification);
assertTrue(_queue.isEmpty()); assertTrue(_queue.isEmpty());
} }
@Test @Test
@DisabledOnOs(WINDOWS) // TODO: needs review
public void testSizeChange() throws Exception public void testSizeChange() throws Exception
{ {
touch("tsc0"); touch("tsc0");
@ -408,12 +405,12 @@ public class ScannerTest
// takes 2 scans to notice tsc0 and check that it is stable. // takes 2 scans to notice tsc0 and check that it is stable.
Event event = _queue.poll(); Event event = _queue.poll();
assertNotNull(event); assertNotNull(event);
assertEquals(_directory + "/tsc0", event._filename); assertEquals(_directory.resolve("tsc0").toString(), event._filename);
assertEquals(Notification.ADDED, event._notification); assertEquals(Notification.ADDED, event._notification);
// Create a new file by writing to it. // Create a new file by writing to it.
long now = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); 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)) try (OutputStream out = new FileOutputStream(file, true))
{ {
out.write('x'); out.write('x');
@ -439,7 +436,7 @@ public class ScannerTest
_scanner.scan(); _scanner.scan();
event = _queue.poll(); event = _queue.poll();
assertNotNull(event); assertNotNull(event);
assertEquals(_directory + "/st", event._filename); assertEquals(_directory.resolve("st").toString(), event._filename);
assertEquals(Notification.ADDED, event._notification); assertEquals(Notification.ADDED, event._notification);
// Modify size only // Modify size only
@ -456,21 +453,20 @@ public class ScannerTest
_scanner.scan(); _scanner.scan();
event = _queue.poll(); event = _queue.poll();
assertNotNull(event); assertNotNull(event);
assertEquals(_directory + "/st", event._filename); assertEquals(_directory.resolve("st").toString(), event._filename);
assertEquals(Notification.CHANGED, event._notification); assertEquals(Notification.CHANGED, event._notification);
} }
} }
private void delete(String string) private void delete(String string) throws IOException
{ {
File file = new File(_directory, string); Path file = _directory.resolve(string);
if (file.exists()) Files.deleteIfExists(file);
IO.delete(file);
} }
private void touch(String string) throws IOException private void touch(String string) throws IOException
{ {
File file = new File(_directory, string); File file = new File(_directory.toFile(), string);
if (file.exists()) if (file.exists())
file.setLastModified(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())); file.setLastModified(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()));
else else

View File

@ -46,7 +46,6 @@ import org.eclipse.jetty.util.BufferUtil;
import org.hamcrest.BaseMatcher; import org.hamcrest.BaseMatcher;
import org.hamcrest.Description; import org.hamcrest.Description;
import org.hamcrest.Matcher; import org.hamcrest.Matcher;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.EnabledOnOs; import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@ -641,7 +640,6 @@ public class FileSystemResourceTest
@ParameterizedTest @ParameterizedTest
@MethodSource("fsResourceProvider") @MethodSource("fsResourceProvider")
@DisabledOnOs(WINDOWS)
public void testSymlink(Class<PathResource> resourceClass) throws Exception public void testSymlink(Class<PathResource> resourceClass) throws Exception
{ {
Path dir = workDir.getEmptyPathDir(); Path dir = workDir.getEmptyPathDir();
@ -649,18 +647,20 @@ public class FileSystemResourceTest
Path foo = dir.resolve("foo"); Path foo = dir.resolve("foo");
Path bar = dir.resolve("bar"); Path bar = dir.resolve("bar");
boolean symlinkSupported;
try try
{ {
Files.createFile(foo); Files.createFile(foo);
Files.createSymbolicLink(bar, foo); Files.createSymbolicLink(bar, foo);
symlinkSupported = true;
} }
catch (UnsupportedOperationException | FileSystemException e) catch (UnsupportedOperationException | FileSystemException e)
{ {
// if unable to create symlink, no point testing the rest symlinkSupported = false;
// this is the path that Microsoft Windows takes.
assumeTrue(true, "Not supported");
} }
assumeTrue(symlinkSupported, "Symlink not supported");
try (Resource base = newResource(resourceClass, dir.toFile())) try (Resource base = newResource(resourceClass, dir.toFile()))
{ {
Resource resFoo = base.addPath("foo"); Resource resFoo = base.addPath("foo");
@ -683,7 +683,6 @@ public class FileSystemResourceTest
@ParameterizedTest @ParameterizedTest
@ValueSource(classes = PathResource.class) // FileResource does not support this @ValueSource(classes = PathResource.class) // FileResource does not support this
@DisabledOnOs(WINDOWS)
public void testNonExistantSymlink(Class<PathResource> resourceClass) throws Exception public void testNonExistantSymlink(Class<PathResource> resourceClass) throws Exception
{ {
Path dir = workDir.getEmptyPathDir(); Path dir = workDir.getEmptyPathDir();
@ -692,17 +691,19 @@ public class FileSystemResourceTest
Path foo = dir.resolve("foo"); Path foo = dir.resolve("foo");
Path bar = dir.resolve("bar"); Path bar = dir.resolve("bar");
boolean symlinkSupported;
try try
{ {
Files.createSymbolicLink(bar, foo); Files.createSymbolicLink(bar, foo);
symlinkSupported = true;
} }
catch (UnsupportedOperationException | FileSystemException e) catch (UnsupportedOperationException | FileSystemException e)
{ {
// if unable to create symlink, no point testing the rest symlinkSupported = false;
// this is the path that Microsoft Windows takes.
assumeTrue(true, "Not supported");
} }
assumeTrue(symlinkSupported, "Symlink not supported");
try (Resource base = newResource(resourceClass, dir.toFile())) try (Resource base = newResource(resourceClass, dir.toFile()))
{ {
Resource resFoo = base.addPath("foo"); Resource resFoo = base.addPath("foo");
@ -835,8 +836,7 @@ public class FileSystemResourceTest
} }
catch (InvalidPathException e) catch (InvalidPathException e)
{ {
// NTFS filesystem streams are unsupported on some platforms. assumeTrue(false, "NTFS simple streams not supported");
assumeTrue(true, "Not supported");
} }
} }
} }
@ -883,8 +883,7 @@ public class FileSystemResourceTest
} }
catch (InvalidPathException e) catch (InvalidPathException e)
{ {
// NTFS filesystem streams are unsupported on some platforms. assumeTrue(false, "NTFS $DATA streams not supported");
assumeTrue(true, "Not supported");
} }
} }
} }
@ -929,15 +928,13 @@ public class FileSystemResourceTest
} }
catch (InvalidPathException e) catch (InvalidPathException e)
{ {
// NTFS filesystem streams are unsupported on some platforms. assumeTrue(false, "NTFS $DATA streams not supported");
assumeTrue(true, "Not supported on this OS");
} }
} }
} }
@ParameterizedTest @ParameterizedTest
@MethodSource("fsResourceProvider") @MethodSource("fsResourceProvider")
@DisabledOnOs(WINDOWS)
public void testSemicolon(Class<PathResource> resourceClass) throws Exception public void testSemicolon(Class<PathResource> resourceClass) throws Exception
{ {
Path dir = workDir.getEmptyPathDir(); Path dir = workDir.getEmptyPathDir();
@ -948,11 +945,9 @@ public class FileSystemResourceTest
Path foo = dir.resolve("foo;"); Path foo = dir.resolve("foo;");
Files.createFile(foo); Files.createFile(foo);
} }
catch (Exception e) catch (InvalidPathException e)
{ {
// if unable to create file, no point testing the rest. assumeTrue(false, "Unable to create file with semicolon");
// this is the path that Microsoft Windows takes.
assumeTrue(true, "Not supported on this OS");
} }
try (Resource base = newResource(resourceClass, dir.toFile())) try (Resource base = newResource(resourceClass, dir.toFile()))
@ -964,7 +959,6 @@ public class FileSystemResourceTest
@ParameterizedTest @ParameterizedTest
@MethodSource("fsResourceProvider") @MethodSource("fsResourceProvider")
@DisabledOnOs(WINDOWS)
public void testSingleQuote(Class<PathResource> resourceClass) throws Exception public void testSingleQuote(Class<PathResource> resourceClass) throws Exception
{ {
Path dir = workDir.getEmptyPathDir(); Path dir = workDir.getEmptyPathDir();
@ -976,11 +970,9 @@ public class FileSystemResourceTest
Path foo = dir.resolve("foo' bar"); Path foo = dir.resolve("foo' bar");
Files.createFile(foo); Files.createFile(foo);
} }
catch (Exception e) catch (InvalidPathException e)
{ {
// if unable to create file, no point testing the rest. assumeTrue(false, "Unable to create file with single quote");
// this is the path that Microsoft Windows takes.
assumeTrue(true, "Not supported on this OS");
} }
try (Resource base = newResource(resourceClass, dir.toFile())) try (Resource base = newResource(resourceClass, dir.toFile()))
@ -992,7 +984,6 @@ public class FileSystemResourceTest
@ParameterizedTest @ParameterizedTest
@MethodSource("fsResourceProvider") @MethodSource("fsResourceProvider")
@DisabledOnOs(WINDOWS)
public void testSingleBackTick(Class<PathResource> resourceClass) throws Exception public void testSingleBackTick(Class<PathResource> resourceClass) throws Exception
{ {
Path dir = workDir.getEmptyPathDir(); Path dir = workDir.getEmptyPathDir();
@ -1004,11 +995,9 @@ public class FileSystemResourceTest
Path foo = dir.resolve("foo` bar"); Path foo = dir.resolve("foo` bar");
Files.createFile(foo); Files.createFile(foo);
} }
catch (Exception e) catch (InvalidPathException e)
{ {
// if unable to create file, no point testing the rest. assumeTrue(false, "Unable to create file with single back tick");
// this is the path that Microsoft Windows takes.
assumeTrue(true, "Not supported on this OS");
} }
try (Resource base = newResource(resourceClass, dir.toFile())) try (Resource base = newResource(resourceClass, dir.toFile()))
@ -1020,7 +1009,6 @@ public class FileSystemResourceTest
@ParameterizedTest @ParameterizedTest
@MethodSource("fsResourceProvider") @MethodSource("fsResourceProvider")
@DisabledOnOs(WINDOWS)
public void testBrackets(Class<PathResource> resourceClass) throws Exception public void testBrackets(Class<PathResource> resourceClass) throws Exception
{ {
Path dir = workDir.getEmptyPathDir(); Path dir = workDir.getEmptyPathDir();
@ -1032,11 +1020,9 @@ public class FileSystemResourceTest
Path foo = dir.resolve("foo[1]"); Path foo = dir.resolve("foo[1]");
Files.createFile(foo); Files.createFile(foo);
} }
catch (Exception e) catch (InvalidPathException e)
{ {
// if unable to create file, no point testing the rest. assumeTrue(false, "Unable to create file with square brackets");
// this is the path that Microsoft Windows takes.
assumeTrue(true, "Not supported on this OS");
} }
try (Resource base = newResource(resourceClass, dir.toFile())) try (Resource base = newResource(resourceClass, dir.toFile()))
@ -1048,7 +1034,6 @@ public class FileSystemResourceTest
@ParameterizedTest @ParameterizedTest
@ValueSource(classes = PathResource.class) // FileResource does not support this @ValueSource(classes = PathResource.class) // FileResource does not support this
@DisabledOnOs(WINDOWS)
public void testBraces(Class<PathResource> resourceClass) throws Exception public void testBraces(Class<PathResource> resourceClass) throws Exception
{ {
Path dir = workDir.getEmptyPathDir(); Path dir = workDir.getEmptyPathDir();
@ -1060,11 +1045,9 @@ public class FileSystemResourceTest
Path foo = dir.resolve("foo.{bar}.txt"); Path foo = dir.resolve("foo.{bar}.txt");
Files.createFile(foo); Files.createFile(foo);
} }
catch (Exception e) catch (InvalidPathException e)
{ {
// if unable to create file, no point testing the rest. assumeTrue(false, "Unable to create file with squiggle braces");
// this is the path that Microsoft Windows takes.
assumeTrue(true, "Not supported on this OS");
} }
try (Resource base = newResource(resourceClass, dir.toFile())) try (Resource base = newResource(resourceClass, dir.toFile()))
@ -1076,7 +1059,6 @@ public class FileSystemResourceTest
@ParameterizedTest @ParameterizedTest
@ValueSource(classes = PathResource.class) // FileResource does not support this @ValueSource(classes = PathResource.class) // FileResource does not support this
@DisabledOnOs(WINDOWS)
public void testCaret(Class<PathResource> resourceClass) throws Exception public void testCaret(Class<PathResource> resourceClass) throws Exception
{ {
Path dir = workDir.getEmptyPathDir(); Path dir = workDir.getEmptyPathDir();
@ -1088,11 +1070,9 @@ public class FileSystemResourceTest
Path foo = dir.resolve("foo^3.txt"); Path foo = dir.resolve("foo^3.txt");
Files.createFile(foo); Files.createFile(foo);
} }
catch (Exception e) catch (InvalidPathException e)
{ {
// if unable to create file, no point testing the rest. assumeTrue(false, "Unable to create file with caret");
// this is the path that Microsoft Windows takes.
assumeTrue(true, "Not supported on this OS");
} }
try (Resource base = newResource(resourceClass, dir.toFile())) try (Resource base = newResource(resourceClass, dir.toFile()))
@ -1104,7 +1084,6 @@ public class FileSystemResourceTest
@ParameterizedTest @ParameterizedTest
@ValueSource(classes = PathResource.class) // FileResource does not support this @ValueSource(classes = PathResource.class) // FileResource does not support this
@DisabledOnOs(WINDOWS)
public void testPipe(Class<PathResource> resourceClass) throws Exception public void testPipe(Class<PathResource> resourceClass) throws Exception
{ {
Path dir = workDir.getEmptyPathDir(); Path dir = workDir.getEmptyPathDir();
@ -1116,11 +1095,9 @@ public class FileSystemResourceTest
Path foo = dir.resolve("foo|bar.txt"); Path foo = dir.resolve("foo|bar.txt");
Files.createFile(foo); Files.createFile(foo);
} }
catch (Exception e) catch (InvalidPathException e)
{ {
// if unable to create file, no point testing the rest. assumeTrue(false, "Unable to create file with pipe symbol");
// this is the path that Microsoft Windows takes.
assumeTrue(true, "Not supported on this OS");
} }
try (Resource base = newResource(resourceClass, dir.toFile())) try (Resource base = newResource(resourceClass, dir.toFile()))
@ -1477,10 +1454,7 @@ public class FileSystemResourceTest
} }
catch (InvalidPathException e) catch (InvalidPathException e)
{ {
// if unable to create file, no point testing the rest. assumeTrue(false, "Unable to create directory with utf-8 character");
// 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");
return; return;
} }

View File

@ -19,6 +19,7 @@ import java.io.InputStream;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;
import java.nio.file.InvalidPathException;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -29,7 +30,6 @@ import org.eclipse.jetty.util.IO;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test; 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.EnabledOnOs;
import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.params.ParameterizedTest; 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.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
public class ResourceTest public class ResourceTest
{ {
@ -287,16 +288,24 @@ public class ResourceTest
} }
@Test @Test
@DisabledOnOs(OS.WINDOWS) // this uses forbidden characters on some Windows Environments
public void testGlobPath() throws IOException public void testGlobPath() throws IOException
{ {
Path testDir = MavenTestingUtils.getTargetTestingPath("testGlobPath"); Path testDir = MavenTestingUtils.getTargetTestingPath("testGlobPath");
FS.ensureEmpty(testDir); FS.ensureEmpty(testDir);
String globReference = testDir.toAbsolutePath().toString() + File.separator + '*'; try
{
String globReference = testDir.toAbsolutePath() + File.separator + '*';
Resource globResource = Resource.newResource(globReference); Resource globResource = Resource.newResource(globReference);
assertNotNull(globResource, "Should have produced a Resource"); 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 @Test
@EnabledOnOs(OS.WINDOWS) @EnabledOnOs(OS.WINDOWS)

View File

@ -123,9 +123,22 @@ public class HugeResourceTest
@AfterAll @AfterAll
public static void cleanupTestFiles() public static void cleanupTestFiles()
{ {
FS.ensureDeleted(staticBase); quietlyDelete(staticBase);
FS.ensureDeleted(outputDir); quietlyDelete(outputDir);
FS.ensureDeleted(multipartTempDir); 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 private static void makeStaticFile(Path staticFile, long size) throws IOException

View File

@ -25,9 +25,10 @@ import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.IO;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIfSystemProperty; 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.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource; import org.junit.jupiter.params.provider.ValueSource;
@ -295,6 +296,7 @@ public class TempDirTest
* so we _will_ have permission to write to this directory. * so we _will_ have permission to write to this directory.
*/ */
@DisabledIfSystemProperty(named = "env", matches = "ci") @DisabledIfSystemProperty(named = "env", matches = "ci")
@DisabledOnOs(value = OS.WINDOWS, disabledReason = "Test/Temp directory is always writable")
@Test @Test
public void attributeWithInvalidPermissions() public void attributeWithInvalidPermissions()
{ {

View File

@ -23,10 +23,11 @@ import org.eclipse.jetty.http.UriCompliance;
import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.LocalConnector; import org.eclipse.jetty.server.LocalConnector;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
import org.eclipse.jetty.util.IO; import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource; 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.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
@ExtendWith(WorkDirExtension.class)
public class WebAppDefaultServletTest public class WebAppDefaultServletTest
{ {
public WorkDir workDir;
private Server server; private Server server;
private LocalConnector connector; private LocalConnector connector;
@ -48,9 +51,7 @@ public class WebAppDefaultServletTest
connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setUriCompliance(UriCompliance.RFC3986); connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setUriCompliance(UriCompliance.RFC3986);
server.addConnector(connector); server.addConnector(connector);
Path directoryPath = MavenTestingUtils.getTargetTestingDir().toPath(); Path directoryPath = workDir.getEmptyPathDir();
IO.delete(directoryPath.toFile());
Files.createDirectories(directoryPath);
Path welcomeResource = directoryPath.resolve("index.html"); Path welcomeResource = directoryPath.resolve("index.html");
try (OutputStream output = Files.newOutputStream(welcomeResource)) try (OutputStream output = Files.newOutputStream(welcomeResource))
{ {

View File

@ -63,6 +63,8 @@ import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerI
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; 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.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsStringIgnoringCase; import static org.hamcrest.Matchers.containsStringIgnoringCase;
@ -234,6 +236,7 @@ public class WebSocketOverHTTP2Test
} }
@Test @Test
@DisabledOnOs(value = OS.WINDOWS, disabledReason = "Issue #6660 - Windows does not throw ConnectException")
public void testWebSocketConnectPortDoesNotExist() throws Exception public void testWebSocketConnectPortDoesNotExist() throws Exception
{ {
startServer(); startServer();

View File

@ -79,7 +79,8 @@
<settingsPath>src/it/settings.xml</settingsPath> <settingsPath>src/it/settings.xml</settingsPath>
<invoker.mergeUserSettings>false</invoker.mergeUserSettings> <invoker.mergeUserSettings>false</invoker.mergeUserSettings>
<surefire.rerunFailingTestsCount>0</surefire.rerunFailingTestsCount> <surefire.rerunFailingTestsCount>0</surefire.rerunFailingTestsCount>
<testcontainers.version>1.15.1</testcontainers.version> <testcontainers.version>1.16.0</testcontainers.version>
<jna.version>5.8.0</jna.version>
<mariadb.version>2.7.0</mariadb.version> <mariadb.version>2.7.0</mariadb.version>
</properties> </properties>
@ -1151,7 +1152,7 @@
<dependency> <dependency>
<groupId>net.java.dev.jna</groupId> <groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId> <artifactId>jna</artifactId>
<version>5.6.0</version> <version>${jna.version}</version>
</dependency> </dependency>
<!-- Old Deps --> <!-- Old Deps -->
<dependency> <dependency>

View File

@ -191,6 +191,11 @@
<artifactId>gcloud</artifactId> <artifactId>gcloud</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.mariadb.jdbc</groupId> <groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId> <artifactId>mariadb-java-client</artifactId>

View File

@ -275,7 +275,7 @@ public class DistributionTests extends AbstractJettyHomeTest
} }
@Test @Test
@DisabledOnOs(OS.WINDOWS) // jnr not supported on windows @DisabledOnOs(value = OS.WINDOWS, disabledReason = "jnr not supported on windows")
public void testUnixSocket() throws Exception public void testUnixSocket() throws Exception
{ {
String dir = System.getProperty("jetty.unixdomain.dir"); String dir = System.getProperty("jetty.unixdomain.dir");

View File

@ -42,8 +42,8 @@ public class LoggingOptionsTests extends AbstractJettyHomeTest
return Stream.of( return Stream.of(
Arguments.of("logging-jetty", Arguments.of("logging-jetty",
Arrays.asList( Arrays.asList(
"\\$\\{jetty.home\\}/lib/logging/slf4j-api-.*\\.jar", "\\$\\{jetty.home\\}[/\\\\]lib[/\\\\]logging[/\\\\]slf4j-api-.*\\.jar",
"\\$\\{jetty.home\\}/lib/logging/jetty-slf4j-impl-.*\\.jar"), "\\$\\{jetty.home\\}[/\\\\]lib[/\\\\]logging[/\\\\]jetty-slf4j-impl-.*\\.jar"),
Arrays.asList( Arrays.asList(
"logging/slf4j", "logging/slf4j",
"logging-jetty" "logging-jetty"
@ -51,9 +51,9 @@ public class LoggingOptionsTests extends AbstractJettyHomeTest
), ),
Arguments.of("logging-logback", Arguments.of("logging-logback",
Arrays.asList( Arrays.asList(
"\\$\\{jetty.home\\}/lib/logging/slf4j-api-.*\\.jar", "\\$\\{jetty.home\\}[/\\\\]lib[/\\\\]logging[/\\\\]slf4j-api-.*\\.jar",
"\\$\\{jetty.base\\}/lib/logging/logback-classic-.*\\.jar", "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]logback-classic-.*\\.jar",
"\\$\\{jetty.base\\}/lib/logging/logback-core-.*\\.jar" "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]logback-core-.*\\.jar"
), ),
Arrays.asList( Arrays.asList(
"logging/slf4j", "logging/slf4j",
@ -62,8 +62,8 @@ public class LoggingOptionsTests extends AbstractJettyHomeTest
), ),
Arguments.of("logging-jul", Arguments.of("logging-jul",
Arrays.asList( Arrays.asList(
"\\$\\{jetty.home\\}/lib/logging/slf4j-api-.*\\.jar", "\\$\\{jetty.home\\}[/\\\\]lib[/\\\\]logging[/\\\\]slf4j-api-.*\\.jar",
"\\$\\{jetty.base\\}/lib/logging/slf4j-jdk14-.*\\.jar" "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]slf4j-jdk14-.*\\.jar"
), ),
Arrays.asList( Arrays.asList(
"logging/slf4j", "logging/slf4j",
@ -72,8 +72,8 @@ public class LoggingOptionsTests extends AbstractJettyHomeTest
), ),
Arguments.of("logging-log4j1", Arguments.of("logging-log4j1",
Arrays.asList( Arrays.asList(
"\\$\\{jetty.home\\}/lib/logging/slf4j-api-.*\\.jar", "\\$\\{jetty.home\\}[/\\\\]lib[/\\\\]logging[/\\\\]slf4j-api-.*\\.jar",
"\\$\\{jetty.base\\}/lib/logging/slf4j-log4j12-.*\\.jar" "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]slf4j-log4j12-.*\\.jar"
), ),
Arrays.asList( Arrays.asList(
"logging/slf4j", "logging/slf4j",
@ -82,10 +82,10 @@ public class LoggingOptionsTests extends AbstractJettyHomeTest
), ),
Arguments.of("logging-log4j2", Arguments.of("logging-log4j2",
Arrays.asList( Arrays.asList(
"\\$\\{jetty.home\\}/lib/logging/slf4j-api-.*\\.jar", "\\$\\{jetty.home\\}[/\\\\]lib[/\\\\]logging[/\\\\]slf4j-api-.*\\.jar",
"\\$\\{jetty.base\\}/lib/logging/log4j-slf4j18-impl-.*\\.jar", "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]log4j-slf4j18-impl-.*\\.jar",
"\\$\\{jetty.base\\}/lib/logging/log4j-api-.*\\.jar", "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]log4j-api-.*\\.jar",
"\\$\\{jetty.base\\}/lib/logging/log4j-core-.*\\.jar" "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]log4j-core-.*\\.jar"
), ),
Arrays.asList( Arrays.asList(
"logging/slf4j", "logging/slf4j",
@ -95,7 +95,7 @@ public class LoggingOptionsTests extends AbstractJettyHomeTest
// Disabled, as slf4j noop is not supported by output/log monitoring of AbstractJettyHomeTest // Disabled, as slf4j noop is not supported by output/log monitoring of AbstractJettyHomeTest
/* Arguments.of("logging-noop", /* Arguments.of("logging-noop",
Arrays.asList( Arrays.asList(
"\\$\\{jetty.home\\}/lib/logging/slf4j-api-.*\\.jar" "\\$\\{jetty.home\\}[/\\\\]lib[/\\\\]logging[/\\\\]slf4j-api-.*\\.jar"
), Arrays.asList( ), Arrays.asList(
"logging/slf4j", "logging/slf4j",
"logging-log4j2" "logging-log4j2"
@ -103,12 +103,12 @@ public class LoggingOptionsTests extends AbstractJettyHomeTest
),*/ ),*/
Arguments.of("logging-logback,logging-jcl-capture,logging-jul-capture,logging-log4j1-capture", Arguments.of("logging-logback,logging-jcl-capture,logging-jul-capture,logging-log4j1-capture",
Arrays.asList( Arrays.asList(
"\\$\\{jetty.home\\}/lib/logging/slf4j-api-.*\\.jar", "\\$\\{jetty.home\\}[/\\\\]lib[/\\\\]logging[/\\\\]slf4j-api-.*\\.jar",
"\\$\\{jetty.base\\}/lib/logging/logback-classic-.*\\.jar", "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]logback-classic-.*\\.jar",
"\\$\\{jetty.base\\}/lib/logging/logback-core-.*\\.jar", "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]logback-core-.*\\.jar",
"\\$\\{jetty.base\\}/lib/logging/jcl-over-slf4j-.*\\.jar", "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]jcl-over-slf4j-.*\\.jar",
"\\$\\{jetty.base\\}/lib/logging/jul-to-slf4j-.*\\.jar", "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]jul-to-slf4j-.*\\.jar",
"\\$\\{jetty.base\\}/lib/logging/log4j-over-slf4j-.*\\.jar" "\\$\\{jetty.base\\}[/\\\\]lib[/\\\\]logging[/\\\\]log4j-over-slf4j-.*\\.jar"
), ),
Arrays.asList( Arrays.asList(
"logging/slf4j", "logging/slf4j",

View File

@ -32,12 +32,14 @@ import org.eclipse.jetty.tests.distribution.AbstractJettyHomeTest;
import org.eclipse.jetty.tests.distribution.JettyHomeTester; import org.eclipse.jetty.tests.distribution.JettyHomeTester;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.testcontainers.junit.jupiter.Testcontainers;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
@Testcontainers(disabledWithoutDocker = true)
public abstract class AbstractSessionDistributionTests extends AbstractJettyHomeTest public abstract class AbstractSessionDistributionTests extends AbstractJettyHomeTest
{ {

View File

@ -16,9 +16,12 @@ package org.eclipse.jetty.tests.distribution.session;
import java.util.Collections; import java.util.Collections;
import java.util.List; 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 public class FileSessionDistributionTests extends AbstractSessionDistributionTests
{ {
@ -52,4 +55,11 @@ public class FileSessionDistributionTests extends AbstractSessionDistributionTes
return Collections.emptyList(); return Collections.emptyList();
} }
@Override
@Test
@DisabledOnOs(value = OS.WINDOWS, disabledReason = "File always locked between stop/start")
public void stopRestartWebappTestSessionContentSaved() throws Exception
{
super.stopRestartWebappTestSessionContentSaved();
}
} }

View File

@ -43,6 +43,7 @@ public class FileSessionWithMemcacheDistributionTests extends AbstractSessionDis
{ {
memcached = memcached =
new GenericContainer("memcached:" + System.getProperty("memcached.docker.version", "1.6.6")) new GenericContainer("memcached:" + System.getProperty("memcached.docker.version", "1.6.6"))
.withExposedPorts(11211)
.withLogConsumer(new Slf4jLogConsumer(MEMCACHED_LOG)); .withLogConsumer(new Slf4jLogConsumer(MEMCACHED_LOG));
memcached.start(); memcached.start();
this.host = memcached.getContainerIpAddress(); this.host = memcached.getContainerIpAddress();

View File

@ -30,9 +30,13 @@ import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.tests.distribution.JettyHomeTester; 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.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.testcontainers.DockerClientFactory;
import org.testcontainers.containers.BindMode; import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer; 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.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue; 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 public class HazelcastSessionDistributionTests extends AbstractSessionDistributionTests
{ {
private static final Logger HAZELCAST_LOG = LoggerFactory.getLogger("org.eclipse.jetty.tests.distribution.session.HazelcastLogs"); 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 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) .withExposedPorts(5701)
.waitingFor(Wait.forListeningPort()) .waitingFor(Wait.forListeningPort())
.withLogConsumer(new Slf4jLogConsumer(HAZELCAST_LOG)); .withLogConsumer(new Slf4jLogConsumer(HAZELCAST_LOG));
}
private Path hazelcastJettyPath;
@Override @Override
public void startExternalSessionStorage() throws Exception public void startExternalSessionStorage() throws Exception
@ -80,7 +86,7 @@ public class HazelcastSessionDistributionTests extends AbstractSessionDistributi
} }
@Override @Override
public void stopExternalSessionStorage() throws Exception public void stopExternalSessionStorage()
{ {
hazelcast.stop(); hazelcast.stop();
} }
@ -106,18 +112,19 @@ public class HazelcastSessionDistributionTests extends AbstractSessionDistributi
); );
} }
@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 * 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 public void testHazelcastRemoteAndPartOfCluster() throws Exception
{ {
Map<String, String> env = new HashMap<>(); Map<String, String> env = new HashMap<>();
// -Dhazelcast.local.publicAddress=127.0.0.1:5701 // -Dhazelcast.local.publicAddress=127.0.0.1:5701
env.put("JAVA_OPTS", "-Dhazelcast.config=/opt/hazelcast/config_ext/hazelcast.xml"); env.put("JAVA_OPTS", "-Dhazelcast.config=/opt/hazelcast/config_ext/hazelcast.xml");
try (GenericContainer hazelcast = try (GenericContainer<?> hazelcast =
new GenericContainer("hazelcast/hazelcast:" + System.getProperty("hazelcast.version", "4.1")) new GenericContainer<>("hazelcast/hazelcast:" + System.getProperty("hazelcast.version", "4.1"))
.withExposedPorts(5701, 5705) .withExposedPorts(5701, 5705)
.withEnv(env) .withEnv(env)
.waitingFor(Wait.forLogMessage(".*is STARTED.*", 1)) .waitingFor(Wait.forLogMessage(".*is STARTED.*", 1))
@ -195,7 +202,6 @@ public class HazelcastSessionDistributionTests extends AbstractSessionDistributi
assertThat(response.getContentAsString(), containsString("SESSION READ CHOCOLATE THE BEST:FRENCH")); assertThat(response.getContentAsString(), containsString("SESSION READ CHOCOLATE THE BEST:FRENCH"));
} }
} }
} }
} }
@ -220,13 +226,11 @@ public class HazelcastSessionDistributionTests extends AbstractSessionDistributi
newLine.setLength(0); newLine.setLength(0);
newLine.append(interpolated); newLine.append(interpolated);
}); });
fileContent.append(newLine.toString()); fileContent.append(newLine);
fileContent.append(System.lineSeparator()); fileContent.append(System.lineSeparator());
}); });
outputStream.write(fileContent.toString().getBytes(StandardCharsets.UTF_8)); outputStream.write(fileContent.toString().getBytes(StandardCharsets.UTF_8));
} }
} }
} }

View File

@ -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 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 String imageName = "mongo:" + System.getProperty("mongo.docker.version", "2.2.7");
final GenericContainer mongoDBContainer = final GenericContainer mongoDBContainer =
new GenericContainer(imageName) new GenericContainer(imageName)
.withLogConsumer(new Slf4jLogConsumer(MONGO_LOG)) .withLogConsumer(new Slf4jLogConsumer(MONGO_LOG))
.waitingFor(new LogMessageWaitStrategy() .withExposedPorts(MONGO_PORT);
.withRegEx(".*waiting for connections.*"));
private String host; private String host;
private int port; private int port;
@ -46,7 +47,7 @@ public class MongodbSessionDistributionTests extends AbstractSessionDistribution
{ {
mongoDBContainer.start(); mongoDBContainer.start();
host = mongoDBContainer.getHost(); host = mongoDBContainer.getHost();
port = mongoDBContainer.getMappedPort(27017); port = mongoDBContainer.getMappedPort(MONGO_PORT);
} }
@Override @Override

View File

@ -13,7 +13,9 @@
package org.eclipse.jetty.test; package org.eclipse.jetty.test;
import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.nio.file.FileSystemException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.StandardCopyOption; 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.Server;
import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory; 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.MavenTestingUtils;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir; import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension; 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.KeyStoreScanner;
import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue; 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) @ExtendWith(WorkDirExtension.class)
public class KeyStoreScannerTest public class KeyStoreScannerTest
@ -107,7 +110,7 @@ public class KeyStoreScannerTest
@AfterEach @AfterEach
public void stop() throws Exception public void stop() throws Exception
{ {
server.stop(); LifeCycle.stop(server);
} }
@Test @Test
@ -176,9 +179,9 @@ public class KeyStoreScannerTest
} }
@Test @Test
@DisabledOnOs(WINDOWS) // does not support symbolic link
public void testReloadChangingSymbolicLink() throws Exception public void testReloadChangingSymbolicLink() throws Exception
{ {
assumeFileSystemSupportsSymlink();
Path keystorePath = keystoreDir.resolve("symlinkKeystore"); Path keystorePath = keystoreDir.resolve("symlinkKeystore");
start(sslContextFactory -> start(sslContextFactory ->
{ {
@ -203,9 +206,9 @@ public class KeyStoreScannerTest
} }
@Test @Test
@DisabledOnOs(WINDOWS) // does not support symbolic link
public void testReloadChangingTargetOfSymbolicLink() throws Exception public void testReloadChangingTargetOfSymbolicLink() throws Exception
{ {
assumeFileSystemSupportsSymlink();
Path keystoreLink = keystoreDir.resolve("symlinkKeystore"); Path keystoreLink = keystoreDir.resolve("symlinkKeystore");
Path oldKeystoreSrc = MavenTestingUtils.getTestResourcePathFile("oldKeystore"); Path oldKeystoreSrc = MavenTestingUtils.getTestResourcePathFile("oldKeystore");
Path newKeystoreSrc = MavenTestingUtils.getTestResourcePathFile("newKeystore"); Path newKeystoreSrc = MavenTestingUtils.getTestResourcePathFile("newKeystore");
@ -273,6 +276,28 @@ public class KeyStoreScannerTest
return (X509Certificate)certs[0]; 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 private static class DefaultTrustManager implements X509TrustManager
{ {
@Override @Override

View File

@ -96,7 +96,6 @@ public abstract class RFC2616BaseTest
server = testableserver; server = testableserver;
server.load(); server.load();
server.start(); server.start();
//server.getServer().dumpStdErr();
} }
@BeforeEach @BeforeEach

View File

@ -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.HttpSocket;
import org.eclipse.jetty.test.support.rawhttp.HttpsSocketImpl; import org.eclipse.jetty.test.support.rawhttp.HttpsSocketImpl;
import org.junit.jupiter.api.BeforeAll; 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). * 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 public class RFC2616NIOHttpsTest extends RFC2616BaseTest
{ {
@BeforeAll @BeforeAll
@ -35,6 +32,7 @@ public class RFC2616NIOHttpsTest extends RFC2616BaseTest
server.addXmlConfiguration("RFC2616Base.xml"); server.addXmlConfiguration("RFC2616Base.xml");
server.addXmlConfiguration("RFC2616_Redirects.xml"); server.addXmlConfiguration("RFC2616_Redirects.xml");
server.addXmlConfiguration("RFC2616_Filters.xml"); server.addXmlConfiguration("RFC2616_Filters.xml");
server.addXmlConfiguration("ssl.xml");
server.addXmlConfiguration("NIOHttps.xml"); server.addXmlConfiguration("NIOHttps.xml");
setUpServer(server, RFC2616NIOHttpsTest.class); setUpServer(server, RFC2616NIOHttpsTest.class);
} }

View File

@ -77,6 +77,10 @@ public class XmlBasedJettyServer
Path webappsDir = MavenTestingUtils.getTargetPath("webapps"); Path webappsDir = MavenTestingUtils.getTargetPath("webapps");
properties.setProperty("test.webapps", webappsDir.toString()); 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. // Write out configuration for use by ConfigurationManager.
Path testConfig = targetDir.resolve("testable-jetty-server-config.properties"); Path testConfig = targetDir.resolve("testable-jetty-server-config.properties");
try (OutputStream out = Files.newOutputStream(testConfig)) try (OutputStream out = Files.newOutputStream(testConfig))

View File

@ -18,9 +18,7 @@ import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.Socket; import java.net.Socket;
import java.net.SocketAddress; import java.net.SocketAddress;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.SSLSocketFactory;
@ -40,21 +38,8 @@ public class HttpsSocketImpl implements HttpSocket
public HttpsSocketImpl() throws Exception 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 try
{ {
// TODO real trust manager
this.sslContext = SSLContext.getInstance("TLS"); this.sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, SslContextFactory.TRUST_ALL_CERTS, new java.security.SecureRandom()); 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 public Socket connect(InetAddress host, int port) throws IOException
{ {
SSLSocket sslsock = (SSLSocket)sslfactory.createSocket(); SSLSocket sslsock = (SSLSocket)sslfactory.createSocket();
sslsock.setEnabledProtocols(new String[]{"TLSv1"});
SocketAddress address = new InetSocketAddress(host, port); SocketAddress address = new InetSocketAddress(host, port);
sslsock.connect(address); sslsock.connect(address);
return sslsock; return sslsock;

View File

@ -1,12 +1,12 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_9_3.dtd"> <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server"> <Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- =========================================================== --> <!-- =========================================================== -->
<!-- Set connectors --> <!-- Set connectors -->
<!-- =========================================================== --> <!-- =========================================================== -->
<Call id="httpsConnector" name="addConnector">
<Call name="addConnector">
<Arg> <Arg>
<New class="org.eclipse.jetty.server.ServerConnector"> <New class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server"><Ref refid="Server" /></Arg> <Arg name="server"><Ref refid="Server" /></Arg>
@ -25,12 +25,7 @@
</Item> </Item>
</Array> </Array>
</Arg> </Arg>
<Set name="host"><Property name="jetty.http.host" /></Set>
<Set name="idleTimeout">30000</Set>
</New> </New>
</Arg> </Arg>
</Call> </Call>
</Configure> </Configure>

View File

@ -1,22 +1,9 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd"> <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">
<Configure id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory$Server"> <Configure id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory$Server">
<Set name="KeyStorePath"><Property name="jetty.home" default="." />/<Property name="jetty.sslContext.keyStorePath" default="keystore.p12"/></Set>
<Set name="KeyStorePath"><Property name="jetty.sslContext.keyStorePath"/></Set>
<Set name="KeyStorePassword"><Property name="jetty.sslContext.keyStorePassword"/></Set> <Set name="KeyStorePassword"><Property name="jetty.sslContext.keyStorePassword"/></Set>
<Set name="KeyManagerPassword"><Property name="jetty.sslContext.keyManagerPassword"/></Set>
<Set name="TrustStorePath"><Property name="jetty.home" default="." />/<Property name="jetty.sslContext.trustStorePath" default="keystore.p12"/></Set>
<Set name="TrustStorePassword"><Property name="jetty.sslContext.trustStorePassword"/></Set>
<Set name="ExcludeCipherSuites">
<Array type="String">
<Item>SSL_RSA_WITH_DES_CBC_SHA</Item>
<Item>SSL_DHE_RSA_WITH_DES_CBC_SHA</Item>
<Item>SSL_DHE_DSS_WITH_DES_CBC_SHA</Item>
<Item>SSL_RSA_EXPORT_WITH_RC4_40_MD5</Item>
<Item>SSL_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
<Item>SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
<Item>SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA</Item>
</Array>
</Set>
<!-- =========================================================== --> <!-- =========================================================== -->
<!-- Create a TLS specific HttpConfiguration based on the --> <!-- Create a TLS specific HttpConfiguration based on the -->
@ -27,7 +14,12 @@
<New id="sslHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration"> <New id="sslHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
<Arg><Ref refid="httpConfig"/></Arg> <Arg><Ref refid="httpConfig"/></Arg>
<Call name="addCustomizer"> <Call name="addCustomizer">
<Arg><New class="org.eclipse.jetty.server.SecureRequestCustomizer"/></Arg> <Arg>
<New class="org.eclipse.jetty.server.SecureRequestCustomizer">
<Set name="sniRequired">false</Set>
<Set name="SniHostCheck">false</Set>
</New>
</Arg>
</Call> </Call>
</New> </New>

View File

@ -10,4 +10,12 @@
</New> </New>
</Arg> </Arg>
</Call> </Call>
<Get name="systemClassMatcher">
<Call name="add"><Arg>org.slf4j.</Arg></Call>
<Call name="add"><Arg>org.eclipse.jetty.logging.</Arg></Call>
</Get>
<Get name="serverClassMatcher">
<Call name="add"><Arg>-org.slf4j.</Arg></Call>
<Call name="add"><Arg>-org.eclipse.jetty.logging.</Arg></Call>
</Get>
</Configure> </Configure>

View File

@ -149,6 +149,7 @@ public class MemcachedTestHelper
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
static GenericContainer memcached = static GenericContainer memcached =
new GenericContainer("memcached:" + System.getProperty("memcached.docker.version", "1.6.6")) new GenericContainer("memcached:" + System.getProperty("memcached.docker.version", "1.6.6"))
.withExposedPorts(11211)
.withLogConsumer(new Slf4jLogConsumer(MEMCACHED_LOG)); .withLogConsumer(new Slf4jLogConsumer(MEMCACHED_LOG));
static static

View File

@ -48,11 +48,12 @@ public class MongoTestHelper
public static final String DB_NAME = "HttpSessions"; public static final String DB_NAME = "HttpSessions";
public static final String COLLECTION_NAME = "testsessions"; public static final String COLLECTION_NAME = "testsessions";
private static final int MONGO_PORT = 27017;
static GenericContainer mongo = static GenericContainer mongo =
new GenericContainer("mongo:" + System.getProperty("mongo.docker.version", "2.2.7")) new GenericContainer("mongo:" + System.getProperty("mongo.docker.version", "2.2.7"))
.withLogConsumer(new Slf4jLogConsumer(MONGO_LOG)) .withLogConsumer(new Slf4jLogConsumer(MONGO_LOG))
.waitingFor(new LogMessageWaitStrategy() .withExposedPorts(MONGO_PORT);
.withRegEx(".*waiting for connections.*"));
static MongoClient mongoClient; static MongoClient mongoClient;
@ -66,7 +67,7 @@ public class MongoTestHelper
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
mongo.start(); mongo.start();
mongoHost = mongo.getHost(); mongoHost = mongo.getHost();
mongoPort = mongo.getMappedPort(27017); mongoPort = mongo.getMappedPort(MONGO_PORT);
LOG.info("Mongo container started for {}:{} - {}ms", mongoHost, mongoPort, LOG.info("Mongo container started for {}:{} - {}ms", mongoHost, mongoPort,
System.currentTimeMillis() - start); System.currentTimeMillis() - start);
mongoClient = new MongoClient(mongoHost, mongoPort); mongoClient = new MongoClient(mongoHost, mongoPort);