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());
}
use of org.apache.catalina.WebResource in project tomcat by apache.
the class TestAbstractArchiveResource method testJarGetURL.
@Test
public void testJarGetURL() throws Exception {
Tomcat tomcat = getTomcatInstance();
File docBase = new File("test/webapp");
Context ctx = tomcat.addWebapp("/test", docBase.getAbsolutePath());
skipTldsForResourceJars(ctx);
((StandardHost) tomcat.getHost()).setUnpackWARs(false);
tomcat.start();
WebResource webResource = ctx.getResources().getClassLoaderResource("/META-INF/tags/echo.tag");
StringBuilder expectedURL = new StringBuilder("jar:");
expectedURL.append(docBase.getAbsoluteFile().toURI().toURL().toString());
expectedURL.append("WEB-INF/lib/test-lib.jar!/META-INF/tags/echo.tag");
Assert.assertEquals(expectedURL.toString(), webResource.getURL().toString());
}
Aggregations