Author: joed
Date: Thu Dec 16 19:30:27 2010
New Revision: 1050112

URL: http://svn.apache.org/viewvc?rev=1050112&view=rev
Log:
Sets the Endpoint on FromDefinition when resolve is called.


Added:
    
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/FromEndpointRouteDefinitionTest.java
Modified:
    
camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromDefinition.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=1050112&r1=1050111&r2=1050112&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 
Thu Dec 16 19:30:27 2010
@@ -70,11 +70,9 @@ public class FromDefinition extends Opti
 
     public Endpoint resolveEndpoint(RouteContext context) {
         if (endpoint == null) {
-            return context.resolveEndpoint(getUri(), getRef());
-        } else {
-            return endpoint;
+            endpoint = context.resolveEndpoint(getUri(), getRef());
         }
-        
+        return endpoint;
     }
 
     // Properties

Added: 
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/FromEndpointRouteDefinitionTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/FromEndpointRouteDefinitionTest.java?rev=1050112&view=auto
==============================================================================
--- 
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/FromEndpointRouteDefinitionTest.java
 (added)
+++ 
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/FromEndpointRouteDefinitionTest.java
 Thu Dec 16 19:30:27 2010
@@ -0,0 +1,50 @@
+/**
+ * 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.impl;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.model.FromDefinition;
+import org.apache.camel.model.RouteDefinition;
+
+public class FromEndpointRouteDefinitionTest extends ContextTestSupport {
+    private MockEndpoint results;
+    private Object expectedBody = "<hello>world!</hello>";
+
+    public void testReceivedMessageHasFromEndpointSet() throws Exception {
+        RouteDefinition route = new RouteDefinition();
+        //build a route
+        route.from("direct:start");
+        route.to("mock:results");
+
+        context.startRoute(route);
+
+        results = getMockEndpoint("mock:results");
+        results.expectedBodiesReceived(expectedBody);
+
+        template.sendBody("direct:start", expectedBody);
+
+        results.assertIsSatisfied();
+
+        Endpoint fromEndpoint = route.getInputs().get(0).getEndpoint();
+        assertNotNull("exchange.fromEndpoint() is null!", fromEndpoint);
+        assertEquals("fromEndpoint URI", "direct://start", 
fromEndpoint.getEndpointUri());
+    }
+}
+


Reply via email to