velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From schu...@apache.org
Subject svn commit: r1151642 - in /velocity/tools/branches/2.0.x/src: main/java/org/apache/velocity/tools/view/tools/LinkTool.java test/java/org/apache/velocity/tools/test/blackbox/LinkToolTests.java
Date Wed, 27 Jul 2011 21:50:22 GMT
Author: schultz
Date: Wed Jul 27 21:50:21 2011
New Revision: 1151642

URL: http://svn.apache.org/viewvc?rev=1151642&view=rev
Log:
Fixed VELTOOLS-148: LinkTool.addAllParameters causes "ignored" parameters to pollute parent
link objects
- Overrode generic.LinkTool.duplicate(boolean) to clone parametersToIgnore

Modified:
    velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/view/tools/LinkTool.java
    velocity/tools/branches/2.0.x/src/test/java/org/apache/velocity/tools/test/blackbox/LinkToolTests.java

Modified: velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/view/tools/LinkTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/view/tools/LinkTool.java?rev=1151642&r1=1151641&r2=1151642&view=diff
==============================================================================
--- velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/view/tools/LinkTool.java
(original)
+++ velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/view/tools/LinkTool.java
Wed Jul 27 21:50:21 2011
@@ -299,4 +299,14 @@ public class LinkTool extends org.apache
         }
     }
 
+    @Override
+    protected LinkTool duplicate(boolean deep)
+    {
+        LinkTool that = (LinkTool)super.duplicate(deep);
+
+        if(parametersToIgnore != null)
+            that.parametersToIgnore = new HashSet<String>(parametersToIgnore);
+
+        return that;
+    }
 }

Modified: velocity/tools/branches/2.0.x/src/test/java/org/apache/velocity/tools/test/blackbox/LinkToolTests.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.0.x/src/test/java/org/apache/velocity/tools/test/blackbox/LinkToolTests.java?rev=1151642&r1=1151641&r2=1151642&view=diff
==============================================================================
--- velocity/tools/branches/2.0.x/src/test/java/org/apache/velocity/tools/test/blackbox/LinkToolTests.java
(original)
+++ velocity/tools/branches/2.0.x/src/test/java/org/apache/velocity/tools/test/blackbox/LinkToolTests.java
Wed Jul 27 21:50:21 2011
@@ -185,4 +185,17 @@ public class LinkToolTests
         Assert.assertEquals("/test/target?a=a&amp;a=b&amp;a=c&amp;a=d", url);
     }
 
+    public @Test void test_VELTOOLS_148()
+    {
+        LinkTool link = newLinkTool("a", new String[] { "a", "b", "c" });
+
+        LinkTool forward = link.setRelative("/foo")
+            .addQueryData("bar", "baz");
+
+        Assert.assertEquals("/test/foo?bar=baz&amp;a=a&amp;a=b&amp;a=c",
+                            forward.addAllParameters().toString());
+
+        Assert.assertEquals("/test/foo?bar=baz&amp;a=a&amp;a=b&amp;a=c",
+                            forward.addAllParameters().toString());
+    }
 }



Mime
View raw message