Search in sources :

Example 56 with WebResource

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());
}
Also used : WebResource(org.apache.catalina.WebResource) File(java.io.File) WebResourceRoot(org.apache.catalina.WebResourceRoot) Test(org.junit.Test)

Example 57 with WebResource

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);
    }
}
Also used : WebResource(org.apache.catalina.WebResource) Manifest(java.util.jar.Manifest) Test(org.junit.Test)

Aggregations

WebResource (org.apache.catalina.WebResource)57 Test (org.junit.Test)17 File (java.io.File)12 ByteArrayInputStream (java.io.ByteArrayInputStream)11 InputStream (java.io.InputStream)11 IOException (java.io.IOException)8 URL (java.net.URL)7 BufferedInputStream (java.io.BufferedInputStream)6 InputSource (org.xml.sax.InputSource)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 FileInputStream (java.io.FileInputStream)5 OutputStreamWriter (java.io.OutputStreamWriter)5 PrintWriter (java.io.PrintWriter)4 RandomAccessFile (java.io.RandomAccessFile)4 Manifest (java.util.jar.Manifest)4 StreamSource (javax.xml.transform.stream.StreamSource)3 WebResourceRoot (org.apache.catalina.WebResourceRoot)3 WebResourceSet (org.apache.catalina.WebResourceSet)3 StringReader (java.io.StringReader)2 StringWriter (java.io.StringWriter)2