ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/tomcat/websocket/server/TestUriTemplate.java

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

      
    
Rootfs path

      
    
Size
7483 (7.3 KB)
MD5
124dca55302710de2169819459f02d02
SHA1
daede4773c58bf2bcb16bbbff5f5155be79e7832
SHA256
f60b48245676d30699b235c125838cb446fc80128e1884974a67f6dc6d356175
SHA512

      
    
SHA1_git
0f1d2f6831b079f2727a924585e7acd375a5ca88
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestUriTemplate.java | 7.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.tomcat.websocket.server; import java.util.Map; import org.junit.Assert; import org.junit.Test; public class TestUriTemplate { @Test public void testBasic() throws Exception { UriTemplate t = new UriTemplate("/{a}/{b}"); Map<String, String> result = t.match(new UriTemplate("/foo/bar")); Assert.assertEquals(2, result.size()); Assert.assertTrue(result.containsKey("a")); Assert.assertTrue(result.containsKey("b")); Assert.assertEquals("foo", result.get("a")); Assert.assertEquals("bar", result.get("b")); } @Test public void testOneOfTwo() throws Exception { UriTemplate t = new UriTemplate("/{a}/{b}"); Map<String, String> result = t.match(new UriTemplate("/foo")); Assert.assertNull(result); } @Test(expected = jakarta.websocket.DeploymentException.class) public void testBasicPrefix() throws Exception { @SuppressWarnings("unused") UriTemplate t = new UriTemplate("/x{a}/y{b}"); } @Test(expected = jakarta.websocket.DeploymentException.class) public void testPrefixOneOfTwo() throws Exception { UriTemplate t = new UriTemplate("/x{a}/y{b}"); t.match(new UriTemplate("/xfoo")); } @Test(expected = jakarta.websocket.DeploymentException.class) public void testPrefixTwoOfTwo() throws Exception { UriTemplate t = new UriTemplate("/x{a}/y{b}"); t.match(new UriTemplate("/ybar")); } @Test(expected = jakarta.websocket.DeploymentException.class) public void testQuote1() throws Exception { UriTemplate t = new UriTemplate("/.{a}"); t.match(new UriTemplate("/yfoo")); } @Test(expected = jakarta.websocket.DeploymentException.class) public void testQuote2() throws Exception { @SuppressWarnings("unused") UriTemplate t = new UriTemplate("/.{a}"); } @Test public void testNoParams() throws Exception { UriTemplate t = new UriTemplate("/foo/bar"); Map<String, String> result = t.match(new UriTemplate("/foo/bar")); Assert.assertEquals(0, result.size()); } @Test public void testSpecExample1_01() throws Exception { UriTemplate t = new UriTemplate("/a/b"); Map<String, String> result = t.match(new UriTemplate("/a/b")); Assert.assertEquals(0, result.size()); } @Test public void testSpecExample1_02() throws Exception { UriTemplate t = new UriTemplate("/a/b"); Map<String, String> result = t.match(new UriTemplate("/a")); Assert.assertNull(result); } @Test public void testSpecExample1_03() throws Exception { UriTemplate t = new UriTemplate("/a/b"); Map<String, String> result = t.match(new UriTemplate("/a/bb")); Assert.assertNull(result); } @Test public void testSpecExample2_01() throws Exception { UriTemplate t = new UriTemplate("/a/{var}"); Map<String, String> result = t.match(new UriTemplate("/a/b")); Assert.assertEquals(1, result.size()); Assert.assertEquals("b", result.get("var")); } @Test public void testSpecExample2_02() throws Exception { UriTemplate t = new UriTemplate("/a/{var}"); Map<String, String> result = t.match(new UriTemplate("/a/apple")); Assert.assertEquals(1, result.size()); Assert.assertEquals("apple", result.get("var")); } @Test public void testSpecExample2_03() throws Exception { UriTemplate t = new UriTemplate("/a/{var}"); Map<String, String> result = t.match(new UriTemplate("/a")); Assert.assertNull(result); } @Test public void testSpecExample2_04() throws Exception { UriTemplate t = new UriTemplate("/a/{var}"); Map<String, String> result = t.match(new UriTemplate("/a/b/c")); Assert.assertNull(result); } @Test(expected = jakarta.websocket.DeploymentException.class) public void testDuplicate01() throws Exception { @SuppressWarnings("unused") UriTemplate t = new UriTemplate("/{var}/{var}"); } @Test public void testDuplicate02() throws Exception { UriTemplate t = new UriTemplate("/{a}/{b}"); Map<String, String> result = t.match(new UriTemplate("/x/x")); Assert.assertEquals(2, result.size()); Assert.assertEquals("x", result.get("a")); Assert.assertEquals("x", result.get("b")); } public void testEgMailingList01() throws Exception { UriTemplate t = new UriTemplate("/a/{var}"); Map<String, String> result = t.match(new UriTemplate("/a/b/")); Assert.assertNull(result); } public void testEgMailingList02() throws Exception { UriTemplate t = new UriTemplate("/a/{var}"); Map<String, String> result = t.match(new UriTemplate("/a/")); Assert.assertNull(result); } @Test public void testEgMailingList03() throws Exception { UriTemplate t = new UriTemplate("/a/{var}"); Map<String, String> result = t.match(new UriTemplate("/a")); Assert.assertNull(result); } @Test(expected = jakarta.websocket.DeploymentException.class) public void testEgMailingList04() throws Exception { UriTemplate t = new UriTemplate("/a/{var1}/{var2}"); @SuppressWarnings("unused") Map<String, String> result = t.match(new UriTemplate("/a//c")); } @Test(expected = jakarta.websocket.DeploymentException.class) public void testEgMailingList05() throws Exception { UriTemplate t = new UriTemplate("/a/{var}/"); @SuppressWarnings("unused") Map<String, String> result = t.match(new UriTemplate("/a/b/")); } @Test(expected = jakarta.websocket.DeploymentException.class) public void testSpecIssue194a() throws Exception { @SuppressWarnings("unused") UriTemplate t = new UriTemplate("/a/../b"); } @Test(expected = jakarta.websocket.DeploymentException.class) public void testSpecIssue194b() throws Exception { @SuppressWarnings("unused") UriTemplate t = new UriTemplate("/./b"); } @Test(expected = jakarta.websocket.DeploymentException.class) public void testSpecIssue194c() throws Exception { @SuppressWarnings("unused") UriTemplate t = new UriTemplate("//b"); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
16.04
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