Issue #5684 - Window's test overhaul
+ Migrate from @DisabledOnOs(WINDOWS) to assumptions on capabilities instead. + Fix other outstanding windows testing issues. Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
parent
cbb3a550cc
commit
7741ecc1e5
|
@ -73,7 +73,6 @@ import org.junit.jupiter.api.AfterEach;
|
|||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||
import org.junit.jupiter.api.condition.EnabledOnJre;
|
||||
import org.junit.jupiter.api.condition.EnabledOnOs;
|
||||
import org.junit.jupiter.api.condition.JRE;
|
||||
|
@ -87,7 +86,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
|||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.junit.jupiter.api.condition.OS.LINUX;
|
||||
import static org.junit.jupiter.api.condition.OS.WINDOWS;
|
||||
|
||||
// Other JREs have slight differences in how TLS work
|
||||
// and this test expects a very specific TLS behavior.
|
||||
|
@ -1032,7 +1030,6 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisabledOnOs(WINDOWS) // Don't run on Windows (buggy JVM)
|
||||
public void testRequestWithBigContentWriteBlockedThenReset() throws Exception
|
||||
{
|
||||
final SSLSocket client = newClient();
|
||||
|
@ -1087,7 +1084,6 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisabledOnOs(WINDOWS) // Don't run on Windows (buggy JVM)
|
||||
public void testRequestWithBigContentReadBlockedThenReset() throws Exception
|
||||
{
|
||||
final SSLSocket client = newClient();
|
||||
|
|
|
@ -33,11 +33,8 @@ import org.eclipse.jetty.util.resource.Resource;
|
|||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import static org.junit.jupiter.api.condition.OS.WINDOWS;
|
||||
|
||||
/**
|
||||
* Similar in scope to {@link ScanningAppProviderStartupTest}, except is concerned with the modification of existing
|
||||
* deployed webapps due to incoming changes identified by the {@link ScanningAppProvider}.
|
||||
|
@ -160,8 +157,6 @@ public class ScanningAppProviderRuntimeUpdatesTest
|
|||
* @throws Exception on test failure
|
||||
*/
|
||||
@Test
|
||||
@DisabledOnOs(WINDOWS)
|
||||
// This test will not work on Windows as second war file would, not be written over the first one because of a file lock
|
||||
public void testAfterStartupThenUpdateContext() throws Exception
|
||||
{
|
||||
jetty.copyWebapp("foo-webapp-1.war", "foo.war");
|
||||
|
|
|
@ -53,7 +53,6 @@ import static org.hamcrest.Matchers.is;
|
|||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.condition.OS.MAC;
|
||||
import static org.junit.jupiter.api.condition.OS.WINDOWS;
|
||||
|
||||
@ExtendWith(WorkDirExtension.class)
|
||||
public class PropertyUserStoreTest
|
||||
|
@ -282,7 +281,6 @@ public class PropertyUserStoreTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisabledOnOs({MAC, WINDOWS}) // File is locked on OS, cannot change.
|
||||
public void testPropertyUserStoreLoadRemoveUser() throws Exception
|
||||
{
|
||||
testdir.ensureEmpty();
|
||||
|
|
|
@ -52,7 +52,6 @@ import org.hamcrest.Matcher;
|
|||
import org.hamcrest.Matchers;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
@ -67,7 +66,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
|||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.junit.jupiter.api.condition.OS.WINDOWS;
|
||||
|
||||
public class GracefulStopTest
|
||||
{
|
||||
|
@ -238,7 +236,6 @@ public class GracefulStopTest
|
|||
* @throws Exception on test failure
|
||||
*/
|
||||
@Test
|
||||
@DisabledOnOs(WINDOWS) // TODO: needs more investigation
|
||||
public void testGracefulComplete() throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
|
|
|
@ -37,21 +37,16 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
|||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.condition.OS.MAC;
|
||||
|
||||
@Disabled
|
||||
@Tag("stress")
|
||||
@DisabledOnOs(MAC) // TODO: needs investigation
|
||||
public class StressTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(StressTest.class);
|
||||
|
@ -134,6 +129,7 @@ public class StressTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@Tag("Slow")
|
||||
public void testNonPersistent() throws Throwable
|
||||
{
|
||||
doThreads(20, 20, false);
|
||||
|
@ -150,6 +146,7 @@ public class StressTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@Tag("Slow")
|
||||
public void testPersistent() throws Throwable
|
||||
{
|
||||
doThreads(40, 40, true);
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.KeyStore;
|
||||
|
@ -31,7 +30,6 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLException;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
import javax.servlet.ServletException;
|
||||
|
@ -41,7 +39,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.io.LeakTrackingByteBufferPool;
|
||||
import org.eclipse.jetty.io.MappedByteBufferPool;
|
||||
import org.eclipse.jetty.io.ssl.SslConnection;
|
||||
import org.eclipse.jetty.server.AbstractConnectionFactory;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.HttpServerTestBase;
|
||||
|
@ -50,13 +47,11 @@ import org.eclipse.jetty.server.SecureRequestCustomizer;
|
|||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
@ -64,7 +59,6 @@ import static org.hamcrest.Matchers.emptyOrNullString;
|
|||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.condition.OS.WINDOWS;
|
||||
|
||||
/**
|
||||
* HttpServer Tester for SSL based ServerConnector
|
||||
|
@ -131,43 +125,6 @@ public class ServerConnectorSslServerTest extends HttpServerTestBase
|
|||
return socket;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DisabledOnOs(WINDOWS) // Don't run on Windows (buggy JVM)
|
||||
public void testFullMethod() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
super.testFullMethod();
|
||||
}
|
||||
catch (SocketException e)
|
||||
{
|
||||
// TODO This needs to be investigated #2244
|
||||
Log.getLogger(SslConnection.class).warn("Close overtook 400 response");
|
||||
}
|
||||
catch (SSLException e)
|
||||
{
|
||||
// TODO This needs to be investigated #2244
|
||||
if (e.getCause() instanceof SocketException)
|
||||
Log.getLogger(SslConnection.class).warn("Close overtook 400 response");
|
||||
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.getLogger(SslConnection.class).warn("Close overtook 400 response");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testFullHeader() throws Exception
|
||||
{
|
||||
|
|
|
@ -68,8 +68,6 @@ import org.hamcrest.Matchers;
|
|||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||
import org.junit.jupiter.api.condition.OS;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
@ -262,7 +260,6 @@ public class SniSslConnectionFactoryTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisabledOnOs(OS.WINDOWS)
|
||||
public void testWrongSNIRejectedConnection() throws Exception
|
||||
{
|
||||
start(ssl ->
|
||||
|
@ -307,7 +304,6 @@ public class SniSslConnectionFactoryTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisabledOnOs(OS.WINDOWS)
|
||||
public void testWrongSNIRejectedFunction() throws Exception
|
||||
{
|
||||
start(ssl ->
|
||||
|
@ -338,7 +334,6 @@ public class SniSslConnectionFactoryTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisabledOnOs(OS.WINDOWS)
|
||||
public void testWrongSNIRejectedConnectionWithNonSNIKeystore() throws Exception
|
||||
{
|
||||
start(ssl ->
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.File;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.PathMatcher;
|
||||
import java.util.List;
|
||||
|
@ -35,66 +36,56 @@ import org.eclipse.jetty.util.Scanner.Notification;
|
|||
import org.hamcrest.Matchers;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
|
||||
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.condition.OS.WINDOWS;
|
||||
|
||||
public class ScannerTest
|
||||
{
|
||||
static File _directory;
|
||||
static Path _directory;
|
||||
static Scanner _scanner;
|
||||
static BlockingQueue<Event> _queue = new LinkedBlockingQueue<Event>();
|
||||
static BlockingQueue<List<String>> _bulk = new LinkedBlockingQueue<List<String>>();
|
||||
static BlockingQueue<Event> _queue = new LinkedBlockingQueue<>();
|
||||
static BlockingQueue<List<String>> _bulk = new LinkedBlockingQueue<>();
|
||||
|
||||
@BeforeAll
|
||||
public static void setUpBeforeClass() throws Exception
|
||||
{
|
||||
File testDir = MavenTestingUtils.getTargetTestingDir(ScannerTest.class.getSimpleName());
|
||||
FS.ensureEmpty(testDir);
|
||||
_directory = MavenTestingUtils.getTargetTestingPath(ScannerTest.class.getSimpleName());
|
||||
FS.ensureEmpty(_directory);
|
||||
|
||||
// Use full path, pointing to a real directory (for FileSystems that are case-insensitive, like Windows and OSX to use)
|
||||
// This is only needed for the various comparisons below to make sense.
|
||||
_directory = testDir.toPath().toRealPath().toFile();
|
||||
_directory = _directory.toRealPath();
|
||||
|
||||
_scanner = new Scanner();
|
||||
_scanner.addScanDir(_directory);
|
||||
_scanner.addDirectory(_directory);
|
||||
_scanner.setScanInterval(0);
|
||||
_scanner.setReportDirs(false);
|
||||
_scanner.setReportExistingFilesOnStartup(false);
|
||||
_scanner.addListener(new Scanner.DiscreteListener()
|
||||
{
|
||||
@Override
|
||||
public void fileRemoved(String filename) throws Exception
|
||||
public void fileRemoved(String filename)
|
||||
{
|
||||
_queue.add(new Event(filename, Notification.REMOVED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileChanged(String filename) throws Exception
|
||||
public void fileChanged(String filename)
|
||||
{
|
||||
_queue.add(new Event(filename, Notification.CHANGED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileAdded(String filename) throws Exception
|
||||
public void fileAdded(String filename)
|
||||
{
|
||||
_queue.add(new Event(filename, Notification.ADDED));
|
||||
}
|
||||
});
|
||||
_scanner.addListener(new Scanner.BulkListener()
|
||||
{
|
||||
@Override
|
||||
public void filesChanged(List<String> filenames) throws Exception
|
||||
{
|
||||
_bulk.add(filenames);
|
||||
}
|
||||
});
|
||||
_scanner.addListener((Scanner.BulkListener)filenames -> _bulk.add(filenames));
|
||||
|
||||
_scanner.start();
|
||||
_scanner.scan();
|
||||
|
@ -107,7 +98,6 @@ public class ScannerTest
|
|||
public static void tearDownAfterClass() throws Exception
|
||||
{
|
||||
_scanner.stop();
|
||||
IO.delete(_directory);
|
||||
}
|
||||
|
||||
static class Event
|
||||
|
@ -125,7 +115,7 @@ public class ScannerTest
|
|||
@Test
|
||||
public void testDepth() throws Exception
|
||||
{
|
||||
File root = new File(_directory, "root");
|
||||
File root = new File(_directory.toFile(), "root");
|
||||
FS.ensureDirExists(root);
|
||||
FS.touch(new File(root, "foo.foo"));
|
||||
FS.touch(new File(root, "foo2.foo"));
|
||||
|
@ -142,7 +132,7 @@ public class ScannerTest
|
|||
File y2 = new File(dir2, "yyy2.foo");
|
||||
FS.touch(y2);
|
||||
|
||||
BlockingQueue<Event> queue = new LinkedBlockingQueue<Event>();
|
||||
BlockingQueue<Event> queue = new LinkedBlockingQueue<>();
|
||||
Scanner scanner = new Scanner();
|
||||
scanner.setScanInterval(0);
|
||||
scanner.setScanDepth(0);
|
||||
|
@ -152,19 +142,19 @@ public class ScannerTest
|
|||
scanner.addListener(new Scanner.DiscreteListener()
|
||||
{
|
||||
@Override
|
||||
public void fileRemoved(String filename) throws Exception
|
||||
public void fileRemoved(String filename)
|
||||
{
|
||||
queue.add(new Event(filename, Notification.REMOVED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileChanged(String filename) throws Exception
|
||||
public void fileChanged(String filename)
|
||||
{
|
||||
queue.add(new Event(filename, Notification.CHANGED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileAdded(String filename) throws Exception
|
||||
public void fileAdded(String filename)
|
||||
{
|
||||
queue.add(new Event(filename, Notification.ADDED));
|
||||
}
|
||||
|
@ -201,7 +191,7 @@ public class ScannerTest
|
|||
public void testPatterns() throws Exception
|
||||
{
|
||||
//test include and exclude patterns
|
||||
File root = new File(_directory, "proot");
|
||||
File root = new File(_directory.toFile(), "proot");
|
||||
FS.ensureDirExists(root);
|
||||
|
||||
File ttt = new File(root, "ttt.txt");
|
||||
|
@ -222,7 +212,7 @@ public class ScannerTest
|
|||
File y2 = new File(dir2, "yyy.txt");
|
||||
FS.touch(y2);
|
||||
|
||||
BlockingQueue<Event> queue = new LinkedBlockingQueue<Event>();
|
||||
BlockingQueue<Event> queue = new LinkedBlockingQueue<>();
|
||||
//only scan the *.txt files for changes
|
||||
Scanner scanner = new Scanner();
|
||||
IncludeExcludeSet<PathMatcher, Path> pattern = scanner.addDirectory(root.toPath());
|
||||
|
@ -235,19 +225,19 @@ public class ScannerTest
|
|||
scanner.addListener(new Scanner.DiscreteListener()
|
||||
{
|
||||
@Override
|
||||
public void fileRemoved(String filename) throws Exception
|
||||
public void fileRemoved(String filename)
|
||||
{
|
||||
queue.add(new Event(filename, Notification.REMOVED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileChanged(String filename) throws Exception
|
||||
public void fileChanged(String filename)
|
||||
{
|
||||
queue.add(new Event(filename, Notification.CHANGED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileAdded(String filename) throws Exception
|
||||
public void fileAdded(String filename)
|
||||
{
|
||||
queue.add(new Event(filename, Notification.ADDED));
|
||||
}
|
||||
|
@ -272,8 +262,7 @@ public class ScannerTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisabledOnOs(WINDOWS) // TODO: needs review
|
||||
@DisabledIfSystemProperty(named = "env", matches = "ci") // TODO: SLOW, needs review
|
||||
@Tag("Slow")
|
||||
public void testAddedChangeRemove() throws Exception
|
||||
{
|
||||
touch("a0");
|
||||
|
@ -284,7 +273,7 @@ public class ScannerTest
|
|||
|
||||
Event event = _queue.poll();
|
||||
assertNotNull(event, "Event should not be null");
|
||||
assertEquals(_directory + "/a0", event._filename);
|
||||
assertEquals(_directory.resolve("a0").toString(), event._filename);
|
||||
assertEquals(Notification.ADDED, event._notification);
|
||||
|
||||
// add 3 more files
|
||||
|
@ -296,9 +285,9 @@ public class ScannerTest
|
|||
// not stable after 1 scan so should not be seen yet.
|
||||
_scanner.scan();
|
||||
event = _queue.poll();
|
||||
assertTrue(event == null);
|
||||
assertNull(event);
|
||||
|
||||
// Keep a2 unstable and remove a3 before it stabalized
|
||||
// Keep a2 unstable and remove a3 before it stabilized
|
||||
Thread.sleep(1100); // make sure time in seconds changes
|
||||
touch("a2");
|
||||
delete("a3");
|
||||
|
@ -306,16 +295,16 @@ public class ScannerTest
|
|||
// only a1 is stable so it should be seen.
|
||||
_scanner.scan();
|
||||
event = _queue.poll();
|
||||
assertTrue(event != null);
|
||||
assertEquals(_directory + "/a1", event._filename);
|
||||
assertNotNull(event);
|
||||
assertEquals(_directory.resolve("a1").toString(), event._filename);
|
||||
assertEquals(Notification.ADDED, event._notification);
|
||||
assertTrue(_queue.isEmpty());
|
||||
|
||||
// Now a2 is stable
|
||||
_scanner.scan();
|
||||
event = _queue.poll();
|
||||
assertTrue(event != null);
|
||||
assertEquals(_directory + "/a2", event._filename);
|
||||
assertNotNull(event);
|
||||
assertEquals(_directory.resolve("a2").toString(), event._filename);
|
||||
assertEquals(Notification.ADDED, event._notification);
|
||||
assertTrue(_queue.isEmpty());
|
||||
|
||||
|
@ -328,7 +317,7 @@ public class ScannerTest
|
|||
// not stable after 1scan so nothing should not be seen yet.
|
||||
_scanner.scan();
|
||||
event = _queue.poll();
|
||||
assertTrue(event == null);
|
||||
assertNull(event);
|
||||
|
||||
// Keep a2 unstable
|
||||
Thread.sleep(1100); // make sure time in seconds changes
|
||||
|
@ -337,16 +326,16 @@ public class ScannerTest
|
|||
// only a1 is stable so it should be seen.
|
||||
_scanner.scan();
|
||||
event = _queue.poll();
|
||||
assertTrue(event != null);
|
||||
assertEquals(_directory + "/a1", event._filename);
|
||||
assertNotNull(event);
|
||||
assertEquals(_directory.resolve("a1").toString(), event._filename);
|
||||
assertEquals(Notification.CHANGED, event._notification);
|
||||
assertTrue(_queue.isEmpty());
|
||||
|
||||
// Now a2 is stable
|
||||
_scanner.scan();
|
||||
event = _queue.poll();
|
||||
assertTrue(event != null);
|
||||
assertEquals(_directory + "/a2", event._filename);
|
||||
assertNotNull(event);
|
||||
assertEquals(_directory.resolve("a2").toString(), event._filename);
|
||||
assertEquals(Notification.CHANGED, event._notification);
|
||||
assertTrue(_queue.isEmpty());
|
||||
|
||||
|
@ -356,7 +345,7 @@ public class ScannerTest
|
|||
// not stable after 1scan so nothing should not be seen yet.
|
||||
_scanner.scan();
|
||||
event = _queue.poll();
|
||||
assertTrue(event == null);
|
||||
assertNull(event);
|
||||
|
||||
// readd a2
|
||||
touch("a2");
|
||||
|
@ -364,22 +353,21 @@ public class ScannerTest
|
|||
// only a1 is stable so it should be seen.
|
||||
_scanner.scan();
|
||||
event = _queue.poll();
|
||||
assertTrue(event != null);
|
||||
assertEquals(_directory + "/a1", event._filename);
|
||||
assertNotNull(event);
|
||||
assertEquals(_directory.resolve("a1").toString(), event._filename);
|
||||
assertEquals(Notification.REMOVED, event._notification);
|
||||
assertTrue(_queue.isEmpty());
|
||||
|
||||
// Now a2 is stable and is a changed file rather than a remove
|
||||
_scanner.scan();
|
||||
event = _queue.poll();
|
||||
assertTrue(event != null);
|
||||
assertEquals(_directory + "/a2", event._filename);
|
||||
assertNotNull(event);
|
||||
assertEquals(_directory.resolve("a2").toString(), event._filename);
|
||||
assertEquals(Notification.CHANGED, event._notification);
|
||||
assertTrue(_queue.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisabledOnOs(WINDOWS) // TODO: needs review
|
||||
public void testSizeChange() throws Exception
|
||||
{
|
||||
touch("tsc0");
|
||||
|
@ -388,13 +376,13 @@ public class ScannerTest
|
|||
|
||||
// takes 2s to notice tsc0 and check that it is stable. This syncs us with the scan
|
||||
Event event = _queue.poll();
|
||||
assertTrue(event != null);
|
||||
assertEquals(_directory + "/tsc0", event._filename);
|
||||
assertNotNull(event);
|
||||
assertEquals(_directory.resolve("tsc0").toString(), event._filename);
|
||||
assertEquals(Notification.ADDED, event._notification);
|
||||
|
||||
// Create a new file by writing to it.
|
||||
long now = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||
File file = new File(_directory, "st");
|
||||
File file = new File(_directory.toFile(), "st");
|
||||
try (OutputStream out = new FileOutputStream(file, true))
|
||||
{
|
||||
out.write('x');
|
||||
|
@ -404,7 +392,7 @@ public class ScannerTest
|
|||
// Not stable yet so no notification.
|
||||
_scanner.scan();
|
||||
event = _queue.poll();
|
||||
assertTrue(event == null);
|
||||
assertNull(event);
|
||||
|
||||
// Modify size only
|
||||
out.write('x');
|
||||
|
@ -414,13 +402,13 @@ public class ScannerTest
|
|||
// Still not stable yet so no notification.
|
||||
_scanner.scan();
|
||||
event = _queue.poll();
|
||||
assertTrue(event == null);
|
||||
assertNull(event);
|
||||
|
||||
// now stable so finally see the ADDED
|
||||
_scanner.scan();
|
||||
event = _queue.poll();
|
||||
assertTrue(event != null);
|
||||
assertEquals(_directory + "/st", event._filename);
|
||||
assertNotNull(event);
|
||||
assertEquals(_directory.resolve("st").toString(), event._filename);
|
||||
assertEquals(Notification.ADDED, event._notification);
|
||||
|
||||
// Modify size only
|
||||
|
@ -431,27 +419,26 @@ public class ScannerTest
|
|||
// Still not stable yet so no notification.
|
||||
_scanner.scan();
|
||||
event = _queue.poll();
|
||||
assertTrue(event == null);
|
||||
assertNull(event);
|
||||
|
||||
// now stable so finally see the ADDED
|
||||
_scanner.scan();
|
||||
event = _queue.poll();
|
||||
assertTrue(event != null);
|
||||
assertEquals(_directory + "/st", event._filename);
|
||||
assertNotNull(event);
|
||||
assertEquals(_directory.resolve("st").toString(), event._filename);
|
||||
assertEquals(Notification.CHANGED, event._notification);
|
||||
}
|
||||
}
|
||||
|
||||
private void delete(String string) throws IOException
|
||||
{
|
||||
File file = new File(_directory, string);
|
||||
if (file.exists())
|
||||
IO.delete(file);
|
||||
Path file = _directory.resolve(string);
|
||||
Files.deleteIfExists(file);
|
||||
}
|
||||
|
||||
private void touch(String string) throws IOException
|
||||
{
|
||||
File file = new File(_directory, string);
|
||||
File file = new File(_directory.toFile(), string);
|
||||
if (file.exists())
|
||||
file.setLastModified(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()));
|
||||
else
|
||||
|
|
|
@ -51,7 +51,6 @@ import org.eclipse.jetty.util.BufferUtil;
|
|||
import org.hamcrest.BaseMatcher;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||
import org.junit.jupiter.api.condition.EnabledOnOs;
|
||||
import org.junit.jupiter.api.condition.OS;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
@ -663,7 +662,6 @@ public class FileSystemResourceTest
|
|||
|
||||
@ParameterizedTest
|
||||
@MethodSource("fsResourceProvider")
|
||||
@DisabledOnOs(WINDOWS)
|
||||
public void testSymlink(Class resourceClass) throws Exception
|
||||
{
|
||||
Path dir = workDir.getEmptyPathDir();
|
||||
|
@ -680,7 +678,7 @@ public class FileSystemResourceTest
|
|||
{
|
||||
// if unable to create symlink, no point testing the rest
|
||||
// this is the path that Microsoft Windows takes.
|
||||
assumeTrue(true, "Not supported");
|
||||
assumeTrue(false, "Not supported");
|
||||
}
|
||||
|
||||
try (Resource base = newResource(resourceClass, dir.toFile()))
|
||||
|
@ -705,7 +703,6 @@ public class FileSystemResourceTest
|
|||
|
||||
@ParameterizedTest
|
||||
@ValueSource(classes = PathResource.class) // FileResource does not support this
|
||||
@DisabledOnOs(WINDOWS)
|
||||
public void testNonExistantSymlink(Class resourceClass) throws Exception
|
||||
{
|
||||
Path dir = workDir.getEmptyPathDir();
|
||||
|
@ -722,7 +719,7 @@ public class FileSystemResourceTest
|
|||
{
|
||||
// if unable to create symlink, no point testing the rest
|
||||
// this is the path that Microsoft Windows takes.
|
||||
assumeTrue(true, "Not supported");
|
||||
assumeTrue(false, "Not supported");
|
||||
}
|
||||
|
||||
try (Resource base = newResource(resourceClass, dir.toFile()))
|
||||
|
@ -858,7 +855,7 @@ public class FileSystemResourceTest
|
|||
catch (InvalidPathException e)
|
||||
{
|
||||
// NTFS filesystem streams are unsupported on some platforms.
|
||||
assumeTrue(true, "Not supported");
|
||||
assumeTrue(false, "NTFS filesystem streams not supported");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -906,7 +903,7 @@ public class FileSystemResourceTest
|
|||
catch (InvalidPathException e)
|
||||
{
|
||||
// NTFS filesystem streams are unsupported on some platforms.
|
||||
assumeTrue(true, "Not supported");
|
||||
assumeTrue(false, "NTFS filesystem streams not supported");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -952,14 +949,13 @@ public class FileSystemResourceTest
|
|||
catch (InvalidPathException e)
|
||||
{
|
||||
// NTFS filesystem streams are unsupported on some platforms.
|
||||
assumeTrue(true, "Not supported on this OS");
|
||||
assumeTrue(false, "NFTS Dats streams not supported");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("fsResourceProvider")
|
||||
@DisabledOnOs(WINDOWS)
|
||||
public void testSemicolon(Class resourceClass) throws Exception
|
||||
{
|
||||
Path dir = workDir.getEmptyPathDir();
|
||||
|
@ -974,7 +970,7 @@ public class FileSystemResourceTest
|
|||
{
|
||||
// if unable to create file, no point testing the rest.
|
||||
// this is the path that Microsoft Windows takes.
|
||||
assumeTrue(true, "Not supported on this OS");
|
||||
assumeTrue(false, "Not supported on this OS");
|
||||
}
|
||||
|
||||
try (Resource base = newResource(resourceClass, dir.toFile()))
|
||||
|
@ -986,7 +982,6 @@ public class FileSystemResourceTest
|
|||
|
||||
@ParameterizedTest
|
||||
@MethodSource("fsResourceProvider")
|
||||
@DisabledOnOs(WINDOWS)
|
||||
public void testSingleQuote(Class resourceClass) throws Exception
|
||||
{
|
||||
Path dir = workDir.getEmptyPathDir();
|
||||
|
@ -1002,7 +997,7 @@ public class FileSystemResourceTest
|
|||
{
|
||||
// if unable to create file, no point testing the rest.
|
||||
// this is the path that Microsoft Windows takes.
|
||||
assumeTrue(true, "Not supported on this OS");
|
||||
assumeTrue(false, "Not supported on this OS");
|
||||
}
|
||||
|
||||
try (Resource base = newResource(resourceClass, dir.toFile()))
|
||||
|
@ -1014,7 +1009,6 @@ public class FileSystemResourceTest
|
|||
|
||||
@ParameterizedTest
|
||||
@MethodSource("fsResourceProvider")
|
||||
@DisabledOnOs(WINDOWS)
|
||||
public void testSingleBackTick(Class resourceClass) throws Exception
|
||||
{
|
||||
Path dir = workDir.getEmptyPathDir();
|
||||
|
@ -1030,7 +1024,7 @@ public class FileSystemResourceTest
|
|||
{
|
||||
// if unable to create file, no point testing the rest.
|
||||
// this is the path that Microsoft Windows takes.
|
||||
assumeTrue(true, "Not supported on this OS");
|
||||
assumeTrue(false, "Not supported on this OS");
|
||||
}
|
||||
|
||||
try (Resource base = newResource(resourceClass, dir.toFile()))
|
||||
|
@ -1042,7 +1036,6 @@ public class FileSystemResourceTest
|
|||
|
||||
@ParameterizedTest
|
||||
@MethodSource("fsResourceProvider")
|
||||
@DisabledOnOs(WINDOWS)
|
||||
public void testBrackets(Class resourceClass) throws Exception
|
||||
{
|
||||
Path dir = workDir.getEmptyPathDir();
|
||||
|
@ -1058,7 +1051,7 @@ public class FileSystemResourceTest
|
|||
{
|
||||
// if unable to create file, no point testing the rest.
|
||||
// this is the path that Microsoft Windows takes.
|
||||
assumeTrue(true, "Not supported on this OS");
|
||||
assumeTrue(false, "Not supported on this OS");
|
||||
}
|
||||
|
||||
try (Resource base = newResource(resourceClass, dir.toFile()))
|
||||
|
@ -1070,7 +1063,6 @@ public class FileSystemResourceTest
|
|||
|
||||
@ParameterizedTest
|
||||
@ValueSource(classes = PathResource.class) // FileResource does not support this
|
||||
@DisabledOnOs(WINDOWS)
|
||||
public void testBraces(Class resourceClass) throws Exception
|
||||
{
|
||||
Path dir = workDir.getEmptyPathDir();
|
||||
|
@ -1086,7 +1078,7 @@ public class FileSystemResourceTest
|
|||
{
|
||||
// if unable to create file, no point testing the rest.
|
||||
// this is the path that Microsoft Windows takes.
|
||||
assumeTrue(true, "Not supported on this OS");
|
||||
assumeTrue(false, "Not supported on this OS");
|
||||
}
|
||||
|
||||
try (Resource base = newResource(resourceClass, dir.toFile()))
|
||||
|
@ -1098,7 +1090,6 @@ public class FileSystemResourceTest
|
|||
|
||||
@ParameterizedTest
|
||||
@ValueSource(classes = PathResource.class) // FileResource does not support this
|
||||
@DisabledOnOs(WINDOWS)
|
||||
public void testCaret(Class resourceClass) throws Exception
|
||||
{
|
||||
Path dir = workDir.getEmptyPathDir();
|
||||
|
@ -1114,7 +1105,7 @@ public class FileSystemResourceTest
|
|||
{
|
||||
// if unable to create file, no point testing the rest.
|
||||
// this is the path that Microsoft Windows takes.
|
||||
assumeTrue(true, "Not supported on this OS");
|
||||
assumeTrue(false, "Not supported on this OS");
|
||||
}
|
||||
|
||||
try (Resource base = newResource(resourceClass, dir.toFile()))
|
||||
|
@ -1126,7 +1117,6 @@ public class FileSystemResourceTest
|
|||
|
||||
@ParameterizedTest
|
||||
@ValueSource(classes = PathResource.class) // FileResource does not support this
|
||||
@DisabledOnOs(WINDOWS)
|
||||
public void testPipe(Class resourceClass) throws Exception
|
||||
{
|
||||
Path dir = workDir.getEmptyPathDir();
|
||||
|
@ -1142,7 +1132,7 @@ public class FileSystemResourceTest
|
|||
{
|
||||
// if unable to create file, no point testing the rest.
|
||||
// this is the path that Microsoft Windows takes.
|
||||
assumeTrue(true, "Not supported on this OS");
|
||||
assumeTrue(false, "Not supported on this OS");
|
||||
}
|
||||
|
||||
try (Resource base = newResource(resourceClass, dir.toFile()))
|
||||
|
@ -1504,7 +1494,7 @@ public class FileSystemResourceTest
|
|||
// if unable to create file, no point testing the rest.
|
||||
// this is the path that occurs if you have a system that doesn't support UTF-8
|
||||
// directory names (or you simply don't have a Locale set properly)
|
||||
assumeTrue(true, "Not supported on this OS");
|
||||
assumeTrue(false, "Not supported on this OS");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.io.InputStream;
|
|||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.stream.Stream;
|
||||
|
@ -34,7 +35,6 @@ import org.eclipse.jetty.util.IO;
|
|||
import org.hamcrest.Matchers;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||
import org.junit.jupiter.api.condition.EnabledOnOs;
|
||||
import org.junit.jupiter.api.condition.OS;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
|
@ -48,6 +48,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||
|
||||
public class ResourceTest
|
||||
{
|
||||
|
@ -292,15 +293,23 @@ public class ResourceTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisabledOnOs(OS.WINDOWS) // this uses forbidden characters on some Windows Environments
|
||||
public void testGlobPath() throws IOException
|
||||
{
|
||||
Path testDir = MavenTestingUtils.getTargetTestingPath("testGlobPath");
|
||||
FS.ensureEmpty(testDir);
|
||||
|
||||
String globReference = testDir.toAbsolutePath().toString() + File.separator + '*';
|
||||
Resource globResource = Resource.newResource(globReference);
|
||||
assertNotNull(globResource, "Should have produced a Resource");
|
||||
try
|
||||
{
|
||||
String globReference = testDir.toAbsolutePath() + File.separator + '*';
|
||||
Resource globResource = Resource.newResource(globReference);
|
||||
assertNotNull(globResource, "Should have produced a Resource");
|
||||
}
|
||||
catch (InvalidPathException e)
|
||||
{
|
||||
// if unable to reference the glob file, no point testing the rest.
|
||||
// this is the path that Microsoft Windows takes.
|
||||
assumeTrue(true, "Not supported on this OS");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -210,7 +210,7 @@ public class DistributionTests extends AbstractDistributionTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisabledOnOs(OS.WINDOWS) // jnr not supported on windows
|
||||
@DisabledOnOs(value = OS.WINDOWS, disabledReason = "jnr not supported on windows")
|
||||
public void testUnixSocket() throws Exception
|
||||
{
|
||||
Path tmpSockFile;
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
|
||||
package org.eclipse.jetty.test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.FileSystemException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
@ -39,23 +41,24 @@ import org.eclipse.jetty.server.SecureRequestCustomizer;
|
|||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.SslConnectionFactory;
|
||||
import org.eclipse.jetty.toolchain.test.FS;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
|
||||
import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.eclipse.jetty.util.log.StacklessLogging;
|
||||
import org.eclipse.jetty.util.ssl.KeyStoreScanner;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.condition.OS.WINDOWS;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeFalse;
|
||||
|
||||
@ExtendWith(WorkDirExtension.class)
|
||||
public class KeyStoreScannerTest
|
||||
|
@ -112,7 +115,7 @@ public class KeyStoreScannerTest
|
|||
@AfterEach
|
||||
public void stop() throws Exception
|
||||
{
|
||||
server.stop();
|
||||
LifeCycle.stop(server);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -181,9 +184,9 @@ public class KeyStoreScannerTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisabledOnOs(WINDOWS) // does not support symbolic link
|
||||
public void testReloadChangingSymbolicLink() throws Exception
|
||||
{
|
||||
assumeFileSystemSupportsSymlink();
|
||||
Path keystorePath = keystoreDir.resolve("symlinkKeystore");
|
||||
start(sslContextFactory ->
|
||||
{
|
||||
|
@ -208,9 +211,9 @@ public class KeyStoreScannerTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisabledOnOs(WINDOWS) // does not support symbolic link
|
||||
public void testReloadChangingTargetOfSymbolicLink() throws Exception
|
||||
{
|
||||
assumeFileSystemSupportsSymlink();
|
||||
Path keystoreLink = keystoreDir.resolve("symlinkKeystore");
|
||||
Path oldKeystoreSrc = MavenTestingUtils.getTestResourcePathFile("oldKeystore");
|
||||
Path newKeystoreSrc = MavenTestingUtils.getTestResourcePathFile("newKeystore");
|
||||
|
@ -278,6 +281,28 @@ public class KeyStoreScannerTest
|
|||
return (X509Certificate)certs[0];
|
||||
}
|
||||
|
||||
private void assumeFileSystemSupportsSymlink() throws IOException
|
||||
{
|
||||
// Make symlink
|
||||
Path dir = MavenTestingUtils.getTargetTestingPath("symlink-test");
|
||||
FS.ensureEmpty(dir);
|
||||
|
||||
Path foo = dir.resolve("foo");
|
||||
Path bar = dir.resolve("bar");
|
||||
|
||||
try
|
||||
{
|
||||
Files.createFile(foo);
|
||||
Files.createSymbolicLink(bar, foo);
|
||||
}
|
||||
catch (UnsupportedOperationException | FileSystemException e)
|
||||
{
|
||||
// if unable to create symlink, no point testing the rest
|
||||
// this is the path that Microsoft Windows takes.
|
||||
assumeFalse(true, "Not supported");
|
||||
}
|
||||
}
|
||||
|
||||
private static class DefaultTrustManager implements X509TrustManager
|
||||
{
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue