Setting up junit Assume on OS Alias / Alternate Filename Reference support.

+ Windows 8 no longer supports the 8.3 alternate filename reference techniques, rendering the test cases for this behavior no longer valid.
This commit is contained in:
Joakim Erdfelt 2014-04-30 09:00:18 -07:00 committed by Simone Bordet
parent a405454276
commit 1956ceffde
1 changed files with 10 additions and 4 deletions

View File

@ -33,14 +33,17 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
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.OS; import org.eclipse.jetty.toolchain.test.OS;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.Resource;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Assume;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
public class ContextHandlerGetResourceTest public class ContextHandlerGetResourceTest
{ {
private static boolean OS_ALIAS_SUPPORTED;
private static Server server; private static Server server;
private static ContextHandler context; private static ContextHandler context;
private static File docroot; private static File docroot;
@ -51,8 +54,9 @@ public class ContextHandlerGetResourceTest
@BeforeClass @BeforeClass
public static void beforeClass() throws Exception public static void beforeClass() throws Exception
{ {
docroot = new File("target/tests/docroot").getCanonicalFile().getAbsoluteFile(); File testRoot = MavenTestingUtils.getTargetTestingDir(ContextHandlerGetResourceTest.class.getSimpleName());
FS.ensureDirExists(docroot); FS.ensureEmpty(testRoot);
docroot = new File(testRoot,"docroot").getCanonicalFile().getAbsoluteFile();
FS.ensureEmpty(docroot); FS.ensureEmpty(docroot);
File index = new File(docroot,"index.html"); File index = new File(docroot,"index.html");
index.createNewFile(); index.createNewFile();
@ -63,8 +67,7 @@ public class ContextHandlerGetResourceTest
File verylong = new File(sub,"TextFile.Long.txt"); File verylong = new File(sub,"TextFile.Long.txt");
verylong.createNewFile(); verylong.createNewFile();
otherroot = new File("target/tests/otherroot").getCanonicalFile().getAbsoluteFile(); otherroot = new File(testRoot, "otherroot").getCanonicalFile().getAbsoluteFile();
FS.ensureDirExists(otherroot);
FS.ensureEmpty(otherroot); FS.ensureEmpty(otherroot);
File other = new File(otherroot,"other.txt"); File other = new File(otherroot,"other.txt");
other.createNewFile(); other.createNewFile();
@ -83,6 +86,7 @@ public class ContextHandlerGetResourceTest
Files.createSymbolicLink(transit.toPath(),otherroot.toPath()); Files.createSymbolicLink(transit.toPath(),otherroot.toPath());
} }
OS_ALIAS_SUPPORTED = new File(sub, "TEXTFI~1.TXT").exists();
server = new Server(); server = new Server();
context =new ContextHandler("/"); context =new ContextHandler("/");
@ -313,6 +317,7 @@ public class ContextHandlerGetResourceTest
@Test @Test
public void testAliasedFile() throws Exception public void testAliasedFile() throws Exception
{ {
Assume.assumeTrue("OS Supports 8.3 Aliased / Alternate References",OS_ALIAS_SUPPORTED);
final String path="/subdir/TEXTFI~1.TXT"; final String path="/subdir/TEXTFI~1.TXT";
Resource resource=context.getResource(path); Resource resource=context.getResource(path);
@ -325,6 +330,7 @@ public class ContextHandlerGetResourceTest
@Test @Test
public void testAliasedFileAllowed() throws Exception public void testAliasedFileAllowed() throws Exception
{ {
Assume.assumeTrue("OS Supports 8.3 Aliased / Alternate References",OS_ALIAS_SUPPORTED);
try try
{ {
allowAliases.set(true); allowAliases.set(true);