activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1079831 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/util/URISupport.java test/java/org/apache/activemq/util/URISupportTest.java
Date Wed, 09 Mar 2011 15:18:00 GMT
Author: tabish
Date: Wed Mar  9 15:17:59 2011
New Revision: 1079831

URL: http://svn.apache.org/viewvc?rev=1079831&view=rev
Log:
apply patch for: https://issues.apache.org/jira/browse/AMQ-3209

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/URISupport.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/URISupportTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/URISupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/URISupport.java?rev=1079831&r1=1079830&r2=1079831&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/URISupport.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/URISupport.java Wed
Mar  9 15:17:59 2011
@@ -174,12 +174,16 @@ public class URISupport {
         String schemeSpecificPart = uri.getRawSchemeSpecificPart();
         // strip existing query if any
         int questionMark = schemeSpecificPart.lastIndexOf("?");
+        // make sure question mark is not within parentheses
+        if (questionMark < schemeSpecificPart.lastIndexOf(")")) {
+        	questionMark = -1;
+        }
         if (questionMark > 0) {
             schemeSpecificPart = schemeSpecificPart.substring(0, questionMark);
         }
         if (query != null && query.length() > 0) {
             schemeSpecificPart += "?" + query;
-         }
+        }
         return new URI(uri.getScheme(), schemeSpecificPart, uri.getFragment());
     }
 

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/URISupportTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/URISupportTest.java?rev=1079831&r1=1079830&r2=1079831&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/URISupportTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/URISupportTest.java
Wed Mar  9 15:17:59 2011
@@ -113,6 +113,28 @@ public class URISupportTest extends Test
         parameters = URISupport.parseParameters(uri);
     }
     
+    public void testCompositeCreateURIWithQuery() throws Exception {
+    	String queryString = "query=value";
+    	URI originalURI = new URI("outerscheme:(innerscheme:innerssp)");
+    	URI querylessURI = originalURI;
+    	assertEquals(querylessURI, URISupport.createURIWithQuery(originalURI, null));
+    	assertEquals(querylessURI, URISupport.createURIWithQuery(originalURI, ""));
+    	assertEquals(new URI(querylessURI + "?" + queryString), URISupport.createURIWithQuery(originalURI,
queryString));
+    	originalURI = new URI("outerscheme:(innerscheme:innerssp)?outerquery=0");
+    	assertEquals(querylessURI, URISupport.createURIWithQuery(originalURI, null));
+    	assertEquals(querylessURI, URISupport.createURIWithQuery(originalURI, ""));
+    	assertEquals(new URI(querylessURI + "?" + queryString), URISupport.createURIWithQuery(originalURI,
queryString));
+    	originalURI = new URI("outerscheme:(innerscheme:innerssp?innerquery=0)");
+    	querylessURI = originalURI;
+    	assertEquals(querylessURI, URISupport.createURIWithQuery(originalURI, null));
+    	assertEquals(querylessURI, URISupport.createURIWithQuery(originalURI, ""));
+    	assertEquals(new URI(querylessURI + "?" + queryString), URISupport.createURIWithQuery(originalURI,
queryString));
+    	originalURI = new URI("outerscheme:(innerscheme:innerssp?innerquery=0)?outerquery=0");
+    	assertEquals(querylessURI, URISupport.createURIWithQuery(originalURI, null));
+    	assertEquals(querylessURI, URISupport.createURIWithQuery(originalURI, ""));
+    	assertEquals(new URI(querylessURI + "?" + queryString), URISupport.createURIWithQuery(originalURI,
queryString));
+    }
+    
     private void verifyParams(Map<String,String> parameters) {
         assertEquals(parameters.get("proxyHost"), "localhost");
         assertEquals(parameters.get("proxyPort"), "80");



Mime
View raw message