use of org.eclipse.jetty.util.resource.Resource in project jetty.project by eclipse.
the class ContextHandlerGetResourceTest method testDeep.
@Test
public void testDeep() throws Exception {
final String path = "/subdir/data.txt";
Resource resource = context.getResource(path);
assertEquals("data.txt", resource.getFile().getName());
assertEquals(docroot, resource.getFile().getParentFile().getParentFile());
assertTrue(resource.exists());
URL url = context.getServletContext().getResource(path);
assertEquals(docroot, new File(url.toURI()).getParentFile().getParentFile());
}
use of org.eclipse.jetty.util.resource.Resource in project jetty.project by eclipse.
the class ContextHandlerGetResourceTest method testSubdir.
@Test
public void testSubdir() throws Exception {
final String path = "/subdir";
Resource resource = context.getResource(path);
assertEquals(docroot, resource.getFile().getParentFile());
assertTrue(resource.exists());
assertTrue(resource.isDirectory());
assertTrue(resource.toString().endsWith("/"));
URL url = context.getServletContext().getResource(path);
assertEquals(docroot, new File(url.toURI()).getParentFile());
}
use of org.eclipse.jetty.util.resource.Resource in project jetty.project by eclipse.
the class ContextHandlerGetResourceTest method testGetUnknownDir.
@Test
public void testGetUnknownDir() throws Exception {
final String path = "/unknown/";
Resource resource = context.getResource(path);
assertEquals("unknown", resource.getFile().getName());
assertEquals(docroot, resource.getFile().getParentFile());
assertFalse(resource.exists());
URL url = context.getServletContext().getResource(path);
assertNull(url);
}
use of org.eclipse.jetty.util.resource.Resource in project jetty.project by eclipse.
the class ContextHandlerGetResourceTest method testSymlinkNested.
@Test
public void testSymlinkNested() throws Exception {
Assume.assumeTrue(OS.IS_UNIX);
try {
allowSymlinks.set(true);
final String path = "/web/logs/file.log";
Resource resource = context.getResource(path);
assertNotNull(resource);
assertEquals("file.log", resource.getFile().getName());
assertTrue(resource.exists());
} finally {
allowSymlinks.set(false);
}
}
use of org.eclipse.jetty.util.resource.Resource in project jetty.project by eclipse.
the class ContextHandlerGetResourceTest method testEncodedSlash.
@Test
public void testEncodedSlash() throws Exception {
final String path = "/subdir%2Fdata.txt";
Resource resource = context.getResource(path);
assertEquals("subdir%2Fdata.txt", resource.getFile().getName());
assertEquals(docroot, resource.getFile().getParentFile());
assertFalse(resource.exists());
URL url = context.getServletContext().getResource(path);
assertNull(url);
}
Aggregations