wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jra...@apache.org
Subject svn commit: r1028008 - /incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/UriBuilderImplTest.java
Date Wed, 27 Oct 2010 15:35:40 GMT
Author: jramos
Date: Wed Oct 27 15:35:39 2010
New Revision: 1028008

URL: http://svn.apache.org/viewvc?rev=1028008&view=rev
Log:
Add new unit test for encoded characters in query params

Modified:
    incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/UriBuilderImplTest.java

Modified: incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/UriBuilderImplTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/UriBuilderImplTest.java?rev=1028008&r1=1028007&r2=1028008&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/UriBuilderImplTest.java
(original)
+++ incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/UriBuilderImplTest.java
Wed Oct 27 15:35:39 2010
@@ -22,6 +22,7 @@ package org.apache.wink.common.internal;
 
 import java.lang.reflect.Method;
 import java.net.URI;
+import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -431,7 +432,7 @@ public class UriBuilderImplTest extends 
     public void testQueryIllegal() {
         UriBuilder uriBuilder = UriBuilder.fromPath("");
         try {
-            uriBuilder.queryParam("a", null);
+            uriBuilder.queryParam("a", (Object)null);
             fail();
         } catch (IllegalArgumentException e) {
             // expected
@@ -579,4 +580,16 @@ public class UriBuilderImplTest extends 
         builder.path("{entity_id: [0-9]+}");
         assertEquals("http://localhost:8080/myResource/3", builder.build("3").toString());
     }
+
+
+    public void testWithQueryEncoded() throws Exception {
+        URL url = new URL("http://localhost:8080/myResource?q={abcd}");
+        // URI.toURL() will escape characters if we use one of the multi-param constructors
+        URI constructedURI = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(),
url.getPort(),url.getPath(), url.getQuery(), null);
+        assertEquals("http://localhost:8080/myResource?q=%7Babcd%7D", constructedURI.toString());
+        
+        UriBuilder builder = UriBuilder.fromUri("http://localhost:8080/myResource");
+        builder.queryParam("q", "%7Babcd%7D");
+        assertEquals("http://localhost:8080/myResource?q=%7Babcd%7D", builder.build().toString());
+    }
 }



Mime
View raw message