Author: davsclaus
Date: Sat Jun  4 19:39:54 2011
New Revision: 1131477

URL: http://svn.apache.org/viewvc?rev=1131477&view=rev
Log:
CAMEL-4053: Fixed parent/child relationship on model, before custom 
InterceptStrategy is wrapped with the model as parameter.

Modified:
    
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DefaultChannel.java
    
camel/trunk/camel-core/src/test/java/org/apache/camel/model/ModelSanityCheckerTest.java
    
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/intercept/SpringParentChildInterceptStrategyTest.java

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DefaultChannel.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DefaultChannel.java?rev=1131477&r1=1131476&r2=1131477&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DefaultChannel.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DefaultChannel.java
 Sat Jun  4 19:39:54 2011
@@ -169,6 +169,16 @@ public class DefaultChannel extends Serv
         // so if a child is set then use it, if not then its the original 
output used
         ProcessorDefinition<?> targetOutputDef = childDefinition != null ? 
childDefinition : outputDefinition;
 
+        // fix parent/child relationship. This will be the case of the routes 
has been
+        // defined using XML DSL or end user may have manually assembled a 
route from the model.
+        // Background note: parent/child relationship is assembled on-the-fly 
when using Java DSL (fluent builders)
+        // where as when using XML DSL (JAXB) then it fixed after, but if 
people are using custom interceptors
+        // then we need to fix the parent/child relationship beforehand, and 
thus we can do it here
+        // ideally we need the design time route -> runtime route to be a 
2-phase pass (scheduled work for Camel 3.0)
+        if (childDefinition != null && outputDefinition != childDefinition) {
+            childDefinition.setParent(outputDefinition);
+        }
+
         // first wrap the output with the managed strategy if any
         InterceptStrategy managed = routeContext.getManagedInterceptStrategy();
         if (managed != null) {

Modified: 
camel/trunk/camel-core/src/test/java/org/apache/camel/model/ModelSanityCheckerTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/model/ModelSanityCheckerTest.java?rev=1131477&r1=1131476&r2=1131477&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/test/java/org/apache/camel/model/ModelSanityCheckerTest.java
 (original)
+++ 
camel/trunk/camel-core/src/test/java/org/apache/camel/model/ModelSanityCheckerTest.java
 Sat Jun  4 19:39:54 2011
@@ -90,6 +90,11 @@ public class ModelSanityCheckerTest exte
             for (Method method : clazz.getDeclaredMethods()) {
                 LOG.debug("Class {} has method {}", clazz.getName(), 
method.getName());
 
+                // special for OptionalIdentifiedDefinition as it has setter, 
so we should skip it
+                if 
(clazz.getCanonicalName().equals(OptionalIdentifiedDefinition.class.getCanonicalName()))
 {
+                    continue;
+                }
+
                 // does the method have a jaxb annotation?
                 boolean attribute = method.getAnnotation(XmlAttribute.class) 
!= null;
                 boolean element = method.getAnnotation(XmlElement.class) != 
null;

Modified: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/intercept/SpringParentChildInterceptStrategyTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/intercept/SpringParentChildInterceptStrategyTest.java?rev=1131477&r1=1131476&r2=1131477&view=diff
==============================================================================
--- 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/intercept/SpringParentChildInterceptStrategyTest.java
 (original)
+++ 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/intercept/SpringParentChildInterceptStrategyTest.java
 Sat Jun  4 19:39:54 2011
@@ -21,26 +21,8 @@ import org.apache.camel.processor.interc
 
 import static 
org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
 
-/**
- *
- */
 public class SpringParentChildInterceptStrategyTest extends 
ParentChildInterceptStrategyTest {
 
-    public void testParentChild() throws Exception {
-        getMockEndpoint("mock:done").expectedMessageCount(1);
-        getMockEndpoint("mock:a").expectedMessageCount(1);
-        getMockEndpoint("mock:b").expectedMessageCount(1);
-        getMockEndpoint("mock:c").expectedMessageCount(1);
-        getMockEndpoint("mock:d").expectedMessageCount(0);
-        getMockEndpoint("mock:e").expectedMessageCount(0);
-
-        template.sendBody("direct:start", "Hello Camel");
-
-        assertMockEndpointsSatisfied();
-
-        assertEquals(7, LIST.size());
-    }
-
     protected CamelContext createCamelContext() throws Exception {
         return createSpringCamelContext(this, 
"org/apache/camel/spring/processor/intercept/SpringParentChildInterceptStrategyTest.xml");
     }


Reply via email to