ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/catalina/webresources/TestAbstractArchiveResourceSet.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/catalina/webresources/TestAbstractArchiveResourceSet.java
Status
scanned
Type
file
Name
TestAbstractArchiveResourceSet.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
4388 (4.3 KB)
MD5
74dcf903653b1fe641095c553744027f
SHA1
d4d8e2e43b5b1f89db770801712abbffb1d9ac16
SHA256
0706ee17ef04092978092c7092f073e9330d8bfed6ba3105b625aa6be7c39d0e
SHA512

      
    
SHA1_git
6a932590405e07e1d7e5c38971a50e0101aae0b7
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestAbstractArchiveResourceSet.java | 4.3 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.catalina.webresources; import java.io.File; import java.lang.reflect.Field; import org.junit.Assert; import org.junit.Test; import org.apache.catalina.WebResource; import org.apache.catalina.WebResourceRoot; public class TestAbstractArchiveResourceSet { /* * https://bz.apache.org/bugzilla/show_bug.cgi?id=65586 */ @Test public void testBloomFilterWithDirectoryVerifyCleanup() throws Exception { WebResourceRoot root = new TesterWebResourceRoot(); root.setArchiveIndexStrategy(WebResourceRoot.ArchiveIndexStrategy.BLOOM.name()); 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); Assert.assertNotNull(getJarContents(jarResourceSet)); WebResource r1 = jarResourceSet.getResource("/WEB-INF/classes/org/"); Assert.assertTrue(r1.isDirectory()); Assert.assertNotNull(getJarContents(jarResourceSet)); WebResource r2 = jarResourceSet.getResource("/WEB-INF/classes/org"); Assert.assertTrue(r2.isDirectory()); Assert.assertNotNull(getJarContents(jarResourceSet)); jarResourceSet.gc(); Assert.assertNotNull(getJarContents(jarResourceSet)); } @Test public void testPurgedBloomFilterWithDirectoryVerifyCleanup() throws Exception { WebResourceRoot root = new TesterWebResourceRoot(); root.setArchiveIndexStrategy(WebResourceRoot.ArchiveIndexStrategy.PURGED.name()); 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); Assert.assertNotNull(getJarContents(jarResourceSet)); WebResource r1 = jarResourceSet.getResource("/WEB-INF/classes/org/"); Assert.assertTrue(r1.isDirectory()); Assert.assertNotNull(getJarContents(jarResourceSet)); WebResource r2 = jarResourceSet.getResource("/WEB-INF/classes/org"); Assert.assertTrue(r2.isDirectory()); Assert.assertNotNull(getJarContents(jarResourceSet)); jarResourceSet.gc(); Assert.assertNull(getJarContents(jarResourceSet)); } @Test public void testBloomFilterWithJarResource() throws Exception { WebResourceRoot root = new TesterWebResourceRoot(); root.setArchiveIndexStrategy(WebResourceRoot.ArchiveIndexStrategy.BLOOM.name()); File file = new File("test/webresources/static-resources.jar"); JarResourceSet jarResourceSet = new JarResourceSet(root, "/", file.getAbsolutePath(), "/META-INF/resources"); jarResourceSet.getArchiveEntries(false); Assert.assertNotNull(getJarContents(jarResourceSet)); WebResource r1 = jarResourceSet.getResource("/index.html"); Assert.assertTrue(r1.isFile()); } private JarContents getJarContents(Object target) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { Field field = AbstractArchiveResourceSet.class.getDeclaredField("jarContents"); field.setAccessible(true); JarContents contents = (JarContents) field.get(target); return contents; } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
28.13
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9
https://bz.apache.org/bugzilla/show_bug.cgi?id=65586 31 31