knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmin...@apache.org
Subject [1/3] knox git commit: KNOX-394: Request and response URLs must be parsed as literals not templates
Date Tue, 03 Nov 2015 04:52:01 GMT
Repository: knox
Updated Branches:
  refs/heads/master 1755fdfa0 -> 33bb1ce57


http://git-wip-us.apache.org/repos/asf/knox/blob/33bb1ce5/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/ParserTest.java
----------------------------------------------------------------------
diff --git a/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/ParserTest.java b/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/ParserTest.java
index 8e14f1f..f6d1ab2 100644
--- a/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/ParserTest.java
+++ b/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/ParserTest.java
@@ -130,40 +130,40 @@ public class ParserTest {
     Template template;
 
     text = "{path}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, false, 1, 0 );
     assertPath( template, 0, "path", "**" );
     assertThat( template.toString(), is( text ) );
 
     text = "{pathA}/{pathB}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, false, 2, 0 );
     assertPath( template, 0, "pathA", "**" );
     assertPath( template, 1, "pathB", "**" );
     assertThat( template.toString(), is( text ) );
 
     text = "?paramA={valueA}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 1 );
     assertQuery( template, "paramA", "valueA", "**" );
     assertThat( template.toString(), is( text ) );
 
     text = "?paramA={valueA}&paramB={valueB}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 2 );
     assertQuery( template, "paramA", "valueA", "**" );
     assertQuery( template, "paramB", "valueB", "**" );
     assertThat( template.toString(), is( text ) );
 
     text = "?paramA={valueA}?paramB={valueB}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 2 );
     assertQuery( template, "paramA", "valueA", "**" );
     assertQuery( template, "paramB", "valueB", "**" );
     //assertThat( template.toString(), is( text ) );
 
     text = "{pathA}?paramA={valueA}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 1, 1 );
     assertPath( template, 0, "pathA", "**" );
     assertQuery( template, "paramA", "valueA", "**" );
@@ -349,31 +349,31 @@ public class ParserTest {
     Template template;
 
     text = "{path}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, false, 1, 0 );
     assertPath( template, 0, "path", "**", Segment.GLOB, 1, 1 );
     assertThat( template.toString(), is( text ) );
 
     text = "{path=static}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, false, 1, 0 );
     assertPath( template, 0, "path", "static", Segment.STATIC, 1, 1 );
     assertThat( template.toString(), is( text ) );
 
     text = "{path=*}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, false, 1, 0 );
     assertPath( template, 0, "path", "*", Segment.STAR, 1, 1 );
     assertThat( template.toString(), is( text ) );
 
     text = "{path=**}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, false, 1, 0 );
     assertPath( template, 0, "path", "**", Segment.GLOB, 0, Integer.MAX_VALUE );
     assertThat( template.toString(), is( text ) );
 
     text = "{path=wild*card}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, false, 1, 0 );
     assertPath( template, 0, "path", "wild*card", Segment.REGEX, 1, 1 );
     assertThat( template.toString(), is( text ) );
@@ -385,31 +385,31 @@ public class ParserTest {
     Template template;
 
     text = "?query={queryParam}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 1 );
     assertQuery( template, "query", "queryParam", "**", Segment.GLOB, 1, 1 );
     assertThat( template.toString(), is( text ) );
 
     text = "?query={queryParam=static}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 1 );
     assertQuery( template, "query", "queryParam", "static", Segment.STATIC, 1, 1 );
     assertThat( template.toString(), is( text ) );
 
     text = "?query={queryParam=*}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 1 );
     assertQuery( template, "query", "queryParam", "*", Segment.STAR, 1, 1 );
     assertThat( template.toString(), is( text ) );
 
     text = "?query={queryParam=**}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 1 );
     assertQuery( template, "query", "queryParam", "**", Segment.GLOB, 0, Integer.MAX_VALUE );
     assertThat( template.toString(), is( text ) );
 
     text = "?query={queryParam=wild*card}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 1 );
     assertQuery( template, "query", "queryParam", "wild*card", Segment.REGEX, 1, 1 );
     assertThat( template.toString(), is( text ) );
@@ -421,27 +421,27 @@ public class ParserTest {
     Template template;
 
     text = "**";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, false, 1, 0 );
     assertThat( template.toString(), is( text ) );
 
     text = "/**";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, true, false, false, 1, 0 );
     assertThat( template.toString(), is( text ) );
 
     text = "**/";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, true, false, 1, 0 );
     assertThat( template.toString(), is( text ) );
 
     text = "/**/";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, true, true, false, 1, 0 );
     assertThat( template.toString(), is( text ) );
 
     text = "/**/path";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, true, false, false, 2, 0 );
     assertThat( template.toString(), is( text ) );
   }
@@ -513,7 +513,7 @@ public class ParserTest {
     String image;
 
     text = "//";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertThat( template.hasAuthority(), is( true ) );
     assertThat( template.getUsername(), nullValue() );
     assertThat( template.getPassword(), nullValue() );
@@ -522,7 +522,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "//:@:";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertThat( template.hasAuthority(), is( true ) );
     assertThat( template.getUsername(), nullValue() );
     assertThat( template.getPassword(), nullValue() );
@@ -532,7 +532,7 @@ public class ParserTest {
     assertThat( template.getPattern(), is( text ) );
 
     text = "//host";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertThat( template.hasAuthority(), is( true ) );
     assertThat( template.getUsername(), nullValue() );
     assertThat( template.getPassword(), nullValue() );
@@ -542,7 +542,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "//@host";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertThat( template.hasAuthority(), is( true ) );
     assertThat( template.getUsername(), nullValue() );
     assertThat( template.getPassword(), nullValue() );
@@ -553,7 +553,7 @@ public class ParserTest {
     assertThat( template.getPattern(), is( text ) );
 
     text = "//@:80";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertThat( template.hasAuthority(), is( true ) );
     assertThat( template.getUsername(), nullValue() );
     assertThat( template.getPassword(), nullValue() );
@@ -564,7 +564,7 @@ public class ParserTest {
     assertThat( template.getPattern(), is( text ) );
 
     text = "//username@";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertThat( template.hasAuthority(), is( true ) );
     assertThat( template.getUsername().getFirstValue().getOriginalPattern(), is( "username" ) );
     assertThat( template.getUsername().getFirstValue().getEffectivePattern(), is( "username" ) );
@@ -574,7 +574,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "//:password@";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertThat( template.hasAuthority(), is( true ) );
     assertThat( template.getUsername(), nullValue() );
     assertThat( template.getPassword().getFirstValue().getOriginalPattern(), is( "password" ) );
@@ -584,7 +584,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "//{host}:{port}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertThat( template.hasAuthority(), is( true ) );
     assertThat( template.getUsername(), nullValue() );
     assertThat( template.getPassword(), nullValue() );
@@ -599,7 +599,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "{host}:{port}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertThat( template.hasAuthority(), is( true ) );
     assertThat( template.getUsername(), nullValue() );
     assertThat( template.getPassword(), nullValue() );
@@ -623,7 +623,7 @@ public class ParserTest {
     Segment.Value value;
 
     text = "?queryName";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 1 );
     query = template.getQuery().get( "queryName" );
     assertThat( query, notNullValue() );
@@ -633,7 +633,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "?query=value1&query=value2";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 1 );
     query = template.getQuery().get( "query" );
     assertThat( query, notNullValue() );
@@ -656,7 +656,7 @@ public class ParserTest {
     Template template;
 
     text = "#fragment";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, false, 0, 0 );
     assertThat( template.hasFragment(), is( true ) );
     assertThat( template.getFragment().getFirstValue().getEffectivePattern(), is( "fragment" ) );
@@ -670,33 +670,33 @@ public class ParserTest {
     Template template;
 
     text = "//";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, false, 0, 0 );
     assertThat( template.hasAuthority(), is( true ) );
     assertThat( template.toString(), is( text ) );
 
     text = "??";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 0 );
     //IMPROVE assertThat( template.toString(), is( text ) );
     assertThat( template.getPattern(), is( text ) );
 
     text = "##";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, false, 0, 0 );
     assertThat( template.hasFragment(), is( true ) );
     assertThat( template.getFragment().getFirstValue().getEffectivePattern(), is( "#" ) );
     assertThat( template.toString(), is( text ) );
 
     text = "??name=value";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 1 );
     assertQuery( template, "name", "", "value" );
     //IMPROVE assertThat( template.toString(), is( text ) );
     assertThat( template.getPattern(), is( text ) );
 
     text = "//?";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 0 );
     assertThat( template.hasAuthority(), is( true ) );
     assertThat( template.getUsername(), nullValue() );
@@ -706,7 +706,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "//#";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, false, 0, 0 );
     assertThat( template.hasAuthority(), is( true ) );
     assertThat( template.getUsername(), nullValue() );
@@ -729,7 +729,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = ":?";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 1, 0 );
     assertThat( template.hasScheme(), is( false ) );
     assertThat( template.getScheme(), nullValue() );
@@ -739,7 +739,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = ":#";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, false, 1, 0 );
     assertThat( template.hasScheme(), is( false ) );
     assertThat( template.getScheme(), nullValue() );
@@ -750,7 +750,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "http:?";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 0 );
     assertThat( template.hasScheme(), is( true ) );
     assertThat( template.getScheme().getFirstValue().getOriginalPattern(), is( "http" ) );
@@ -759,7 +759,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "http:#";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, false, 0, 0 );
     assertThat( template.hasScheme(), is( true ) );
     assertThat( template.getScheme().getFirstValue().getOriginalPattern(), is( "http" ) );
@@ -769,19 +769,19 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "scheme:path?";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 1, 0 );
     assertThat( template.toString(), is( text ) );
 
     text = "scheme:path#";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, false, 1, 0 );
     assertThat( template.hasFragment(), is( true ) );
     assertThat( template.getFragment(), nullValue() );
     assertThat( template.toString(), is( text ) );
 
     text = "//host/";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, true, true, false, 0, 0 );
     assertThat( template.hasAuthority(), is( true ) );
     assertThat( template.getHost().getFirstValue().getOriginalPattern(), is( "host" ) );
@@ -789,7 +789,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "//host?";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 0 );
     assertThat( template.hasAuthority(), is( true ) );
     assertThat( template.getHost().getFirstValue().getOriginalPattern(), is( "host" ) );
@@ -797,7 +797,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "//host#";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, false, 0, 0 );
     assertThat( template.hasAuthority(), is( true ) );
     assertThat( template.hasFragment(), is( true ) );
@@ -807,26 +807,26 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "///";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, true, true, false, 0, 0 );
     assertThat( template.hasAuthority(), is( true ) );
     assertThat( template.toString(), is( text ) );
 
     text = "//:";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, false, 0, 0 );
     assertThat( template.hasAuthority(), is( true ) );
     //IMPROVE assertThat( template.toString(), is( text ) );
     assertThat( template.getPattern(), is( text ) );
 
     text = "//?";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 0 );
     assertThat( template.hasAuthority(), is( true ) );
     assertThat( template.toString(), is( text ) );
 
     text = "//#";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, false, 0, 0 );
     assertThat( template.hasAuthority(), is( true ) );
     assertThat( template.hasFragment(), is( true ) );
@@ -834,7 +834,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "//:/";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, true, true, false, 0, 0 );
     assertThat( template.hasAuthority(), is( true ) );
     assertThat( template.getHost(), nullValue() );
@@ -842,14 +842,14 @@ public class ParserTest {
     assertThat( template.getPattern(), is( text ) );
 
     text = "//:?";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 0 );
     assertThat( template.getHost(), nullValue() );
     //IMPROVE assertThat( template.toString(), is( text ) );
     assertThat( template.getPattern(), is( text ) );
 
     text = "//:#";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, false, 0, 0 );
     assertThat( template.hasFragment(), is( true ) );
     assertThat( template.getHost(), nullValue() );
@@ -857,7 +857,7 @@ public class ParserTest {
     assertThat( template.getPattern(), is( text ) );
 
     text = "///#";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, true, true, false, 0, 0 );
     assertThat( template.hasFragment(), is( true ) );
     assertThat( template.getHost(), nullValue() );
@@ -865,7 +865,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "///path#";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, true, false, false, 1, 0 );
     assertThat( template.hasFragment(), is( true ) );
     assertThat( template.getHost(), nullValue() );
@@ -873,14 +873,14 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "///?";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, true, true, true, 0, 0 );
     assertThat( template.getHost(), nullValue() );
     assertThat( template.getFragment(), nullValue() );
     assertThat( template.toString(), is( text ) );
 
     text = "///path?";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, true, false, true, 1, 0 );
     assertThat( template.getHost(), nullValue() );
     assertThat( template.getFragment(), nullValue() );
@@ -894,7 +894,7 @@ public class ParserTest {
     Query query;
 
     text = "?*";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 0 );
     query = template.getExtra();
     assertThat( query, notNullValue() );
@@ -905,7 +905,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "?**";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 0 );
     query = template.getExtra();
     assertThat( query, notNullValue() );
@@ -916,7 +916,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "?{*}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 0 );
     query = template.getExtra();
     assertThat( query, notNullValue() );
@@ -927,7 +927,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "?{**}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 0 );
     query = template.getExtra();
     assertThat( query, notNullValue() );
@@ -938,7 +938,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "?*={*}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 0 );
     query = template.getExtra();
     assertThat( query, notNullValue() );
@@ -950,7 +950,7 @@ public class ParserTest {
     assertThat( template.getPattern(), is( text ) );
 
     text = "?**={**}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 0 );
     query = template.getExtra();
     assertThat( query, notNullValue() );
@@ -962,7 +962,7 @@ public class ParserTest {
     assertThat( template.getPattern(), is( text ) );
 
     text = "?**={**=**}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 0 );
     query = template.getExtra();
     assertThat( query, notNullValue() );
@@ -981,7 +981,7 @@ public class ParserTest {
     Query query;
 
     text = "?{queryParam}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 1 );
     query = template.getQuery().get( "queryParam" );
     assertThat( query, notNullValue() );
@@ -993,7 +993,7 @@ public class ParserTest {
     assertThat( template.getPattern(), is( text ) );
 
     text = "?{queryParam=value}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertBasics( template, false, false, true, 0, 1 );
     query = template.getQuery().get( "queryParam" );
     assertThat( query, notNullValue() );
@@ -1011,17 +1011,17 @@ public class ParserTest {
     Template template;
 
     text = "*://*:*/**?**";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertThat( template, notNullValue() );
     assertThat( template.toString(), is( text ) );
 
     text = "*://*:*/**/path?{**}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertThat( template, notNullValue() );
     assertThat( template.toString(), is( text ) );
 
     text = "*://*:*/**/webhdfs/v1/?{**}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertThat( template, notNullValue() );
     assertThat( template.toString(), is( text ) );
   }
@@ -1058,7 +1058,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "*://*:*/**?X=";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertThat( template, notNullValue() );
     assertThat( template.getQuery().get( "X" ), notNullValue() );
     string = expander.expandToString( template, null, null );
@@ -1067,7 +1067,7 @@ public class ParserTest {
     assertThat( template.getPattern(), is( text ) );
 
     text = "http://localhost:62142/gateway/cluster/webhdfs/data/v1/tmp/GatewayWebHdfsFuncTest/testBasicHdfsUseCase/dir/file?aG9zdD1sb2NhbGhvc3QmcG9ydD02MjEzOSZvcD1DUkVBVEUmdXNlci5uYW1lPWhkZnM";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertThat( template, notNullValue() );
     assertThat( template.getQuery().get( "aG9zdD1sb2NhbGhvc3QmcG9ydD02MjEzOSZvcD1DUkVBVEUmdXNlci5uYW1lPWhkZnM" ), notNullValue() );
     string = expander.expandToString( template, null, null );
@@ -1075,7 +1075,7 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "http://localhost:62142/gateway/cluster/webhdfs/data/v1/tmp/GatewayWebHdfsFuncTest/testBasicHdfsUseCase/dir/file?aG9zdD1sb2NhbGhvc3QmcG9ydD02MjEzOSZvcD1DUkVBVEUmdXNlci5uYW1lPWhkZnM=";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertThat( template, notNullValue() );
     assertThat( template.getQuery().get( "aG9zdD1sb2NhbGhvc3QmcG9ydD02MjEzOSZvcD1DUkVBVEUmdXNlci5uYW1lPWhkZnM" ), notNullValue() );
     string = expander.expandToString( template, null, null );
@@ -1183,7 +1183,7 @@ public class ParserTest {
     Template template;
 
     text = "*://*:*/";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertThat( template.getHost().getFirstValue().getOriginalPattern(), is( "*" ) );
     assertThat( template.getHost().getFirstValue().getEffectivePattern(), is( "*" ) );
     assertThat( template.getPort().getFirstValue().getOriginalPattern(), is( "*" ) );
@@ -1191,21 +1191,21 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
 
     text = "*://**/";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertThat( template.getHost().getFirstValue().getOriginalPattern(), is( "**" ) );
     assertThat( template.getHost().getFirstValue().getEffectivePattern(), is( "*" ) );
     assertThat( template.getPort(), nullValue() );
     assertThat( template.toString(), is( text ) );
 
     text = "*://*/";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertThat( template.getHost().getFirstValue().getOriginalPattern(), is( "*" ) );
     assertThat( template.getHost().getFirstValue().getEffectivePattern(), is( "*" ) );
     assertThat( template.getPort(), nullValue() );
     assertThat( template.toString(), is( text ) );
 
     text = "*://**:**/";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     assertThat( template.getHost().getFirstValue().getOriginalPattern(), is( "**" ) );
     assertThat( template.getHost().getFirstValue().getEffectivePattern(), is( "*" ) );
     assertThat( template.getPort().getFirstValue().getOriginalPattern(), is( "**" ) );
@@ -1215,47 +1215,50 @@ public class ParserTest {
 
   @Test
   public void testParseTemplateToken() {
+    Builder builder;
     String input;
     Token output;
 
+    builder = new Builder( "" );
+
     input = "{";
-    output = Parser.parseTemplateToken( input, "~" );
+    output = Parser.parseTemplateToken( builder, input, "~" );
     assertThat( output.getParameterName(), is( "" ) );
     assertThat( output.getOriginalPattern(), is( "{" ) );
     assertThat( output.getEffectivePattern(), is( "{" ) );
 
     input = "}";
-    output = Parser.parseTemplateToken( input, "~" );
+    output = Parser.parseTemplateToken( builder, input, "~" );
     assertThat( output.getParameterName(), is( "" ) );
     assertThat( output.getOriginalPattern(), is( "}" ) );
     assertThat( output.getEffectivePattern(), is( "}" ) );
 
     input = "{X";
-    output = Parser.parseTemplateToken( input, "~" );
+    output = Parser.parseTemplateToken( builder, input, "~" );
     assertThat( output.getParameterName(), is( "" ) );
     assertThat( output.getOriginalPattern(), is( "{X" ) );
     assertThat( output.getEffectivePattern(), is( "{X" ) );
 
     input = "X}";
-    output = Parser.parseTemplateToken( input, "~" );
+    output = Parser.parseTemplateToken( builder, input, "~" );
     assertThat( output.getParameterName(), is( "" ) );
     assertThat( output.getOriginalPattern(), is( "X}" ) );
     assertThat( output.getEffectivePattern(), is( "X}" ) );
 
     input = "X";
-    output = Parser.parseTemplateToken( input, "~" );
+    output = Parser.parseTemplateToken( builder, input, "~" );
     assertThat( output.getParameterName(), is( "" ) );
     assertThat( output.getOriginalPattern(), is( "X" ) );
     assertThat( output.getEffectivePattern(), is( "X" ) );
 
     input = "$";
-    output = Parser.parseTemplateToken( input, "~" );
+    output = Parser.parseTemplateToken( builder, input, "~" );
     assertThat( output.getParameterName(), is( "" ) );
     assertThat( output.getOriginalPattern(), is( "$" ) );
     assertThat( output.getEffectivePattern(), is( "$" ) );
 
     input = "";
-    output = Parser.parseTemplateToken( input, Segment.GLOB_PATTERN );
+    output = Parser.parseTemplateToken( builder, input, Segment.GLOB_PATTERN );
     assertThat( output.getParameterName(), is( "" ) );
     assertThat( output.getOriginalPattern(), is( "" ) );
     assertThat( output.getEffectivePattern(), is( "" ) );
@@ -1268,16 +1271,35 @@ public class ParserTest {
     Matcher<String> matcher;
 
     matcher = new Matcher<String>();
-    template = Parser.parse( "*://*:*/**/webhdfs/v1/{path=**}?{**}" );
+    template = Parser.parseTemplate( "*://*:*/**/webhdfs/v1/{path=**}?{**}" );
     matcher.add( template, "test-value" );
 
-    input = Parser.parse( "http://kminder-os-u14-23-knoxha-150922-1352-2.novalocal:1022/gateway/sandbox/webhdfs/v1/user/hrt_qa/knox-ha/knox_webhdfs_client_dir/test_file?op=CREATE&delegation=XXX&namenoderpcaddress=nameservice&createflag=&createparent=true&overwrite=true" );
+    input = Parser.parseTemplate( "http://kminder-os-u14-23-knoxha-150922-1352-2.novalocal:1022/gateway/sandbox/webhdfs/v1/user/hrt_qa/knox-ha/knox_webhdfs_client_dir/test_file?op=CREATE&delegation=XXX&namenoderpcaddress=nameservice&createflag=&createparent=true&overwrite=true" );
 
     assertThat( input.getQuery().get( "createflag" ).getFirstValue().getPattern(), is( "" ) );
 
-    input = Parser.parse( "http://kminder-os-u14-23-knoxha-150922-1352-2.novalocal:1022/gateway/sandbox/webhdfs/v1/user/hrt_qa/knox-ha/knox_webhdfs_client_dir/test_file?op=CREATE&delegation=XXX&namenoderpcaddress=nameservice&createflag&createparent=true&overwrite=true" );
+    input = Parser.parseTemplate( "http://kminder-os-u14-23-knoxha-150922-1352-2.novalocal:1022/gateway/sandbox/webhdfs/v1/user/hrt_qa/knox-ha/knox_webhdfs_client_dir/test_file?op=CREATE&delegation=XXX&namenoderpcaddress=nameservice&createflag&createparent=true&overwrite=true" );
 
     assertThat( input.getQuery().get( "createflag" ).getFirstValue().getPattern(), nullValue() );
   }
 
+  @Test
+  public void testParserLiteralsWithReservedCharactersBugKnox394() throws Exception {
+    Template template;
+    String image;
+
+    template = Parser.parseLiteral( "{}" );
+    image = template.toString();
+    assertThat( image, is( "{}" ) );
+
+    template = Parser.parseLiteral( "{app.path}/child/path" );
+    image = template.toString();
+    assertThat( image, is( "{app.path}/child/path" ) );
+
+    template = Parser.parseLiteral( "${app.path}/child/path" );
+    image = template.toString();
+    assertThat( image, is( "${app.path}/child/path" ) );
+
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/33bb1ce5/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/RewriterTest.java
----------------------------------------------------------------------
diff --git a/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/RewriterTest.java b/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/RewriterTest.java
index 3cdda85..645ffd5 100644
--- a/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/RewriterTest.java
+++ b/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/RewriterTest.java
@@ -60,9 +60,9 @@ public class RewriterTest {
     // This is the URI like we would get from say a Location HTTP header.
     inputUri = new URI( "http://some-host:80" );
     // This will be used to extract the three values from input URI: scheme='http', host='some-known-host', port='80'
-    inputTemplate = Parser.parse( "{scheme}://{host}:{port}" );
+    inputTemplate = Parser.parseTemplate( "{scheme}://{host}:{port}" );
     // The template to build a new URI.  The match those in the input template.
-    outputTemplate = Parser.parse( "{scheme}://{host}:{port}" );
+    outputTemplate = Parser.parseTemplate( "{scheme}://{host}:{port}" );
     // Copies the values extracted from the input URI via the inputTemplate and inserts them into the outputTemplate.
     // The resolver isn't used in this case.
     outputUri = Rewriter.rewrite( inputUri, inputTemplate, outputTemplate, resolver, null );
@@ -76,8 +76,8 @@ public class RewriterTest {
     // I want to discuss the '$' syntax hoping you have a better suggestion.
     // IMPORTANT: The $ ended up being used for function so the syntax below cannot be used.  Consider ^ or something else.
     inputUri = new URI( "http://some-known-host:80" );
-    inputTemplate = Parser.parse( "{scheme}://{host}:{port}" );
-    outputTemplate = Parser.parse( "{scheme}://{$host}:{port}" );
+    inputTemplate = Parser.parseTemplate( "{scheme}://{host}:{port}" );
+    outputTemplate = Parser.parseTemplate( "{scheme}://{$host}:{port}" );
     outputUri = Rewriter.rewrite( inputUri, inputTemplate, outputTemplate, resolver, null );
     assertThat( outputUri.toString(), equalTo( "http://some-other-host:80" ) );
 
@@ -85,8 +85,8 @@ public class RewriterTest {
     // Right now it uses the empty string.
     // IMPORTANT: The $ ended up being used for function so the syntax below cannot be used.  Consider ^ or something else.
     inputUri = new URI( "http://some-unknown-host:80" );
-    inputTemplate = Parser.parse( "{scheme}://{host}:{port}" );
-    outputTemplate = Parser.parse( "{scheme}://{$host}:{port}" );
+    inputTemplate = Parser.parseTemplate( "{scheme}://{host}:{port}" );
+    outputTemplate = Parser.parseTemplate( "{scheme}://{$host}:{port}" );
     outputUri = Rewriter.rewrite( inputUri, inputTemplate, outputTemplate, resolver, null );
     assertThat( outputUri.toString(), equalTo( "http://:80" ) );
 
@@ -94,8 +94,8 @@ public class RewriterTest {
     // Should this be the default and only behavior?
     // See the '?' in the output template below.
     inputUri = new URI( "http://some-unknown-host:80" );
-    inputTemplate = Parser.parse( "{scheme}://{host}:{port}" );
-    outputTemplate = Parser.parse( "{scheme}://{?host}:{port}" );
+    inputTemplate = Parser.parseTemplate( "{scheme}://{host}:{port}" );
+    outputTemplate = Parser.parseTemplate( "{scheme}://{?host}:{port}" );
     outputUri = Rewriter.rewrite( inputUri, inputTemplate, outputTemplate, resolver, null );
     assertThat( outputUri.toString(), equalTo( "http://some-unknown-host:80" ) );
   }
@@ -111,8 +111,8 @@ public class RewriterTest {
     EasyMock.replay( resolver, evaluator );
 
     URI inputUri = new URI( "scheme://internal-host:777/path" );
-    Template inputMatch = Parser.parse( "{scheme}://{host}:{port}/{path=**}?{**}" );
-    Template outputTemplate = Parser.parse( "{scheme}://{$hostmap(host)}:{port}/{path=**}?&{**}" );
+    Template inputMatch = Parser.parseTemplate( "{scheme}://{host}:{port}/{path=**}?{**}" );
+    Template outputTemplate = Parser.parseTemplate( "{scheme}://{$hostmap(host)}:{port}/{path=**}?&{**}" );
 
     URI outputUri = Rewriter.rewrite( inputUri, inputMatch, outputTemplate, resolver, evaluator );
 
@@ -126,20 +126,20 @@ public class RewriterTest {
     MockParams resolver = new MockParams();
 
     inputUri = new URI( "path-1/path-2" );
-    inputTemplate = Parser.parse( "{path-1-name}/{path-2-name}" );
-    outputTemplate = Parser.parse( "{path-2-name}/{path-1-name}" );
+    inputTemplate = Parser.parseTemplate( "{path-1-name}/{path-2-name}" );
+    outputTemplate = Parser.parseTemplate( "{path-2-name}/{path-1-name}" );
     outputUri = Rewriter.rewrite( inputUri, inputTemplate, outputTemplate, resolver, null );
     assertThat( outputUri.toString(), equalTo( "path-2/path-1" ) );
 
     inputUri = new URI( "path-1/path-2/path-3/path-4" );
-    inputTemplate = Parser.parse( "path-1/{path=**}/path-4" ); // Need the ** to allow the expansion to include all path values.
-    outputTemplate = Parser.parse( "new-path-1/{path=**}/new-path-4" );
+    inputTemplate = Parser.parseTemplate( "path-1/{path=**}/path-4" ); // Need the ** to allow the expansion to include all path values.
+    outputTemplate = Parser.parseTemplate( "new-path-1/{path=**}/new-path-4" );
     outputUri = Rewriter.rewrite( inputUri, inputTemplate, outputTemplate, resolver, null );
     assertThat( outputUri.toString(), equalTo( "new-path-1/path-2/path-3/new-path-4" ) );
 
     inputUri = new URI( "some-path?query-name=some-queryParam-value" );
-    inputTemplate = Parser.parse( "{path-name}?query-name={queryParam-value}" );
-    outputTemplate = Parser.parse( "{queryParam-value}/{path-name}" );
+    inputTemplate = Parser.parseTemplate( "{path-name}?query-name={queryParam-value}" );
+    outputTemplate = Parser.parseTemplate( "{queryParam-value}/{path-name}" );
     outputUri = Rewriter.rewrite( inputUri, inputTemplate, outputTemplate, resolver, null );
     assertThat( outputUri.toString(), equalTo( "some-queryParam-value/some-path" ) );
   }
@@ -151,15 +151,15 @@ public class RewriterTest {
     MockParams params = new MockParams();
 
     inputUri = new URI( "path?query=value" );
-    inputTemplate = Parser.parse( "path?{**}" );
-    outputTemplate = Parser.parse( "path?{**}" );
+    inputTemplate = Parser.parseTemplate( "path?{**}" );
+    outputTemplate = Parser.parseTemplate( "path?{**}" );
 
     outputUri = Rewriter.rewrite( inputUri, inputTemplate, outputTemplate, params, null );
     assertThat( outputUri.toString(), equalTo( "path?query=value" ) );
 
     inputUri = new URI( "path?query=value" );
-    inputTemplate = Parser.parse( "path?{*}" );
-    outputTemplate = Parser.parse( "path?{*}" );
+    inputTemplate = Parser.parseTemplate( "path?{*}" );
+    outputTemplate = Parser.parseTemplate( "path?{*}" );
     outputUri = Rewriter.rewrite( inputUri, inputTemplate, outputTemplate, params, null );
     assertThat( outputUri.toString(), equalTo( "path?query=value" ) );
   }
@@ -180,79 +180,79 @@ public class RewriterTest {
 
     actualInput = new URI( "http://some-host:0/some-path" );
 //    sourcePattern = Parser.parse( "**" );
-    sourcePattern = Parser.parse( "*://*:*/**" );
-    targetPattern = Parser.parse( "should-not-change" );
+    sourcePattern = Parser.parseTemplate( "*://*:*/**" );
+    targetPattern = Parser.parseTemplate( "should-not-change" );
     actualOutput = Rewriter.rewrite( actualInput, sourcePattern, targetPattern, new TestResolver( config, request ), null );
     expectOutput = new URI( "should-not-change" );
     assertThat( actualOutput, equalTo( expectOutput ) );
 
     actualInput = new URI( "http://some-host:0/some-path" );
-    sourcePattern = Parser.parse( "*://*:*/{0=**}" );
-    targetPattern = Parser.parse( "{0}" );
+    sourcePattern = Parser.parseTemplate( "*://*:*/{0=**}" );
+    targetPattern = Parser.parseTemplate( "{0}" );
     actualOutput = Rewriter.rewrite( actualInput, sourcePattern, targetPattern, new TestResolver( config, request ), null );
     expectOutput = new URI( "some-path" );
     assertThat( actualOutput, equalTo( expectOutput ) );
 
     actualInput = new URI( "http://some-host:0/pathA/pathB/pathC" );
-    sourcePattern = Parser.parse( "*://*:*/pathA/{1=*}/{2=*}" );
-    targetPattern = Parser.parse( "http://some-other-host/{2}/{1}" );
+    sourcePattern = Parser.parseTemplate( "*://*:*/pathA/{1=*}/{2=*}" );
+    targetPattern = Parser.parseTemplate( "http://some-other-host/{2}/{1}" );
     actualOutput = Rewriter.rewrite( actualInput, sourcePattern, targetPattern, new TestResolver( config, request ), null );
     expectOutput = new URI( "http://some-other-host/pathC/pathB" );
     assertThat( actualOutput, equalTo( expectOutput ) );
 
     actualInput = new URI( "http://some-host:0/some-path" );
-    sourcePattern = Parser.parse( "*://*:*/**" );
-    targetPattern = Parser.parse( "{filter-queryParam-name}" );
+    sourcePattern = Parser.parseTemplate( "*://*:*/**" );
+    targetPattern = Parser.parseTemplate( "{filter-queryParam-name}" );
     actualOutput = Rewriter.rewrite( actualInput, sourcePattern, targetPattern, new TestResolver( config, request ), null );
     expectOutput = new URI( "filter-queryParam-value" );
     assertThat( actualOutput, equalTo( expectOutput ) );
 
     actualInput = new URI( "http://some-host:0/some-path" );
-    sourcePattern = Parser.parse( "*://*:*/**" );
-    targetPattern = Parser.parse( "{expect-queryParam-name}" );
+    sourcePattern = Parser.parseTemplate( "*://*:*/**" );
+    targetPattern = Parser.parseTemplate( "{expect-queryParam-name}" );
     actualOutput = Rewriter.rewrite( actualInput, sourcePattern, targetPattern, new TestResolver( config, request ), null );
     expectOutput = new URI( "expect-queryParam-value" );
     assertThat( actualOutput, equalTo( expectOutput ) );
 
     actualInput = new URI( "http://some-host:0/some-path" );
-    sourcePattern = Parser.parse( "*://*:*/**" );
-    targetPattern = Parser.parse( "http://some-other-host/{filter-queryParam-name}/{expect-queryParam-name}" );
+    sourcePattern = Parser.parseTemplate( "*://*:*/**" );
+    targetPattern = Parser.parseTemplate( "http://some-other-host/{filter-queryParam-name}/{expect-queryParam-name}" );
     actualOutput = Rewriter.rewrite( actualInput, sourcePattern, targetPattern, new TestResolver( config, request ), null );
     expectOutput = new URI( "http://some-other-host/filter-queryParam-value/expect-queryParam-value" );
     assertThat( actualOutput, equalTo( expectOutput ) );
 
     actualInput = new URI( "http://some-host:0/pathA/pathB/pathC" );
-    sourcePattern = Parser.parse( "*://*:*/pathA/{1=*}/{2=*}" );
-    targetPattern = Parser.parse( "http://some-other-host/{2}/{1}/{filter-queryParam-name}/{expect-queryParam-name}" );
+    sourcePattern = Parser.parseTemplate( "*://*:*/pathA/{1=*}/{2=*}" );
+    targetPattern = Parser.parseTemplate( "http://some-other-host/{2}/{1}/{filter-queryParam-name}/{expect-queryParam-name}" );
     actualOutput = Rewriter.rewrite( actualInput, sourcePattern, targetPattern, new TestResolver( config, request ), null );
     expectOutput = new URI( "http://some-other-host/pathC/pathB/filter-queryParam-value/expect-queryParam-value" );
     assertThat( actualOutput, equalTo( expectOutput ) );
 
     actualInput = new URI( "/webhdfs/v1/test" );
-    sourcePattern = Parser.parse( "/webhdfs/v1/{0=**}" );
-    targetPattern = Parser.parse( "http://{filter-queryParam-name}/webhdfs/v1/{0}" );
+    sourcePattern = Parser.parseTemplate( "/webhdfs/v1/{0=**}" );
+    targetPattern = Parser.parseTemplate( "http://{filter-queryParam-name}/webhdfs/v1/{0}" );
     actualOutput = Rewriter.rewrite( actualInput, sourcePattern, targetPattern, new TestResolver( config, request ), null );
     expectOutput = new URI( "http://filter-queryParam-value/webhdfs/v1/test" );
     assertThat( actualOutput, equalTo( expectOutput ) );
 
     actualInput = new URI( "/webhdfs/v1/test" );
-    sourcePattern = Parser.parse( "/webhdfs/v1/{0=**}" );
-    targetPattern = Parser.parse( "http://{filter-queryParam-name}/webhdfs/v1/{0}" );
+    sourcePattern = Parser.parseTemplate( "/webhdfs/v1/{0=**}" );
+    targetPattern = Parser.parseTemplate( "http://{filter-queryParam-name}/webhdfs/v1/{0}" );
     actualOutput = Rewriter.rewrite( actualInput, sourcePattern, targetPattern, new TestResolver( config, request ), null );
     expectOutput = new URI( "http://filter-queryParam-value/webhdfs/v1/test" );
     assertThat( actualOutput, equalTo( expectOutput ) );
 
     actualInput = new URI( "http://vm.home:50075/webhdfs/v1/test/file?op=CREATE&user.name=hdfs&overwrite=false" );
     expectOutput = new URI( "http://filter-queryParam-value/gatewaycluster/webhdfs/v1/test/file?op=CREATE&user.name=hdfs&overwrite=false" );
-    sourcePattern = Parser.parse( "*://*:*/webhdfs/v1/{path=**}?op={op=*}&user.name={username=*}&overwrite={overwrite=*}" );
-    targetPattern = Parser.parse( "http://{filter-queryParam-name}/gatewaycluster/webhdfs/v1/{path=**}?op={op}&user.name={username}&overwrite={overwrite}" );
+    sourcePattern = Parser.parseTemplate( "*://*:*/webhdfs/v1/{path=**}?op={op=*}&user.name={username=*}&overwrite={overwrite=*}" );
+    targetPattern = Parser.parseTemplate( "http://{filter-queryParam-name}/gatewaycluster/webhdfs/v1/{path=**}?op={op}&user.name={username}&overwrite={overwrite}" );
     actualOutput = Rewriter.rewrite( actualInput, sourcePattern, targetPattern, new TestResolver( config, request ), null );
     assertThat( actualOutput, equalTo( expectOutput ) );
 
     actualInput = new URI( "/webhdfs/data/v1/test?user.name=hdfs&op=CREATE&overwrite=false&host=vm.home&port=50075" );
     expectOutput = new URI( "http://vm.home:50075/webhdfs/v1/test?op=CREATE&user.name=hdfs&overwrite=false" );
-    sourcePattern = Parser.parse( "/webhdfs/data/v1/{path=**}?{host}&{port}&{**}" );
-    targetPattern = Parser.parse( "http://{host}:{port}/webhdfs/v1/{path=**}?{**}" );
+    sourcePattern = Parser.parseTemplate( "/webhdfs/data/v1/{path=**}?{host}&{port}&{**}" );
+    targetPattern = Parser.parseTemplate( "http://{host}:{port}/webhdfs/v1/{path=**}?{**}" );
     actualOutput = Rewriter.rewrite( actualInput, sourcePattern, targetPattern, new TestResolver( config, request ), null );
     // Note: Had to change the order of the expected query params to match.
     // This is probably dependent upon iterator ordering and therefore might be a test issue.
@@ -289,8 +289,8 @@ public class RewriterTest {
     URI actualInput, actualOutput;
     String actualString;
 
-    sourcePattern = Parser.parse( "*://{host}:{port}/webhdfs/v1/{path=**}?{**}" );
-    targetPattern = Parser.parse( "{gateway.url}/webhdfs/data/v1/{path=**}?{host}&{port}&{**}" );
+    sourcePattern = Parser.parseTemplate( "*://{host}:{port}/webhdfs/v1/{path=**}?{**}" );
+    targetPattern = Parser.parseTemplate( "{gateway.url}/webhdfs/data/v1/{path=**}?{host}&{port}&{**}" );
 
     actualInput = new URI( "http://vm.local:50075/webhdfs/v1/tmp/GatewayWebHdfsFuncTest/dirA700/fileA700?op=CREATE&user.name=hdfs&overwrite=false&permission=700" );
     actualOutput = Rewriter.rewrite( actualInput, sourcePattern, targetPattern, new TestResolver( config, request ), null );
@@ -318,8 +318,8 @@ public class RewriterTest {
     URI actualInput, actualOutput;
     String actualString;
 
-    sourcePattern = Parser.parse( "/webhdfs/data/v1/{path=**}?{host}&{port}&{**}" );
-    targetPattern = Parser.parse( "http://{host}:{port}/webhdfs/v1/{path=**}?{**}" );
+    sourcePattern = Parser.parseTemplate( "/webhdfs/data/v1/{path=**}?{host}&{port}&{**}" );
+    targetPattern = Parser.parseTemplate( "http://{host}:{port}/webhdfs/v1/{path=**}?{**}" );
 
     actualInput = new URI( "/webhdfs/data/v1/tmp/GatewayWebHdfsFuncTest/dirA700/fileA700?host=vm.local&port=50075&op=CREATE&user.name=hdfs&overwrite=false&permission=700" );
     actualOutput = Rewriter.rewrite( actualInput, sourcePattern, targetPattern, new TestResolver( config, request ), null );
@@ -337,8 +337,8 @@ public class RewriterTest {
     Template inputTemplate, outputTemplate;
     URI actualInput, actualOutput, expectOutput;
 
-    inputTemplate = Parser.parse( "{scheme}://{host}:*/{path=**}?{**}" );
-    outputTemplate = Parser.parse( "{scheme}://{host}:777/test-output/{path=**}?{**}" );
+    inputTemplate = Parser.parseTemplate( "{scheme}://{host}:*/{path=**}?{**}" );
+    outputTemplate = Parser.parseTemplate( "{scheme}://{host}:777/test-output/{path=**}?{**}" );
 
     actualInput = new URI( "http://host:42/pathA/pathB" );
     expectOutput = new URI( "http://host:777/test-output/pathA/pathB" );
@@ -353,8 +353,8 @@ public class RewriterTest {
     Template inputTemplate, outputTemplate;
     URI actualInput, actualOutput;
 
-    inputTemplate = Parser.parse( "*://*:*/**/oozie/{**}?{**}");
-    outputTemplate = Parser.parse( "http://localhost:11000/oozie/{**}?{**}");
+    inputTemplate = Parser.parseTemplate( "*://*:*/**/oozie/{**}?{**}" );
+    outputTemplate = Parser.parseTemplate( "http://localhost:11000/oozie/{**}?{**}");
 
     actualInput = new URI("https://localhost:8443/gateway/oozieui/oozie/v2/jobs?_dc=1438899557070&filter=&timezone=GMT");
     actualOutput = Rewriter.rewrite( actualInput, inputTemplate, outputTemplate, null, null );

http://git-wip-us.apache.org/repos/asf/knox/blob/33bb1ce5/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/SegmentTest.java
----------------------------------------------------------------------
diff --git a/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/SegmentTest.java b/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/SegmentTest.java
index b5c9840..b2f2881 100644
--- a/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/SegmentTest.java
+++ b/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/SegmentTest.java
@@ -32,42 +32,42 @@ public class SegmentTest {
   @Test
   public void testEquals() throws Exception {
     Object o = new Object();
-    TestSegment s1 = new TestSegment( "p", "v" );
+    TestSegment s1 = new TestSegment( "p", "v", true );
     assertThat( s1.equals( o ), equalTo( false ) );
     assertThat( s1.equals( s1 ), equalTo( true ) );
 
-    TestSegment s2 = new TestSegment( "p", "v" );
+    TestSegment s2 = new TestSegment( "p", "v", true );
     assertThat( s1.equals( s2 ), equalTo( true ) );
 
-    TestSegment s3 = new TestSegment( "p2", "v" );
+    TestSegment s3 = new TestSegment( "p2", "v", true );
     assertThat( s2.equals( s3 ), equalTo( false ) );
 
-    TestSegment s4 = new TestSegment( "p2", "v2" );
+    TestSegment s4 = new TestSegment( "p2", "v2", true );
     assertThat( s3.equals( s4 ), equalTo( false ) );
 
-    TestSegment s5 = new TestSegment( "p", "*" );
+    TestSegment s5 = new TestSegment( "p", "*", false );
     assertThat( s1.equals( s5 ), equalTo( false ) );
 
   }
 
   @Test
   public void testMatches() throws Exception {
-    TestSegment s1 = new TestSegment( "p", "v" );
-    TestSegment s2 = new TestSegment( "p", "v" );
+    TestSegment s1 = new TestSegment( "p", "v", true );
+    TestSegment s2 = new TestSegment( "p", "v", true );
 
     assertThat( s1.matches( s1 ), equalTo( true ) );
     assertThat( s1.matches( s2 ), equalTo( true ) );
 
-    TestSegment s3 = new TestSegment( "p", "*" );
+    TestSegment s3 = new TestSegment( "p", "*", false );
     assertThat( s3.matches( s1 ), equalTo( true ) );
     assertThat( s1.matches( s3 ), equalTo( false ) ); // Because wildecards no longer supported in "that" segment.
 
-    TestSegment s4 = new TestSegment( "p", "**" );
+    TestSegment s4 = new TestSegment( "p", "**", false );
     assertThat( s4.matches( s1 ), equalTo( true ) );
     assertThat( s1.matches( s4 ), equalTo( false ) ); // Because wildecards no longer supported in "that" segment.
 
-    TestSegment s5 = new TestSegment( "p", "*.ext" );
-    TestSegment s6 = new TestSegment( "p", "file.ext" );
+    TestSegment s5 = new TestSegment( "p", "*.ext", false );
+    TestSegment s6 = new TestSegment( "p", "file.ext", false );
     assertThat( s5.matches( s5 ), equalTo( true ) );
     assertThat( s5.matches( s6 ), equalTo( true ) );
     assertThat( s6.matches( s5 ), equalTo( false ) ); // Because wildecards no longer supported in "that" segment.
@@ -128,8 +128,8 @@ public class SegmentTest {
 
   private class TestSegment extends Segment {
 
-    public TestSegment( String paramName, String valuePattern ) {
-      super( new Token( paramName, valuePattern ) );
+    public TestSegment( String paramName, String valuePattern, boolean literal ) {
+      super( new Token( paramName, valuePattern, literal ) );
     }
 
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/33bb1ce5/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/TemplateTest.java
----------------------------------------------------------------------
diff --git a/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/TemplateTest.java b/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/TemplateTest.java
index cc0e720..c99421c 100644
--- a/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/TemplateTest.java
+++ b/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/TemplateTest.java
@@ -41,12 +41,12 @@ public class TemplateTest {
     Template template;
 
     input = "{X}";
-    template = Parser.parse( input );
+    template = Parser.parseTemplate( input );
     output = template.toString();
     assertThat( output, is( input ) );
 
     input = "{}";
-    template = Parser.parse( input );
+    template = Parser.parseTemplate( input );
     output = template.toString();
     assertThat( output, is( input ) );
 
@@ -57,52 +57,52 @@ public class TemplateTest {
     // {**}
 
     input = "*,${";
-    template = Parser.parse( input );
+    template = Parser.parseTemplate( input );
     output = template.toString();
     assertThat( output, is( input ) );
 
     input = "$";
-    template = Parser.parse( input );
+    template = Parser.parseTemplate( input );
     output = template.toString();
     assertThat( output, is( input ) );
 
     input = "$$";
-    template = Parser.parse( input );
+    template = Parser.parseTemplate( input );
     output = template.toString();
     assertThat( output, is( input ) );
 
     input = "*,$";
-    template = Parser.parse( input );
+    template = Parser.parseTemplate( input );
     output = template.toString();
     assertThat( output, is( input ) );
 
     input = "*.,${";
-    template = Parser.parse( input );
+    template = Parser.parseTemplate( input );
     output = template.toString();
     assertThat( output, is( input ) );
 
     input = "{";
-    template = Parser.parse( input );
+    template = Parser.parseTemplate( input );
     output = template.toString();
     assertThat( output, is( input ) );
 
     input = "}";
-    template = Parser.parse( input );
+    template = Parser.parseTemplate( input );
     output = template.toString();
     assertThat( output, is( input ) );
 
     input = "${X}";
-    template = Parser.parse( input );
+    template = Parser.parseTemplate( input );
     output = template.toString();
     assertThat( output, is( input ) );
 
     input = "{$X}";
-    template = Parser.parse( input );
+    template = Parser.parseTemplate( input );
     output = template.toString();
     assertThat( output, is( input ) );
 
     input = "/var/lib/oozie/*.jar,/usr/lib/hadoop/client/*.jar,/usr/lib/oozie/libserver/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar";
-    template = Parser.parse( input );
+    template = Parser.parseTemplate( input );
     output = template.toString();
     assertThat( output, is( input ) );
 
@@ -111,12 +111,17 @@ public class TemplateTest {
   @Test
   public void testToString() throws Exception {
     String text = "scheme://username:password@host:port/top/mid/bot/file?query=value#fragment";
-    Template template = Parser.parse( text );
+    Template template = Parser.parseTemplate( text );
     String actual = template.toString();
     assertThat( actual, equalTo( text ) );
 
+    text = "scheme://username:password@host:port/top/mid/bot/file?query=value#fragment";
+    template = Parser.parseLiteral( text );
+    actual = template.toString();
+    assertThat( actual, equalTo( text ) );
+
     text = "{*}://{host}:{*}/{**}?{**}";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     actual = template.toString();
     assertThat( template.getScheme().getParamName(), is( "*" ) );
     assertThat( template.getScheme().getFirstValue().getOriginalPattern(), nullValue() );
@@ -139,21 +144,21 @@ public class TemplateTest {
     assertThat( actual, is( text ) );
 
     text = "/path/**?**";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     actual = template.toString();
     assertThat( actual, is( text ) );
 
     text = "host:42";
-    template = Parser.parse( text );
+    template = Parser.parseTemplate( text );
     actual = template.toString();
     assertThat( actual, is( text ) );
   }
 
   @Test
   public void testHashCode() throws Exception {
-    Template t1 = Parser.parse( "scheme://username:password@host:port/top/mid/bot/file?query=value#fragment1" );
-    Template t2 = Parser.parse( "scheme://username:password@host:port/top/mid/bot/file?query=value#fragment1" );
-    Template t3 = Parser.parse( "scheme://username:password@host:port/top/mid/bot/file?query=value#fragment2" );
+    Template t1 = Parser.parseTemplate( "scheme://username:password@host:port/top/mid/bot/file?query=value#fragment1" );
+    Template t2 = Parser.parseTemplate( "scheme://username:password@host:port/top/mid/bot/file?query=value#fragment1" );
+    Template t3 = Parser.parseTemplate( "scheme://username:password@host:port/top/mid/bot/file?query=value#fragment2" );
 
     assertThat( t1.hashCode(), equalTo( t2.hashCode() ) );
     assertThat( t1.hashCode(), not( equalTo( t3.hashCode() ) ) );
@@ -161,9 +166,9 @@ public class TemplateTest {
 
   @Test
   public void testEquals() throws Exception {
-    Template t1 = Parser.parse( "scheme://username:password@host:port/top/mid/bot/file?query=value#fragment1" );
-    Template t2 = Parser.parse( "scheme://username:password@host:port/top/mid/bot/file?query=value#fragment1" );
-    Template t3 = Parser.parse( "scheme://username:password@host:port/top/mid/bot/file?query=value#fragment2" );
+    Template t1 = Parser.parseTemplate( "scheme://username:password@host:port/top/mid/bot/file?query=value#fragment1" );
+    Template t2 = Parser.parseTemplate( "scheme://username:password@host:port/top/mid/bot/file?query=value#fragment1" );
+    Template t3 = Parser.parseTemplate( "scheme://username:password@host:port/top/mid/bot/file?query=value#fragment2" );
 
     assertThat( t1.equals( t2 ), equalTo( true ) );
     assertThat( t1.equals( t3 ), equalTo( false ) );

http://git-wip-us.apache.org/repos/asf/knox/blob/33bb1ce5/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/TokenTest.java
----------------------------------------------------------------------
diff --git a/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/TokenTest.java b/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/TokenTest.java
index a713fb8..0aec102 100644
--- a/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/TokenTest.java
+++ b/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/TokenTest.java
@@ -27,7 +27,7 @@ public class TokenTest {
   @Test
   public void testConstructorAndGetters() throws Exception {
 
-    Token token = new Token( "test-parameter-name", "test-original-value", "test-effective-value" );
+    Token token = new Token( "test-parameter-name", "test-original-value", "test-effective-value", true );
 
     assertThat( token.parameterName, is( "test-parameter-name" ) );
     assertThat( token.originalPattern, is( "test-original-value" ) );


Mime
View raw message