ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/tomcat/util/http/parser/TestHttpParser.java

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

      
    
Rootfs path

      
    
Size
5144 (5.0 KB)
MD5
f124b8dcb6e1a08aba31028e901c842d
SHA1
5f4217d26c3b732c478dae857729c782dc8ccc66
SHA256
36655f779fc0a442fd4e92366d08b3a663d54e1188b3ab37d6b1efa14e9e152d
SHA512

      
    
SHA1_git
60f00e17f266da02047e922704ca361cdc7c5529
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestHttpParser.java | 5.0 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.tomcat.util.http.parser; import org.junit.Assert; import org.junit.Test; public class TestHttpParser { @Test public void testTokenDel() { Assert.assertFalse("DEL is not a token", HttpParser.isToken(127)); } @Test public void testAbsolutePathRelaxedLargeInvalid() { HttpParser httpParser = new HttpParser(null, null); Assert.assertFalse(httpParser.isAbsolutePathRelaxed(Integer.MAX_VALUE)); } @Test public void testAbsolutePathRelaxed01() { HttpParser httpParser = new HttpParser(null, null); Assert.assertFalse(httpParser.isAbsolutePathRelaxed('{')); } @Test public void testAbsolutePathRelaxed02() { HttpParser httpParser = new HttpParser("{", null); Assert.assertTrue(httpParser.isAbsolutePathRelaxed('{')); } @Test public void testAbsolutePathRelaxed03() { HttpParser httpParser = new HttpParser(null, "{"); Assert.assertFalse(httpParser.isAbsolutePathRelaxed('{')); } @Test public void testAbsolutePathRelaxed04() { HttpParser httpParser = new HttpParser("\u1000", null); Assert.assertFalse(httpParser.isAbsolutePathRelaxed('{')); } @Test public void testAbsolutePathRelaxed05() { HttpParser httpParser = new HttpParser("", null); Assert.assertFalse(httpParser.isAbsolutePathRelaxed('{')); } @Test public void testQueryRelaxedLargeInvalid() { HttpParser httpParser = new HttpParser(null, null); Assert.assertFalse(httpParser.isQueryRelaxed(Integer.MAX_VALUE)); } @Test public void testRequestTargetLargeInvalid() { Assert.assertTrue(HttpParser.isNotRequestTarget(Integer.MAX_VALUE)); } @Test public void testHttpProtocolLargeInvalid() { Assert.assertFalse(HttpParser.isHttpProtocol(Integer.MAX_VALUE)); } @Test public void testUserInfoLargeInvalid() { Assert.assertFalse(HttpParser.isUserInfo(Integer.MAX_VALUE)); } @Test public void testAbsolutePathLargeInvalid() { Assert.assertFalse(HttpParser.isAbsolutePath(Integer.MAX_VALUE)); } @Test public void testQueryLargeInvalid() { Assert.assertFalse(HttpParser.isQuery(Integer.MAX_VALUE)); } @Test public void testUnquoteNull() { Assert.assertNull(HttpParser.unquote(null)); } @Test public void testUnquoteShort() { String shortText = "a"; Assert.assertEquals(shortText, HttpParser.unquote(shortText)); } @Test public void testUnquoteUnquoted() { String shortText = "abcde"; Assert.assertEquals(shortText, HttpParser.unquote(shortText)); } @Test public void testUnquoteEscaped() { // Note: Test string is also Java escaped String shortText = "\"ab\\\"ab\""; String result = "ab\"ab"; Assert.assertEquals(result, HttpParser.unquote(shortText)); } @Test public void testUnquoteUnquotedEscaped() { // Note: Test string is also Java escaped String shortText = "ab\\\"ab"; String result = "ab\"ab"; Assert.assertEquals(result, HttpParser.unquote(shortText)); } @Test public void testUnquoteInvalid01() { // Note: Test string is also Java escaped String shortText = "aaa\\"; Assert.assertNull(shortText, HttpParser.unquote(shortText)); } @Test public void testTokenStringNull() { Assert.assertFalse(HttpParser.isToken(null)); } @Test public void testTokenStringEmpty() { Assert.assertFalse(HttpParser.isToken("")); } @Test public void testTokenStringLws01() { Assert.assertFalse(HttpParser.isToken(" ")); } @Test public void testTokenStringLws02() { Assert.assertFalse(HttpParser.isToken(" aaa")); } @Test public void testTokenStringLws03() { Assert.assertFalse(HttpParser.isToken(" aaa")); } @Test public void testTokenStringValid() { Assert.assertTrue(HttpParser.isToken("token")); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
25.81
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