You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/06/24 21:35:25 UTC

svn commit: r1496174 - /tomcat/trunk/test/org/apache/tomcat/websocket/server/TestUriTemplate.java

Author: markt
Date: Mon Jun 24 19:35:24 2013
New Revision: 1496174

URL: http://svn.apache.org/r1496174
Log:
Additional unit tests based on spec examples

Modified:
    tomcat/trunk/test/org/apache/tomcat/websocket/server/TestUriTemplate.java

Modified: tomcat/trunk/test/org/apache/tomcat/websocket/server/TestUriTemplate.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/websocket/server/TestUriTemplate.java?rev=1496174&r1=1496173&r2=1496174&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/websocket/server/TestUriTemplate.java (original)
+++ tomcat/trunk/test/org/apache/tomcat/websocket/server/TestUriTemplate.java Mon Jun 24 19:35:24 2013
@@ -86,4 +86,69 @@ public class TestUriTemplate {
 
         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);
+   }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org