ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/jasper/compiler/TestCompiler.java

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

      
    
Rootfs path

      
    
Size
6631 (6.5 KB)
MD5
84c56a2bf0d446f0ac7bdb4281bc45cf
SHA1
8557de5bc2145e359735c32bc64a026f2547d9bb
SHA256
c25370758eb324c987ab10f4a2f080a20abd016e8401b60bcfda1df38d45c3ca
SHA512

      
    
SHA1_git
372414e5c4305f8795fb92d1ba9cfebda8c228f6
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestCompiler.java | 6.5 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.jasper.compiler; import java.io.File; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.regex.Pattern; import org.junit.Assert; import org.junit.Test; import org.apache.catalina.Context; import org.apache.catalina.startup.Tomcat; import org.apache.catalina.startup.TomcatBaseTest; import org.apache.tomcat.util.buf.ByteChunk; public class TestCompiler extends TomcatBaseTest { @Test public void testBug49726a() throws Exception { getTomcatInstanceTestWebapp(false, true); ByteChunk res = new ByteChunk(); Map<String,List<String>> headers = new HashMap<>(); getUrl("http://localhost:" + getPort() + "/test/bug49nnn/bug49726a.jsp", res, headers); // Check request completed String result = res.toString(); assertEcho(result, "OK"); // Check content type String contentType = getSingleHeader("Content-Type", headers); Assert.assertTrue(contentType.startsWith("text/html")); } @Test public void testBug49726b() throws Exception { getTomcatInstanceTestWebapp(false, true); ByteChunk res = new ByteChunk(); Map<String,List<String>> headers = new HashMap<>(); getUrl("http://localhost:" + getPort() + "/test/bug49nnn/bug49726b.jsp", res, headers); // Check request completed String result = res.toString(); assertEcho(result, "OK"); // Check content type String contentType = getSingleHeader("Content-Type", headers); Assert.assertTrue(contentType.startsWith("text/plain")); } @Test public void testBug53257a() throws Exception { getTomcatInstanceTestWebapp(false, true); // foo;bar.jsp ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/bug53257/foo%3bbar.jsp"); // Check request completed String result = res.toString(); assertEcho(result, "OK"); } @Test public void testBug53257b() throws Exception { getTomcatInstanceTestWebapp(false, true); ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/bug53257/foo&bar.jsp"); // Check request completed String result = res.toString(); assertEcho(result, "OK"); } @Test public void testBug53257c() throws Exception { getTomcatInstanceTestWebapp(false, true); // foo#bar.jsp ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/bug53257/foo%23bar.jsp"); // Check request completed String result = res.toString(); assertEcho(result, "OK"); } @Test public void testBug53257d() throws Exception { getTomcatInstanceTestWebapp(false, true); // foo%bar.jsp ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/bug53257/foo%25bar.jsp"); // Check request completed String result = res.toString(); assertEcho(result, "OK"); } @Test public void testBug53257e() throws Exception { getTomcatInstanceTestWebapp(false, true); ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/bug53257/foo+bar.jsp"); // Check request completed String result = res.toString(); assertEcho(result, "OK"); } @Test public void testBug53257f() throws Exception { getTomcatInstanceTestWebapp(false, true); ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/bug53257/foo%20bar.jsp"); // Check request completed String result = res.toString(); assertEcho(result, "OK"); } @Test public void testBug53257g() throws Exception { getTomcatInstanceTestWebapp(false, true); ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/bug53257/foo%20bar/foobar.jsp"); // Check request completed String result = res.toString(); assertEcho(result, "OK"); } @Test public void testBug53257z() throws Exception { getTomcatInstanceTestWebapp(false, true); // Check that URL decoding is not done twice ByteChunk res = new ByteChunk(); int rc = getUrl("http://localhost:" + getPort() + "/test/bug53257/foo%2525bar.jsp", res, null); Assert.assertEquals(404, rc); } @Test public void testBug51584() throws Exception { Tomcat tomcat = getTomcatInstance(); File appDir = new File("test/webapp-fragments"); Context ctx = tomcat.addWebapp(null, "/test", appDir.getAbsolutePath()); skipTldsForResourceJars(ctx); tomcat.start(); // No further tests required. The bug triggers an infinite loop on // context start so the test will crash before it reaches this point if // it fails } @Test public void testBug55262() throws Exception { getTomcatInstanceTestWebapp(false, true); ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/bug5nnnn/bug55262.jsp"); String result = res.toString(); Pattern prelude = Pattern.compile("(.*This is a prelude\\.){2}.*", Pattern.MULTILINE | Pattern.DOTALL); Pattern coda = Pattern.compile("(.*This is a coda\\.){2}.*", Pattern.MULTILINE | Pattern.DOTALL); Assert.assertTrue(prelude.matcher(result).matches()); Assert.assertTrue(coda.matcher(result).matches()); } /** Assertion for text printed by tags:echo */ private static void assertEcho(String result, String expected) { Assert.assertTrue(result, result.indexOf("<p>" + expected + "</p>") > 0); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
17.45
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