use of org.apache.catalina.WebResource in project tomcat by apache.
the class AbstractTestResourceSet method testGetResourceDirA.
@Test
public final void testGetResourceDirA() {
WebResource webResource = resourceRoot.getResource(getMount() + "/d1");
Assert.assertTrue(webResource.isDirectory());
Assert.assertEquals("d1", webResource.getName());
Assert.assertEquals(getMount() + "/d1/", webResource.getWebappPath());
Assert.assertEquals(-1, webResource.getContentLength());
Assert.assertNull(webResource.getContent());
Assert.assertNull(webResource.getInputStream());
}
use of org.apache.catalina.WebResource in project tomcat by apache.
the class AbstractTestResourceSet method testGetManifest.
// ----------------------------------------------------------- getManifest()
@Test
public final void testGetManifest() {
WebResource exists = resourceRoot.getResource(getMount() + "/d1/d1-f1.txt");
boolean manifestExists = resourceRoot.getResource("/META-INF/MANIFEST.MF").exists();
Manifest m = exists.getManifest();
if (getMount().equals("") && manifestExists) {
Assert.assertNotNull(m);
} else {
Assert.assertNull(m);
}
}
use of org.apache.catalina.WebResource in project tomcat by apache.
the class AbstractTestResourceSet method doTestGetResourceRoot.
private void doTestGetResourceRoot(boolean slash) {
String mount = getMount();
if (!slash && mount.length() == 0) {
return;
}
mount = mount + (slash ? "/" : "");
WebResource webResource = resourceRoot.getResource(mount);
Assert.assertTrue(webResource.isDirectory());
String expected;
if (getMount().length() > 0) {
expected = getMount().substring(1);
} else {
expected = "";
}
Assert.assertEquals(expected, webResource.getName());
Assert.assertEquals(mount + (!slash ? "/" : ""), webResource.getWebappPath());
}
use of org.apache.catalina.WebResource in project tomcat by apache.
the class AbstractTestResourceSet method testGetCanonicalPathExists.
// ------------------------------------------------------ getCanonicalPath()
@Test
public final void testGetCanonicalPathExists() {
WebResource exists = resourceRoot.getResource(getMount() + "/d1/d1-f1.txt");
String existsCanonicalPath = exists.getCanonicalPath();
URL existsUrl = exists.getURL();
if ("file".equals(existsUrl.getProtocol())) {
// Should have a canonical path
Assert.assertNotNull(existsCanonicalPath);
} else {
Assert.assertNull(existsCanonicalPath);
}
}
use of org.apache.catalina.WebResource in project tomcat by apache.
the class AbstractTestResourceSet method testGetResourceTraversal.
@Test
public final void testGetResourceTraversal() {
WebResource webResource = null;
try {
webResource = resourceRoot.getResource(getMount() + "/../");
} catch (IllegalArgumentException iae) {
// Expected if mount point is zero length
Assert.assertTrue(getMount().length() == 0);
return;
}
Assert.assertFalse(webResource.exists());
}
Aggregations