camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r954840 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/model/ camel-core/src/test/java/org/apache/camel/model/ camel-core/src/test/java/org/apache/camel/processor/ components/camel-spring/src/test/java/org/apache/camel/spring/...
Date Tue, 15 Jun 2010 11:44:23 GMT
Author: ningjiang
Date: Tue Jun 15 11:44:22 2010
New Revision: 954840

URL: http://svn.apache.org/viewvc?rev=954840&view=rev
Log:
CAMEL-2811 the routeContext should be independent on CamelContext

Added:
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteRefMultipleCamelContextRefsTest.java
  (with props)
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/RouteRefMultipleCamelContextRefsTest.xml
  (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/SendDefinition.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/model/StartingRoutesErrorReportedTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DualPipelineTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RandomLoadBalanceJavaDSLBuilderTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RandomLoadBalanceTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/XmlConfigTestSupport.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromDefinition.java?rev=954840&r1=954839&r2=954840&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromDefinition.java Tue Jun
15 11:44:22 2010
@@ -69,9 +69,11 @@ public class FromDefinition extends Opti
 
     public Endpoint resolveEndpoint(RouteContext context) {
         if (endpoint == null) {
-            endpoint = context.resolveEndpoint(getUri(), getRef());
+            return context.resolveEndpoint(getUri(), getRef());
+        } else {
+            return endpoint;
         }
-        return endpoint;
+        
     }
 
     // Properties

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/SendDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SendDefinition.java?rev=954840&r1=954839&r2=954840&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/SendDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/SendDefinition.java Tue Jun
15 11:44:22 2010
@@ -60,9 +60,10 @@ public abstract class SendDefinition<Typ
 
     public Endpoint resolveEndpoint(RouteContext context) {
         if (endpoint == null) {
-            endpoint = context.resolveEndpoint(getUri(), getRef());
+            return context.resolveEndpoint(getUri(), getRef());
+        } else {
+            return endpoint;
         }
-        return endpoint;
     }
 
     // Properties

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/model/StartingRoutesErrorReportedTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/model/StartingRoutesErrorReportedTest.java?rev=954840&r1=954839&r2=954840&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/model/StartingRoutesErrorReportedTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/model/StartingRoutesErrorReportedTest.java
Tue Jun 15 11:44:22 2010
@@ -51,7 +51,7 @@ public class StartingRoutesErrorReported
             context.start();
             fail();
         } catch (FailedToCreateRouteException e) {
-            assertTrue(e.getMessage().startsWith("Failed to create route route2 at: >>>
To[mock:result?foo=bar] <<< in route: Route[[From[direct://start]] -> [To[mock:result?foo=bar]]]
because of"));
+            assertTrue(e.getMessage().startsWith("Failed to create route route2 at: >>>
To[mock:result?foo=bar] <<< in route: Route[[From[direct:start]] -> [To[mock:result?foo=bar]]]
because of"));
         }
     }
 
@@ -67,7 +67,7 @@ public class StartingRoutesErrorReported
             });
             context.start();
         } catch (FailedToCreateRouteException e) {
-            assertTrue(e.getMessage().startsWith("Failed to create route route3 at: >>>
Bean[ref:] <<< in route: Route[[From[direct://start]] -> [To[mock://foo], Bean[ref:]]...
because of"));
+            assertTrue(e.getMessage().startsWith("Failed to create route route3 at: >>>
Bean[ref:] <<< in route: Route[[From[direct:start]] -> [To[mock:foo], Bean[ref:]]]
because of"));
         }
     }
 

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DualPipelineTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DualPipelineTest.java?rev=954840&r1=954839&r2=954840&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DualPipelineTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DualPipelineTest.java
Tue Jun 15 11:44:22 2010
@@ -48,13 +48,13 @@ public class DualPipelineTest extends Co
         assertEquals(4, pd2.getOutputs().size());
 
         SendDefinition send1 = assertIsInstanceOf(SendDefinition.class, pd1.getOutputs().get(2));
-        assertEquals("mock://b", send1.getEndpoint().getEndpointUri());
+        assertEquals("mock:b", send1.getUri());
 
         SendDefinition send2 = assertIsInstanceOf(SendDefinition.class, pd2.getOutputs().get(3));
-        assertEquals("mock://e", send2.getEndpoint().getEndpointUri());
+        assertEquals("mock:e", send2.getUri());
 
         SendDefinition send = assertIsInstanceOf(SendDefinition.class, context.getRouteDefinitions().get(0).getOutputs().get(1));
-        assertEquals("mock://result", send.getEndpoint().getEndpointUri());
+        assertEquals("mock:result", send.getUri());
     }
 
     @Override

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RandomLoadBalanceJavaDSLBuilderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RandomLoadBalanceJavaDSLBuilderTest.java?rev=954840&r1=954839&r2=954840&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RandomLoadBalanceJavaDSLBuilderTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RandomLoadBalanceJavaDSLBuilderTest.java
Tue Jun 15 11:44:22 2010
@@ -60,7 +60,7 @@ public class RandomLoadBalanceJavaDSLBui
         RouteDefinition route = context.getRouteDefinitions().get(0);
 
         // the start of the route
-        sb.append("from(\"" + route.getInputs().get(0).getEndpoint().getEndpointUri() + "\")");
+        sb.append("from(\"" + route.getInputs().get(0).getUri() + "\")");
 
         // navigate the route and add Java DSL to the sb
         navigateDefinition(route, sb);
@@ -102,7 +102,7 @@ public class RandomLoadBalanceJavaDSLBui
 
         if (defn instanceof SendDefinition) {
             SendDefinition send = (SendDefinition) defn;
-            sb.append(".to(\"" + send.getEndpoint().getEndpointUri() + "\")");
+            sb.append(".to(\"" + send.getUri() + "\")");
         }
 
         List<ProcessorDefinition> children = defn.getOutputs();

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RandomLoadBalanceTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RandomLoadBalanceTest.java?rev=954840&r1=954839&r2=954840&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RandomLoadBalanceTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RandomLoadBalanceTest.java
Tue Jun 15 11:44:22 2010
@@ -29,16 +29,16 @@ public class RandomLoadBalanceTest exten
     protected void setUp() throws Exception {
         super.setUp();
 
-        x = getMockEndpoint("mock:x");
-        y = getMockEndpoint("mock:y");
-        z = getMockEndpoint("mock:z");
+        x = getMockEndpoint("mock://x");
+        y = getMockEndpoint("mock://y");
+        z = getMockEndpoint("mock://z");
     }
 
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                from("direct:start").loadBalance().
-                random().to("mock:x", "mock:y", "mock:z");
+                from("direct://start").loadBalance().
+                random().to("mock://x", "mock://y", "mock://z");
             }
         };
     }

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteRefMultipleCamelContextRefsTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteRefMultipleCamelContextRefsTest.java?rev=954840&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteRefMultipleCamelContextRefsTest.java
(added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteRefMultipleCamelContextRefsTest.java
Tue Jun 15 11:44:22 2010
@@ -0,0 +1,62 @@
+/**
+ * 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.spring.config;
+
+import junit.framework.TestCase;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision$
+ */
+public class RouteRefMultipleCamelContextRefsTest extends TestCase {
+
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/RouteRefMultipleCamelContextRefsTest.xml");
+    }
+
+    public void testSpringTwoCamelContextDirectEndpoint() throws Exception {
+        AbstractXmlApplicationContext ac = createApplicationContext();
+        ac.start();
+
+        CamelContext camel1 = (CamelContext) ac.getBean("myCamel-1", CamelContext.class);
+        CamelContext camel2 = (CamelContext) ac.getBean("myCamel-2", CamelContext.class);
+
+        Endpoint start1 = camel1.getEndpoint("direct:start");
+        Endpoint start2 = camel2.getEndpoint("direct:start");
+        assertNotSame(start1, start2);
+        
+        MockEndpoint mock1 = camel1.getEndpoint("mock:result", MockEndpoint.class);
+        mock1.expectedBodiesReceived("Hello World");
+
+        MockEndpoint mock2 = camel2.getEndpoint("mock:result", MockEndpoint.class);
+        mock2.expectedBodiesReceived("Bye World");
+
+        camel1.createProducerTemplate().sendBody("direct:start", "Hello World");
+        camel2.createProducerTemplate().sendBody("direct:start", "Bye World");
+
+        mock1.assertIsSatisfied();
+        mock2.assertIsSatisfied();
+
+        ac.stop();
+    }
+    
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteRefMultipleCamelContextRefsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteRefMultipleCamelContextRefsTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/XmlConfigTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/XmlConfigTestSupport.java?rev=954840&r1=954839&r2=954840&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/XmlConfigTestSupport.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/XmlConfigTestSupport.java
Tue Jun 15 11:44:22 2010
@@ -44,7 +44,7 @@ public class XmlConfigTestSupport extend
             List<FromDefinition> inputs = route.getInputs();
             assertEquals("Number of inputs", 1, inputs.size());
             FromDefinition fromType = inputs.get(0);
-            assertEquals("from URI", "seda://test.a", fromType.getEndpoint().getEndpointUri());
+            assertEquals("from URI", "seda:test.a", fromType.getUri());
 
             List<ProcessorDefinition> outputs = route.getOutputs();
             assertEquals("Number of outputs", 1, outputs.size());

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/RouteRefMultipleCamelContextRefsTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/RouteRefMultipleCamelContextRefsTest.xml?rev=954840&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/RouteRefMultipleCamelContextRefsTest.xml
(added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/RouteRefMultipleCamelContextRefsTest.xml
Tue Jun 15 11:44:22 2010
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <!-- START SNIPPET: e1 -->
+    <routeContext id="myCoolRoute" xmlns="http://camel.apache.org/schema/spring">
+        <!-- we can have a route -->
+        <route id="cool">
+            <from uri="direct:start"/>
+            <to uri="mock:result"/>
+        </route>
+    </routeContext>
+
+    <camelContext id="myCamel-1" xmlns="http://camel.apache.org/schema/spring">
+        <routeContextRef ref="myCoolRoute"/>
+    </camelContext>
+    
+    <camelContext id="myCamel-2" xmlns="http://camel.apache.org/schema/spring">
+        <routeContextRef ref="myCoolRoute"/>
+    </camelContext>
+    <!-- END SNIPPET: e1 -->
+
+</beans>

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/RouteRefMultipleCamelContextRefsTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/RouteRefMultipleCamelContextRefsTest.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/RouteRefMultipleCamelContextRefsTest.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message