ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/catalina/valves/rewrite/TestQuotedStringTokenizer.java

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

      
    
Rootfs path

      
    
Size
3091 (3.0 KB)
MD5
94919d8391a59206e3ff70b9de59e350
SHA1
bb164c9dad017c07dd3ce0b35e13e75623e66fcf
SHA256
cd09b1559d7f5e5f645acc9cad2a3673e7d3780efb50a542f7e7fc0c2be1926a
SHA512

      
    
SHA1_git
fa0c46e700f7b36474fa7aa7bd5d2e458799ff5d
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestQuotedStringTokenizer.java | 3.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.catalina.valves.rewrite; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import org.hamcrest.CoreMatchers; import org.hamcrest.MatcherAssert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @RunWith(Parameterized.class) public class TestQuotedStringTokenizer { private String inputText; private List<String> tokens; @Parameters(name = "{index}: tokenize({0}) = {1}") public static Collection<Object[]> data() { return Arrays.asList(new Object[][] { { null, Collections.emptyList() }, { "", Collections.emptyList() }, { " ", Collections.emptyList() }, { "simple", Arrays.asList("simple") }, { "more than one word", Arrays.asList("more", "than", "one", "word") }, { "\"quoted text\"", Arrays.asList("quoted text") }, { " mixed \"words with\\\"\" escapes", Arrays.asList("mixed", "words with\"", "escapes") }, { "# comment", Collections.emptyList() }, { "Something # and then a comment", Arrays.asList("Something") }, { "\"Quoted with a #\" which is not a comment", Arrays.asList("Quoted with a #", "which", "is", "not", "a", "comment") } }); } public TestQuotedStringTokenizer(String inputText, List<String> tokens) { this.inputText = inputText; this.tokens = tokens; } @Test public void testTokenize() { QuotedStringTokenizer tokenizer = new QuotedStringTokenizer(inputText); List<String> result = new ArrayList<>(); int count = tokens.size(); while (tokenizer.hasMoreTokens()) { MatcherAssert.assertThat(Integer.valueOf(tokenizer.countTokens()), CoreMatchers.is(Integer.valueOf(count))); result.add(tokenizer.nextToken()); count--; } MatcherAssert.assertThat(Integer.valueOf(tokenizer.countTokens()), CoreMatchers.is(Integer.valueOf(0))); MatcherAssert.assertThat(tokens, CoreMatchers.is(result)); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
36.28
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