Author: davsclaus
Date: Sat Jun 11 13:15:44 2011
New Revision: 1134626

URL: http://svn.apache.org/viewvc?rev=1134626&view=rev
Log:
CAMEL-4089: Fixed issue when using pattern together with a custom id attribute 
in XML DSL

Added:
    
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetExchangePatternWithCustomIdTest.java
      - copied, changed from r1134557, 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetExchangePatternTest.java
    
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setExchangePatternWithCustomId.xml
      - copied, changed from r1134557, 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setExchangePattern.xml
Modified:
    
camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelEndpointFactoryBean.java

Modified: 
camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelEndpointFactoryBean.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelEndpointFactoryBean.java?rev=1134626&r1=1134625&r2=1134626&view=diff
==============================================================================
--- 
camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelEndpointFactoryBean.java
 (original)
+++ 
camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelEndpointFactoryBean.java
 Sat Jun 11 13:15:44 2011
@@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlAttr
 import javax.xml.bind.annotation.XmlTransient;
 
 import org.apache.camel.Endpoint;
+import org.apache.camel.ExchangePattern;
 import org.apache.camel.NoSuchEndpointException;
 
 import static org.apache.camel.util.ObjectHelper.notNull;
@@ -34,6 +35,8 @@ public abstract class AbstractCamelEndpo
     private Boolean singleton;
     @XmlAttribute
     private String uri;
+    @XmlAttribute
+    private ExchangePattern pattern;
     @XmlTransient
     private Endpoint endpoint;
 
@@ -65,4 +68,11 @@ public abstract class AbstractCamelEndpo
         this.uri = uri;
     }
 
+    public ExchangePattern getPattern() {
+        return pattern;
+    }
+
+    public void setPattern(ExchangePattern pattern) {
+        this.pattern = pattern;
+    }
 }

Copied: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetExchangePatternWithCustomIdTest.java
 (from r1134557, 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetExchangePatternTest.java)
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetExchangePatternWithCustomIdTest.java?p2=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetExchangePatternWithCustomIdTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetExchangePatternTest.java&r1=1134557&r2=1134626&rev=1134626&view=diff
==============================================================================
--- 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetExchangePatternTest.java
 (original)
+++ 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetExchangePatternWithCustomIdTest.java
 Sat Jun 11 13:15:44 2011
@@ -17,16 +17,23 @@
 
 package org.apache.camel.spring.processor;
 
-
 import org.apache.camel.CamelContext;
 import org.apache.camel.processor.SetExchangePatternTest;
+
 import static 
org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
 
+public class SpringSetExchangePatternWithCustomIdTest extends 
SetExchangePatternTest {
+
+    @Override
+    public void testToWithInOnlyParam() throws Exception {
+        super.testToWithInOnlyParam();
+
+        // just assert one of the routes has the correct id on the <to> with 
the exchange pattern
+        assertEquals("q", 
context.getRouteDefinitions().get(6).getOutputs().get(0).getId());
+    }
 
-public class SpringSetExchangePatternTest extends SetExchangePatternTest {
-    
     protected CamelContext createCamelContext() throws Exception {
-        return createSpringCamelContext(this, 
"org/apache/camel/spring/processor/setExchangePattern.xml");
+        return createSpringCamelContext(this, 
"org/apache/camel/spring/processor/setExchangePatternWithCustomId.xml");
     }
 
 }

Copied: 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setExchangePatternWithCustomId.xml
 (from r1134557, 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setExchangePattern.xml)
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setExchangePatternWithCustomId.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setExchangePatternWithCustomId.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setExchangePattern.xml&r1=1134557&r2=1134626&rev=1134626&view=diff
==============================================================================
--- 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setExchangePattern.xml
 (original)
+++ 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setExchangePatternWithCustomId.xml
 Sat Jun 11 13:15:44 2011
@@ -22,53 +22,51 @@
        http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-  <!-- START SNIPPET: example -->
   <camelContext xmlns="http://camel.apache.org/schema/spring";>
     <!-- Send the exchange as InOnly -->
     <route>
-      <from uri="direct:testInOut"/>
-      <inOut uri="mock:result"/>
+      <from uri="direct:testInOut" id="a"/>
+      <inOut uri="mock:result" id="b"/>
     </route>
 
     <!-- Send the exchange as InOnly -->
     <route>
-      <from uri="direct:testInOnly"/>
-      <inOnly uri="mock:result"/>
+      <from uri="direct:testInOnly" id="c"/>
+      <inOnly uri="mock:result" id="d"/>
     </route>
 
 
     <!-- lets set the exchange pattern then send it on -->
     <route>
-      <from uri="direct:testSetToInOnlyThenTo"/>
-      <setExchangePattern pattern="InOnly"/>
-      <to uri="mock:result"/>      
+      <from uri="direct:testSetToInOnlyThenTo" id="e"/>
+      <setExchangePattern pattern="InOnly" id="f"/>
+      <to uri="mock:result" id="g"/>
     </route>
     <route>
-      <from uri="direct:testSetToInOutThenTo"/>
-      <setExchangePattern pattern="InOut"/>
-      <to uri="mock:result"/>
+      <from uri="direct:testSetToInOutThenTo" id="h"/>
+      <setExchangePattern pattern="InOut" id="i"/>
+      <to uri="mock:result" id="j"/>
     </route>
     <route>
-      <from uri="direct:testSetExchangePatternInOnly"/>
-      <setExchangePattern pattern="InOnly"/>
-      <to uri="mock:result"/>
+      <from uri="direct:testSetExchangePatternInOnly" id="k"/>
+      <setExchangePattern pattern="InOnly" id="l"/>
+      <to uri="mock:result" id="m"/>
     </route>
 
 
     <!-- Lets pass the pattern as an argument in the to element -->
     <route>
-      <from uri="direct:testToWithInOnlyParam"/>
-      <to uri="mock:result" pattern="InOnly"/>
+      <from uri="direct:testToWithInOnlyParam" id="n"/>
+      <to uri="mock:result" pattern="InOnly" id="o"/>
     </route>
     <route>
-      <from uri="direct:testToWithInOutParam"/>
-      <to uri="mock:result" pattern="InOut"/>
+      <from uri="direct:testToWithInOutParam" id="p"/>
+      <to uri="mock:result" pattern="InOut" id="q"/>
     </route>
     <route>
-      <from uri="direct:testToWithRobustInOnlyParam"/>
-      <to uri="mock:result" pattern="RobustInOnly"/>
+      <from uri="direct:testToWithRobustInOnlyParam" id="r"/>
+      <to uri="mock:result" pattern="RobustInOnly" id="s"/>
     </route>
    </camelContext>
-   <!-- END SNIPPET: example -->
 
 </beans>


Reply via email to