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

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

      
    
Rootfs path

      
    
Size
3339 (3.3 KB)
MD5
89fb1c53b14d01d980d2fd654a2bce2f
SHA1
50b43fc12004133abd8cc0e8623c72785d5c8af6
SHA256
b21687804de2e5a765d037bce140e284607cd090327fceba61b3da59a0311e81
SHA512

      
    
SHA1_git
eb904f9367cb400c13df503c93aa9a944fa6fef9
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestStandardRoot.java | 3.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.net.MalformedURLException; import java.net.URI; import java.net.URL; import org.junit.Assert; import org.junit.Test; import org.apache.catalina.WebResourceRoot; import org.apache.catalina.webresources.StandardRoot.BaseLocation; public class TestStandardRoot { private static final File file; private static final String fileUrl; static { file = new File("/foo"); String url = null; try { url = file.toURI().toURL().toExternalForm(); } catch (MalformedURLException e) { // Ignore } fileUrl = url; } @Test public void testBaseLocation01() throws Exception { doTestBaseLocation(URI.create(fileUrl).toURL(), file.getAbsolutePath(), null); } @Test public void testBaseLocation02() throws Exception { doTestBaseLocation(URI.create("jar:" + fileUrl + "!/").toURL(), file.getAbsolutePath(), null); } @Test public void testBaseLocation03() throws Exception { doTestBaseLocation(URI.create("jar:" + fileUrl + "!/bar").toURL(), file.getAbsolutePath(), "bar"); } @Test public void testBaseLocation04() throws Exception { doTestBaseLocation(URI.create("jar:" + fileUrl + "!/bar/bar").toURL(), file.getAbsolutePath(), "bar/bar"); } @Test(expected=IllegalArgumentException.class) public void testBaseLocation05() throws Exception { doTestBaseLocation(URI.create("http://localhost:8080/foo").toURL(), null, null); } private void doTestBaseLocation(URL url, String expectedBasePath, String expectedArchivePath) { BaseLocation baseLocation = new BaseLocation(url); Assert.assertEquals(expectedBasePath, baseLocation.getBasePath()); Assert.assertEquals(expectedArchivePath, baseLocation.getArchivePath()); } @Test public void testArchiveIndexStrategy() { WebResourceRoot root = new StandardRoot(); root.setArchiveIndexStrategy(WebResourceRoot.ArchiveIndexStrategy.BLOOM.name()); Assert.assertEquals(WebResourceRoot.ArchiveIndexStrategy.BLOOM.name(), root.getArchiveIndexStrategy()); } @Test(expected = IllegalArgumentException.class) public void testArchiveIndexStrategyUnrecognized() { WebResourceRoot root = new StandardRoot(); root.setArchiveIndexStrategy("UNRECOGNIZED"); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
35.84
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