activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1367620 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/util/URISupport.java test/java/org/apache/activemq/util/URISupportTest.java
Date Tue, 31 Jul 2012 15:44:00 GMT
Author: tabish
Date: Tue Jul 31 15:43:59 2012
New Revision: 1367620

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

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=1367620&r1=1367619&r2=1367620&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 Tue
Jul 31 15:43:59 2012
@@ -205,18 +205,12 @@ public class URISupport {
     }
 
     public static boolean isCompositeURI(URI uri) {
-        if (uri.getQuery() != null) {
-            return false;
-        } else {
-            String ssp = stripPrefix(uri.getRawSchemeSpecificPart().trim(), "(").trim();
-            ssp = stripPrefix(ssp, "//").trim();
-            try {
-                new URI(ssp);
-            } catch (URISyntaxException e) {
-                return false;
-            }
+        String ssp = stripPrefix(uri.getRawSchemeSpecificPart().trim(), "//").trim();
+
+        if (ssp.indexOf('(') == 0 && checkParenthesis(ssp)) {
             return true;
         }
+        return false;
     }
 
     public static int indexOfParenthesisMatch(String str, int first) throws URISyntaxException
{

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=1367620&r1=1367619&r2=1367620&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
Tue Jul 31 15:43:59 2012
@@ -178,4 +178,37 @@ public class URISupportTest extends Test
         assertEquals(parameters.get("proxyPort"), "80");
     }
 
+    public void testIsCompositeURIWithQueryNoSlashes() throws URISyntaxException {
+        URI[] compositeURIs = new URI[] { new URI("test:(part1://host?part1=true)?outside=true"),
new URI("broker:(tcp://localhost:61616)?name=foo") };
+        for (URI uri : compositeURIs) {
+            assertTrue(uri + " must be detected as composite URI", URISupport.isCompositeURI(uri));
+        }
+    }
+
+    public void testIsCompositeURIWithQueryAndSlashes() throws URISyntaxException {
+        URI[] compositeURIs = new URI[] { new URI("test://(part1://host?part1=true)?outside=true"),
new URI("broker://(tcp://localhost:61616)?name=foo") };
+        for (URI uri : compositeURIs) {
+            assertTrue(uri + " must be detected as composite URI", URISupport.isCompositeURI(uri));
+        }
+    }
+
+    public void testIsCompositeURINoQueryNoSlashes() throws URISyntaxException {
+        URI[] compositeURIs = new URI[] { new URI("test:(part1://host,part2://(sub1://part,sube2:part))"),
new URI("test:(path)/path") };
+        for (URI uri : compositeURIs) {
+            assertTrue(uri + " must be detected as composite URI", URISupport.isCompositeURI(uri));
+        }
+    }
+
+    public void testIsCompositeURINoQueryNoSlashesNoParentheses() throws URISyntaxException
{
+        assertFalse("test:part1" + " must be detected as non-composite URI", URISupport.isCompositeURI(new
URI("test:part1")));
+    }
+
+    public void testIsCompositeURINoQueryWithSlashes() throws URISyntaxException {
+        URI[] compositeURIs = new URI[] { new URI("failover://(tcp://bla:61616,tcp://bla:61617)"),
+                new URI("failover://(tcp://localhost:61616,ssl://anotherhost:61617)") };
+        for (URI uri : compositeURIs) {
+            assertTrue(uri + " must be detected as composite URI", URISupport.isCompositeURI(uri));
+        }
+    }
+
 }



Mime
View raw message