camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1329091 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/impl/ test/java/org/apache/camel/impl/
Date Mon, 23 Apr 2012 06:56:32 GMT
Author: davsclaus
Date: Mon Apr 23 06:56:31 2012
New Revision: 1329091

URL: http://svn.apache.org/viewvc?rev=1329091&view=rev
Log:
CAMEL-5183: Polished

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ConfigurationHelper.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpointConfiguration.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MappedEndpointConfiguration.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/EndpointConfigurationTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ConfigurationHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ConfigurationHelper.java?rev=1329091&r1=1329090&r2=1329091&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ConfigurationHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ConfigurationHelper.java Mon
Apr 23 06:56:31 2012
@@ -72,10 +72,11 @@ public final class ConfigurationHelper {
                 new Object[]{scheme, component != null ? component.getClass().getName() :
"<null>"});
         }
         if (component != null) {
-            DefaultEndpointConfiguration cfg = (DefaultEndpointConfiguration) component.createConfiguration(scheme);
-            // Should we be ok with URIs not properly encoded? (that method may need a bit
of refactoring too)
-            cfg.setURI(new URI(UnsafeUriCharactersEncoder.encode(uri)));
-            return cfg;
+            EndpointConfiguration config = component.createConfiguration(scheme);
+            if (config instanceof DefaultEndpointConfiguration) {
+                ((DefaultEndpointConfiguration) config).setURI(uri);
+            }
+            return config;
         } else {
             // no component to create the configuration
             return null;

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpointConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpointConfiguration.java?rev=1329091&r1=1329090&r2=1329091&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpointConfiguration.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpointConfiguration.java
Mon Apr 23 06:56:31 2012
@@ -23,6 +23,7 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.EndpointConfiguration;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.UnsafeUriCharactersEncoder;
 
 /**
  * Default implementation of {@link EndpointConfiguration}.
@@ -60,7 +61,8 @@ public abstract class DefaultEndpointCon
 
     public void setURI(String uri) {
         try {
-            setURI(new URI(uri));
+            String encoded = UnsafeUriCharactersEncoder.encode(uri);
+            setURI(new URI(encoded));
         } catch (URISyntaxException e) {
             throw new RuntimeCamelException("Cannot parse uri: " + uri, e);
         }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MappedEndpointConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MappedEndpointConfiguration.java?rev=1329091&r1=1329090&r2=1329091&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MappedEndpointConfiguration.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MappedEndpointConfiguration.java
Mon Apr 23 06:56:31 2012
@@ -126,15 +126,15 @@ public final class MappedEndpointConfigu
                 }
             }
         }
-        
+
         Collections.sort(queryParams);
         String q = "";
         for (String entry : queryParams) {
             q += q.length() == 0 ? "" : "&";
             q += entry;
         }
-        
-        StringBuffer u = new StringBuffer(1024);
+
+        StringBuffer u = new StringBuffer(64);
         if (scheme != null) {
             u.append(scheme); // SHOULD NOT be null
             u.append(":");
@@ -152,6 +152,10 @@ public final class MappedEndpointConfigu
                 u.append(fragment);
             }
         } else {
+            // add leading // if not provided
+            if (!schemeSpecificPart.startsWith("//")) {
+                u.append("//");
+            }
             u.append(schemeSpecificPart);
         }
         return u.toString();

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/EndpointConfigurationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/EndpointConfigurationTest.java?rev=1329091&r1=1329090&r2=1329091&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/EndpointConfigurationTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/EndpointConfigurationTest.java
Mon Apr 23 06:56:31 2012
@@ -22,6 +22,7 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.EndpointConfiguration;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.Ignore;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
@@ -60,6 +61,14 @@ public class EndpointConfigurationTest {
         assertEquals("Query parameter order should not matter", uri1, uri2);
     }
 
+    @Test
+    @Ignore("Fails due CAMEL-5183")
+    public void testConfigurationPortParameter() throws Exception {
+        EndpointConfiguration cfg1 = ConfigurationHelper.createConfiguration("mapped://foo:8080?one=true&two=2&port=123",
context);
+        String uri1 = cfg1.toUriString(EndpointConfiguration.UriFormat.Complete);
+        assertEquals("mapped://foo:8080?one=true&port=123&two=2", uri1);
+    }
+
     private static class ConfiguredComponent implements Component {
         private CamelContext context;
 



Mime
View raw message