Improving test reliability (esp on Windows)
This commit is contained in:
parent
f297096716
commit
e65d0ba0e7
|
@ -19,6 +19,12 @@
|
||||||
package org.eclipse.jetty.util;
|
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.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
|
@ -35,12 +41,6 @@ import org.junit.Assert;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
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
|
public class BufferUtilTest
|
||||||
{
|
{
|
||||||
@Test
|
@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";
|
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 file = File.createTempFile("test",".txt");
|
||||||
file.deleteOnExit();
|
file.deleteOnExit();
|
||||||
try(FileWriter out = new FileWriter(file);)
|
try(FileWriter out = new FileWriter(file))
|
||||||
{
|
{
|
||||||
out.write(data);
|
out.write(data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ import java.util.TimeZone;
|
||||||
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.TestingDir;
|
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -166,7 +166,7 @@ public class RolloverFileOutputStreamTest
|
||||||
@Test
|
@Test
|
||||||
public void testFileHandling() throws Exception
|
public void testFileHandling() throws Exception
|
||||||
{
|
{
|
||||||
File testDir = testingDir.getEmptyPathDir().toFile();
|
File testDir = MavenTestingUtils.getTargetTestingDir(RolloverFileOutputStreamTest.class.getName() + "_testFileHandling");
|
||||||
Path testPath = testDir.toPath();
|
Path testPath = testDir.toPath();
|
||||||
FS.ensureEmpty(testDir);
|
FS.ensureEmpty(testDir);
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ public class RolloverFileOutputStreamTest
|
||||||
@Test
|
@Test
|
||||||
public void testRollover() throws Exception
|
public void testRollover() throws Exception
|
||||||
{
|
{
|
||||||
File testDir = testingDir.getEmptyPathDir().toFile();
|
File testDir = MavenTestingUtils.getTargetTestingDir(RolloverFileOutputStreamTest.class.getName() + "_testRollover");
|
||||||
FS.ensureEmpty(testDir);
|
FS.ensureEmpty(testDir);
|
||||||
|
|
||||||
TimeZone zone = toZoneId("Australia/Sydney");
|
TimeZone zone = toZoneId("Australia/Sydney");
|
||||||
|
|
|
@ -19,14 +19,16 @@
|
||||||
package org.eclipse.jetty.util;
|
package org.eclipse.jetty.util;
|
||||||
|
|
||||||
|
|
||||||
import org.eclipse.jetty.toolchain.test.JDK;
|
import static org.hamcrest.CoreMatchers.containsString;
|
||||||
import org.hamcrest.Matchers;
|
import static org.junit.Assert.assertThat;
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.JDK;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TypeUtilTest
|
public class TypeUtilTest
|
||||||
{
|
{
|
||||||
@Test
|
@Test
|
||||||
|
@ -129,18 +131,19 @@ public class TypeUtilTest
|
||||||
public void testGetLocationOfClass() throws Exception
|
public void testGetLocationOfClass() throws Exception
|
||||||
{
|
{
|
||||||
Path mavenRepoPath = Paths.get( System.getProperty( "mavenRepoPath" ) );
|
Path mavenRepoPath = Paths.get( System.getProperty( "mavenRepoPath" ) );
|
||||||
String mavenRepo = mavenRepoPath.toFile().getPath();
|
String mavenRepo = mavenRepoPath.toFile().getPath().replaceAll("\\\\", "/");
|
||||||
|
|
||||||
// Classes from maven dependencies
|
// 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
|
// 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
|
// Class from JVM core
|
||||||
String expectedJavaBase = "/rt.jar";
|
String expectedJavaBase = "/rt.jar";
|
||||||
if(JDK.IS_9)
|
if(JDK.IS_9)
|
||||||
expectedJavaBase = "/java.base/";
|
expectedJavaBase = "/java.base/";
|
||||||
|
|
||||||
Assert.assertThat(TypeUtil.getLocationOfClass(String.class).toASCIIString(),Matchers.containsString(expectedJavaBase));
|
assertThat(TypeUtil.getLocationOfClass(String.class).toASCIIString(),containsString(expectedJavaBase));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1404,13 +1404,12 @@ public class FileSystemResourceTest
|
||||||
assumeTrue("Only windows supports UNC paths", OS.IS_WINDOWS);
|
assumeTrue("Only windows supports UNC paths", OS.IS_WINDOWS);
|
||||||
assumeFalse("FileResource does not support this test", _class.equals(FileResource.class));
|
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/");
|
Resource resource = base.addPath("WEB-INF/");
|
||||||
assertThat("getURI()", resource.getURI().toASCIIString(), containsString("path/WEB-INF/"));
|
assertThat("getURI()", resource.getURI().toASCIIString(), containsString("path/WEB-INF/"));
|
||||||
assertThat("isAlias()", resource.isAlias(), is(true));
|
assertThat("isAlias()", resource.isAlias(), is(false));
|
||||||
assertThat("getAlias()", resource.getAlias(), notNullValue());
|
assertThat("getAlias()", resource.getAlias(), nullValue());
|
||||||
assertThat("getAlias()", resource.getAlias().toASCIIString(), containsString("path/WEB-INF"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,8 @@ public class ResourceTest
|
||||||
|
|
||||||
File testDir = MavenTestingUtils.getTargetTestingDir(ResourceTest.class.getName());
|
File testDir = MavenTestingUtils.getTargetTestingDir(ResourceTest.class.getName());
|
||||||
FS.ensureEmpty(testDir);
|
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));
|
cases.addCase(new Data(tmpFile.toString(),EXISTS,!DIR));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue