You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2010/12/15 09:39:15 UTC

svn commit: r1049455 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/impl/ test/java/org/apache/camel/management/ test/java/org/apache/camel/processor/intercept/

Author: davsclaus
Date: Wed Dec 15 08:39:14 2010
New Revision: 1049455

URL: http://svn.apache.org/viewvc?rev=1049455&view=rev
Log:
CAMEL-3430: Fixed intercept send to endpoint with endpoints having parameters.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSendToEndpointWithParametersTest.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationCustomMBeanTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=1049455&r1=1049454&r2=1049455&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Wed Dec 15 08:39:14 2010
@@ -357,7 +357,7 @@ public class DefaultCamelContext extends
             for (LifecycleStrategy strategy : lifecycleStrategies) {
                 strategy.onEndpointAdd(endpoint);
             }
-            addEndpointToRegistry(uri, endpoint);
+            addEndpointToRegistry(endpoint);
             if (oldEndpoint != null) {
                 stopServices(oldEndpoint);
             }
@@ -449,7 +449,7 @@ public class DefaultCamelContext extends
 
                     if (answer != null) {
                         addService(answer);
-                        answer = addEndpointToRegistry(uri, answer);
+                        answer = addEndpointToRegistry(answer);
                     }
                 } catch (Exception e) {
                     throw new ResolveEndpointFailedException(uri, e);
@@ -487,7 +487,7 @@ public class DefaultCamelContext extends
             endpointStrategies.add(strategy);
             for (Endpoint endpoint : getEndpoints()) {
                 Endpoint newEndpoint = strategy.registerEndpoint(endpoint.getEndpointUri(), endpoint);
-                if (newEndpoint != endpoint) {
+                if (newEndpoint != null) {
                     endpoints.put(getEndpointKey(newEndpoint.getEndpointUri(), newEndpoint), newEndpoint);
                 }
             }
@@ -497,15 +497,14 @@ public class DefaultCamelContext extends
     /**
      * Strategy to add the given endpoint to the internal endpoint registry
      *
-     * @param uri      uri of endpoint
      * @param endpoint the endpoint to add
      * @return the added endpoint
      */
-    protected Endpoint addEndpointToRegistry(String uri, Endpoint endpoint) {
+    protected Endpoint addEndpointToRegistry(Endpoint endpoint) {
         for (EndpointStrategy strategy : endpointStrategies) {
-            endpoint = strategy.registerEndpoint(uri, endpoint);
+            endpoint = strategy.registerEndpoint(endpoint.getEndpointUri(), endpoint);
         }
-        endpoints.put(getEndpointKey(uri, endpoint), endpoint);
+        endpoints.put(getEndpointKey(endpoint.getEndpointUri(), endpoint), endpoint);
         return endpoint;
     }
 

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationCustomMBeanTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationCustomMBeanTest.java?rev=1049455&r1=1049454&r2=1049455&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationCustomMBeanTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationCustomMBeanTest.java Wed Dec 15 08:39:14 2010
@@ -120,7 +120,7 @@ public class JmxInstrumentationCustomMBe
 
     private class CustomComponent extends DefaultComponent {
         protected Endpoint createEndpoint(final String uri, final String remaining, final Map<String, Object> parameters) throws Exception {
-            return new CustomEndpoint("custom", this);
+            return new CustomEndpoint(uri, this);
         }
     }
 }

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSendToEndpointWithParametersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSendToEndpointWithParametersTest.java?rev=1049455&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSendToEndpointWithParametersTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSendToEndpointWithParametersTest.java Wed Dec 15 08:39:14 2010
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor.intercept;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.RouteDefinition;
+
+/**
+ * @version $Revision$
+ */
+public class InterceptSendToEndpointWithParametersTest extends ContextTestSupport {
+
+    public void testInterceptSendToEndpoint() throws Exception {
+        RouteDefinition route = context.getRouteDefinitions().get(0);
+        route.adviceWith(context, new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                interceptSendToEndpoint("log*").to("mock:http").skipSendToOriginalEndpoint();
+            }
+        });
+
+        getMockEndpoint("mock:http").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("log://foo?groupSize=5&level=WARN");
+            }
+        };
+    }
+
+}