diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/BufferUtilTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/BufferUtilTest.java index 7c7a038dd4d..89a1f7e6470 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/BufferUtilTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/BufferUtilTest.java @@ -19,6 +19,12 @@ package org.eclipse.jetty.util; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileWriter; @@ -35,12 +41,6 @@ import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - public class BufferUtilTest { @Test @@ -346,7 +346,7 @@ public class BufferUtilTest String data="Now is the time for all good men to come to the aid of the party"; File file = File.createTempFile("test",".txt"); file.deleteOnExit(); - try(FileWriter out = new FileWriter(file);) + try(FileWriter out = new FileWriter(file)) { out.write(data); } diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/RolloverFileOutputStreamTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/RolloverFileOutputStreamTest.java index 9fa00057c4c..56947e9e3fb 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/RolloverFileOutputStreamTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/RolloverFileOutputStreamTest.java @@ -37,7 +37,6 @@ import java.util.concurrent.TimeUnit; import org.eclipse.jetty.toolchain.test.FS; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; -import org.eclipse.jetty.util.resource.ResourceTest; import org.hamcrest.Matchers; import org.junit.Test; @@ -182,9 +181,9 @@ public class RolloverFileOutputStreamTest } @Test - public void testFilehandling() throws Exception + public void testFileHandling() throws Exception { - File testDir = MavenTestingUtils.getTargetTestingDir(ResourceTest.class.getName()); + File testDir = MavenTestingUtils.getTargetTestingDir(RolloverFileOutputStreamTest.class.getName() + "_testFileHandling"); Path testPath = testDir.toPath(); FS.ensureEmpty(testDir); @@ -290,7 +289,7 @@ public class RolloverFileOutputStreamTest @Test public void testRollover() throws Exception { - File testDir = MavenTestingUtils.getTargetTestingDir(ResourceTest.class.getName()); + File testDir = MavenTestingUtils.getTargetTestingDir(RolloverFileOutputStreamTest.class.getName() + "_testRollover"); FS.ensureEmpty(testDir); ZoneId zone = toZoneId("Australia/Sydney"); diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/TypeUtilTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/TypeUtilTest.java index 032cae7c313..d7085b9c77f 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/TypeUtilTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/TypeUtilTest.java @@ -19,14 +19,16 @@ package org.eclipse.jetty.util; -import org.eclipse.jetty.toolchain.test.JDK; -import org.hamcrest.Matchers; -import org.junit.Assert; -import org.junit.Test; +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertThat; import java.nio.file.Path; import java.nio.file.Paths; +import org.eclipse.jetty.toolchain.test.JDK; +import org.junit.Assert; +import org.junit.Test; + public class TypeUtilTest { @Test @@ -129,18 +131,19 @@ public class TypeUtilTest public void testGetLocationOfClass() throws Exception { Path mavenRepoPath = Paths.get( System.getProperty( "mavenRepoPath" ) ); - String mavenRepo = mavenRepoPath.toFile().getPath(); + String mavenRepo = mavenRepoPath.toFile().getPath().replaceAll("\\\\", "/"); + // Classes from maven dependencies - Assert.assertThat(TypeUtil.getLocationOfClass(Assert.class).toASCIIString(),Matchers.containsString(mavenRepo)); + assertThat(TypeUtil.getLocationOfClass(Assert.class).toASCIIString(),containsString(mavenRepo)); // Class from project dependencies - Assert.assertThat(TypeUtil.getLocationOfClass(TypeUtil.class).toASCIIString(),Matchers.containsString("/classes/")); + assertThat(TypeUtil.getLocationOfClass(TypeUtil.class).toASCIIString(),containsString("/classes/")); // Class from JVM core String expectedJavaBase = "/rt.jar"; if(JDK.IS_9) expectedJavaBase = "/java.base/"; - Assert.assertThat(TypeUtil.getLocationOfClass(String.class).toASCIIString(),Matchers.containsString(expectedJavaBase)); + assertThat(TypeUtil.getLocationOfClass(String.class).toASCIIString(),containsString(expectedJavaBase)); } } diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/FileSystemResourceTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/FileSystemResourceTest.java index f1e3e16316b..68b8d28266a 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/FileSystemResourceTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/FileSystemResourceTest.java @@ -1404,13 +1404,12 @@ public class FileSystemResourceTest assumeTrue("Only windows supports UNC paths", OS.IS_WINDOWS); assumeFalse("FileResource does not support this test", _class.equals(FileResource.class)); - try (Resource base = newResource(URI.create("file://127.0.0.1/path"))) + try (Resource base = newResource(URI.create("file:////127.0.0.1/path"))) { Resource resource = base.addPath("WEB-INF/"); assertThat("getURI()", resource.getURI().toASCIIString(), containsString("path/WEB-INF/")); - assertThat("isAlias()", resource.isAlias(), is(true)); - assertThat("getAlias()", resource.getAlias(), notNullValue()); - assertThat("getAlias()", resource.getAlias().toASCIIString(), containsString("path/WEB-INF")); + assertThat("isAlias()", resource.isAlias(), is(false)); + assertThat("getAlias()", resource.getAlias(), nullValue()); } } } diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java index 3937d97a248..f978024bf4d 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java @@ -196,8 +196,9 @@ public class ResourceTest File testDir = MavenTestingUtils.getTargetTestingDir(ResourceTest.class.getName()); FS.ensureEmpty(testDir); - File tmpFile = File.createTempFile("test",null,testDir); - + File tmpFile = new File(testDir, "test.tmp"); + FS.touch(tmpFile); + cases.addCase(new Data(tmpFile.toString(),EXISTS,!DIR)); // Some resource references.