use of org.apache.catalina.WebResource in project tomcat by apache.
the class AbstractTestResourceSetMount method testGetResourceAbove.
@Test
public final void testGetResourceAbove() {
WebResource webResource = resourceRoot.getResource("/");
Assert.assertFalse(webResource.exists());
}
use of org.apache.catalina.WebResource in project tomcat by apache.
the class TestAbstractArchiveResource method testNestedJarGetURL.
@Test
public void testNestedJarGetURL() throws Exception {
Tomcat tomcat = getTomcatInstance();
File docBase = new File("test/webresources/war-url-connection.war");
Context ctx = tomcat.addWebapp("/test", docBase.getAbsolutePath());
skipTldsForResourceJars(ctx);
((StandardHost) tomcat.getHost()).setUnpackWARs(false);
tomcat.start();
WebResource webResource = ctx.getResources().getClassLoaderResource("/META-INF/resources/index.html");
StringBuilder expectedURL = new StringBuilder("jar:war:");
expectedURL.append(docBase.getAbsoluteFile().toURI().toURL().toString());
expectedURL.append("*/WEB-INF/lib/test.jar!/META-INF/resources/index.html");
Assert.assertEquals(expectedURL.toString(), webResource.getURL().toString());
}
use of org.apache.catalina.WebResource in project tomcat by apache.
the class TestJarInputStreamWrapper method getWrappedClosedInputStream.
private InputStream getWrappedClosedInputStream() throws IOException {
StandardRoot root = new StandardRoot();
root.setCachingAllowed(false);
JarResourceSet jarResourceSet = new JarResourceSet(root, "/", "test/webresources/non-static-resources.jar", "/");
WebResource webResource = jarResourceSet.getResource("/META-INF/MANIFEST.MF");
InputStream wrapped = webResource.getInputStream();
wrapped.close();
return wrapped;
}
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 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");
}
}
Aggregations