use of org.apache.catalina.WebResource in project tomcat by apache.
the class AbstractTestResourceSet method testWriteDirA.
@Test
public final void testWriteDirA() {
WebResource d1 = resourceRoot.getResource(getMount() + "/d1");
InputStream is = new ByteArrayInputStream("test".getBytes());
if (d1.exists()) {
Assert.assertFalse(resourceRoot.write(getMount() + "/d1", is, false));
} else if (d1.isVirtual()) {
Assert.assertTrue(resourceRoot.write(getMount() + "/d1", is, false));
File file = new File(getBaseDir(), "d1");
Assert.assertTrue(file.exists());
Assert.assertTrue(file.delete());
} else {
Assert.fail("Unhandled condition in unit test");
}
}
use of org.apache.catalina.WebResource in project tomcat by apache.
the class AbstractTestResourceSet method testGetResourceCaseSensitive.
@Test
public final void testGetResourceCaseSensitive() {
WebResource webResource = resourceRoot.getResource(getMount() + "/d1/d1-F1.txt");
Assert.assertFalse(webResource.exists());
}
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());
}
Aggregations