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 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 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.getCanonicalFile().toURI().toURL().toString());
expectedURL.append("WEB-INF/lib/test-lib.jar!/META-INF/tags/echo.tag");
Assert.assertEquals(expectedURL.toString(), webResource.getURL().toString());
}
use of org.apache.catalina.WebResource in project tomcat by apache.
the class TestAbstractArchiveResourceSet method testBloomFilterWithDirectory.
/*
* https://bz.apache.org/bugzilla/show_bug.cgi?id=65586
*/
@Test
public void testBloomFilterWithDirectory() {
WebResourceRoot root = new TesterWebResourceRoot();
root.getContext().setUseBloomFilterForArchives(true);
File file = new File("webapps/examples/WEB-INF/lib/taglibs-standard-impl-1.2.5-migrated-0.0.1.jar");
JarResourceSet jarResourceSet = new JarResourceSet(root, "/WEB-INF/classes", file.getAbsolutePath(), "/");
jarResourceSet.getArchiveEntries(false);
WebResource r1 = jarResourceSet.getResource("/WEB-INF/classes/org/");
Assert.assertTrue(r1.isDirectory());
WebResource r2 = jarResourceSet.getResource("/WEB-INF/classes/org");
Assert.assertTrue(r2.isDirectory());
}
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);
}
}
Aggregations