camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r1171270 - in /camel/trunk/components/camel-spring-ws/src: main/java/org/apache/camel/component/spring/ws/ test/java/org/apache/camel/component/spring/ws/
Date Thu, 15 Sep 2011 20:53:41 GMT
Author: hadrian
Date: Thu Sep 15 20:53:40 2011
New Revision: 1171270

URL: http://svn.apache.org/viewvc?rev=1171270&view=rev
Log:
CAMEL-4455. Use valid URIs in camel-spring-ws

Modified:
    camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceComponent.java
    camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConfiguration.java
    camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceEndpoint.java
    camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerExceptionPropagationRouteTest.java

Modified: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceComponent.java?rev=1171270&r1=1171269&r2=1171270&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceComponent.java
(original)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceComponent.java
Thu Sep 15 20:53:40 2011
@@ -54,6 +54,12 @@ public class SpringWebserviceComponent e
         super(context);
     }
 
+    @Deprecated
+    protected String preProcessUri(String uri) {
+        String[] u = uri.split("\\?");
+        return u[0].replaceAll("%7B", "(").replaceAll("%7D", ")") + (u.length > 1 ? "?"
+ u[1] : "");
+    }
+
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object>
parameters) throws Exception {
         SpringWebserviceConfiguration configuration = new SpringWebserviceConfiguration();
@@ -61,11 +67,10 @@ public class SpringWebserviceComponent e
         addProducerConfiguration(remaining, parameters, configuration);
         addXmlConverterToConfiguration(parameters, configuration);
         setProperties(configuration, parameters);
-        return new SpringWebserviceEndpoint(this, configuration);
+        return new SpringWebserviceEndpoint(this, uri, configuration);
     }
 
-    private void addConsumerConfiguration(String remaining, Map<String, Object> parameters,
-                                          SpringWebserviceConfiguration configuration) {
+    private void addConsumerConfiguration(String remaining, Map<String, Object> parameters,
SpringWebserviceConfiguration configuration) {
         EndpointMappingType type = EndpointMappingType.getTypeFromUriPrefix(remaining);
         if (type != null) {
             LOG.debug("Building Spring Web Services consumer of type " + type);
@@ -75,12 +80,8 @@ public class SpringWebserviceComponent e
             } else {
                 addEndpointMappingToConfiguration(parameters, configuration);
             }
-            if (EndpointMappingType.XPATHRESULT.equals(type)) {
-                XPathExpression expression = getXPathExpressionFromParameters(parameters);
-                configuration.setEndpointMappingKey(new EndpointMappingKey(type, lookupKey,
expression));
-            } else {
-                configuration.setEndpointMappingKey(new EndpointMappingKey(type, lookupKey,
null));
-            }
+            configuration.setEndpointMappingKey(new EndpointMappingKey(type, lookupKey, 
+                type.equals(EndpointMappingType.XPATHRESULT) ? getXPathExpressionFromParameters(parameters)
: null));
         }
     }
 
@@ -115,7 +116,8 @@ public class SpringWebserviceComponent e
 
     private String getLookupKey(String remaining, EndpointMappingType type) {
         String lookupKey = remaining.substring(type.getPrefix().length());
-        return lookupKey.startsWith("//") ? lookupKey.substring(2) : lookupKey;
+        lookupKey = lookupKey.startsWith("//") ? lookupKey.substring(2) : lookupKey;
+        return SpringWebserviceConfiguration.decode(lookupKey);
     }
 
     private XPathExpression getXPathExpressionFromParameters(Map<String, Object> parameters)
{

Modified: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConfiguration.java?rev=1171270&r1=1171269&r2=1171270&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConfiguration.java
(original)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConfiguration.java
Thu Sep 15 20:53:40 2011
@@ -58,7 +58,7 @@ public class SpringWebserviceConfigurati
     public String getEndpointUri() {
         if (endpointMappingKey != null) {
             // only for consumers, use lookup key as endpoint uri/key
-            return endpointMappingKey.getLookupKey();
+            return encode(endpointMappingKey.getLookupKey());
         } else if (webServiceTemplate != null) {
             return webServiceTemplate.getDefaultUri();
         }
@@ -108,4 +108,14 @@ public class SpringWebserviceConfigurati
     public void setXmlConverter(XmlConverter xmlConverter) {
         this.xmlConverter = xmlConverter;
     }
+
+    public static String encode(String uri) {
+        int i = uri.lastIndexOf('}');
+        return i == -1 ? uri : (uri.subSequence(0, i) + ")" + uri.substring(i + 1)).replaceFirst("\\{",
"(");
+    }
+
+    public static String decode(String uri) {
+        int i = uri.lastIndexOf(')');
+        return i == -1 ? uri : (uri.subSequence(0, i) + "}" + uri.substring(i + 1)).replaceFirst("\\(",
"{");
+    }
 }

Modified: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceEndpoint.java?rev=1171270&r1=1171269&r2=1171270&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceEndpoint.java
(original)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceEndpoint.java
Thu Sep 15 20:53:40 2011
@@ -26,8 +26,8 @@ public class SpringWebserviceEndpoint ex
 
     private SpringWebserviceConfiguration configuration;
 
-    public SpringWebserviceEndpoint(Component component, SpringWebserviceConfiguration configuration)
{
-        super(configuration.getEndpointUri(), component);
+    public SpringWebserviceEndpoint(Component component, String uri, SpringWebserviceConfiguration
configuration) {
+        super(uri, component);
         this.configuration = configuration;
     }
 
@@ -50,5 +50,4 @@ public class SpringWebserviceEndpoint ex
     public SpringWebserviceConfiguration getConfiguration() {
         return configuration;
     }
-
 }

Modified: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerExceptionPropagationRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerExceptionPropagationRouteTest.java?rev=1171270&r1=1171269&r2=1171270&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerExceptionPropagationRouteTest.java
(original)
+++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerExceptionPropagationRouteTest.java
Thu Sep 15 20:53:40 2011
@@ -17,13 +17,17 @@
 package org.apache.camel.component.spring.ws;
 
 import java.io.StringReader;
+import java.net.URI;
+
 import javax.xml.transform.stream.StreamSource;
 
+import org.apache.camel.Endpoint;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.spring.ws.bean.CamelEndpointMapping;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -67,6 +71,15 @@ public class ConsumerExceptionPropagatio
         return registry;
     }
 
+    @Ignore("For now getEndpointUri does not return the initial uri. Info like the endpoint
scheme is lost")
+    public void testValidUri() throws Exception {
+        String deprecate = "spring-ws:rootqname:{http://www.webserviceX.NET/}GetQuote?endpointMapping=#endpointMapping";
+        String sanitized = "spring-ws:rootqname:(http://www.webserviceX.NET/)GetQuote?endpointMapping=#endpointMapping";
+        Endpoint endpoint = context.getComponent("spring-ws").createEndpoint(deprecate);

+        assertEquals(sanitized, endpoint.getEndpointUri());
+        assertNotNull(new URI(endpoint.getEndpointUri()));
+    }
+
     @Test
     public void consumeWebserviceAndTestForSoapFault() throws Exception {
         StreamSource source = new StreamSource(new StringReader(xmlRequestForGoogleStockQuote));
@@ -84,5 +97,4 @@ public class ConsumerExceptionPropagatio
             }
         };
     }
-
 }
\ No newline at end of file



Mime
View raw message