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

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

      
    
Rootfs path

      
    
Size
3483 (3.4 KB)
MD5
83241cf2a822b47411ae1586e6218cc2
SHA1
58f167bcdb60838649173f4297305db5d448f350
SHA256
c3273020af55db80331b2c6a8fcc139a3e0738f3dd4d0977a9603fe29d6a0e94
SHA512

      
    
SHA1_git
53a3eb55f8b06706a81ec7d4ed9d223ffd83d6dc
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestJarContents.java | 3.4 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.util.jar.JarFile; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.apache.catalina.WebResourceSet; public class TestJarContents { private static File empty; private static File jar; private static TesterWebResourceRoot root; private static WebResourceSet webResourceSet; private static JarResourceSet test; private static JarContents testJarContentsObject; @BeforeClass public static void setup() { try { empty = new File("test/webresources/dir3"); jar = new File("test/webresources/dir1.jar"); root = new TesterWebResourceRoot(); // Use empty dir for root of web app. webResourceSet = new DirResourceSet(root, "/", empty.getAbsolutePath(), "/"); root.setMainResources(webResourceSet); // If this JAR was in a web application, this is equivalent to how it // would be added test = new JarResourceSet(root, "/", jar.getAbsolutePath(), "/META-INF/resources"); test.setStaticOnly(true); root.addJarResources(test); testJarContentsObject = new JarContents(new JarFile("test/webresources/dir1.jar")); } catch (Exception e) { Assert.fail("Error happened while testing JarContents, " + e.getMessage()); } } @Test public void testMightContainResource() { Assert.assertTrue(testJarContentsObject.mightContainResource( "/d1/d1-f1.txt", jar.getAbsolutePath())); Assert.assertTrue(testJarContentsObject.mightContainResource( "d1/d1-f1.txt", jar.getAbsolutePath())); Assert.assertTrue(testJarContentsObject.mightContainResource( "f9.txt", jar.getAbsolutePath())); Assert.assertFalse(testJarContentsObject.mightContainResource( "/d7/d1-f1.txt", jar.getAbsolutePath())); Assert.assertFalse(testJarContentsObject.mightContainResource( "/", jar.getAbsolutePath())); Assert.assertFalse(testJarContentsObject.mightContainResource( "/////", jar.getAbsolutePath())); } @Test(expected = StringIndexOutOfBoundsException.class) public void testStringOutOfBoundExceptions() { testJarContentsObject.mightContainResource("", jar.getAbsolutePath()); } @Test(expected = NullPointerException.class) public void testNullPointerExceptions() { testJarContentsObject.mightContainResource(null, jar.getAbsolutePath()); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
34.8
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