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 2012/02/23 13:11:20 UTC

svn commit: r1292760 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/language/simple/ components/camel-spring/src/test/java/org/apache/camel/language/ components/camel-spring/src/test/resources/org/apache/camel/language/ components/camel-s...

Author: davsclaus
Date: Thu Feb 23 12:11:19 2012
New Revision: 1292760

URL: http://svn.apache.org/viewvc?rev=1292760&view=rev
Log:
CAMEL-4988: Fixed simple languauge issue with wire by constructor when using spring. And using custom start/end tokens should use the setter instead of the ctr.

Added:
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/language/SpringSimpleWeirdIssueTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/language/SpringSimpleWeirdIssueTest.xml
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/SpringChangeFunctionStartFunctionEndTest.xml

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java?rev=1292760&r1=1292759&r2=1292760&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java Thu Feb 23 12:11:19 2012
@@ -101,17 +101,6 @@ public class SimpleLanguage implements L
     public SimpleLanguage() {
     }
 
-    /**
-     * Constructor that customizes the function start and end tokens.
-     *
-     * @param functionStartToken The function start token.
-     * @param functionEndToken   The function end token.
-     */
-    public SimpleLanguage(String functionStartToken, String functionEndToken) {
-        changeFunctionStartToken(functionStartToken);
-        changeFunctionEndToken(functionEndToken);
-    }
-
     public Class<?> getResultType() {
         return resultType;
     }
@@ -177,7 +166,7 @@ public class SimpleLanguage implements L
      * This can be used to alter the function tokens to avoid clashes with other
      * frameworks etc.
      * <p/>
-     * The default start tokens is <tt>${</tt> and <tt>$simple{}</tt>.
+     * The default start tokens is <tt>${</tt> and <tt>$simple{</tt>.
      *
      * @param startToken new start token(s) to be used for functions
      */
@@ -198,4 +187,32 @@ public class SimpleLanguage implements L
     public static void changeFunctionEndToken(String... endToken) {
         SimpleTokenizer.changeFunctionEndToken(endToken);
     }
+
+    /**
+     * Change the start token used for functions.
+     * <p/>
+     * This can be used to alter the function tokens to avoid clashes with other
+     * frameworks etc.
+     * <p/>
+     * The default start tokens is <tt>${</tt> and <tt>$simple{</tt>.
+     *
+     * @param startToken new start token to be used for functions
+     */
+    public void setFunctionStartToken(String startToken) {
+        changeFunctionStartToken(startToken);
+    }
+
+    /**
+     * Change the end token used for functions.
+     * <p/>
+     * This can be used to alter the function tokens to avoid clashes with other
+     * frameworks etc.
+     * <p/>
+     * The default end token is <tt>}</tt>
+     *
+     * @param endToken new end token to be used for functions
+     */
+    public void setFunctionEndToken(String endToken) {
+        changeFunctionEndToken(endToken);
+    }
 }

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/language/SpringSimpleWeirdIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/language/SpringSimpleWeirdIssueTest.java?rev=1292760&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/language/SpringSimpleWeirdIssueTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/language/SpringSimpleWeirdIssueTest.java Thu Feb 23 12:11:19 2012
@@ -0,0 +1,38 @@
+/**
+ * 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.language;
+
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SpringSimpleWeirdIssueTest extends SpringTestSupport {
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/language/SpringSimpleWeirdIssueTest.xml");
+    }
+    
+    public void testSimple() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
+
+        template.sendBody("direct:start", "World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+}

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/language/SpringSimpleWeirdIssueTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/language/SpringSimpleWeirdIssueTest.xml?rev=1292760&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/language/SpringSimpleWeirdIssueTest.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/language/SpringSimpleWeirdIssueTest.xml Thu Feb 23 12:11:19 2012
@@ -0,0 +1,39 @@
+<?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.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+  
+  <bean id="myString" class="java.lang.String">
+    <constructor-arg index="0" value="weird"/>
+  </bean>
+
+  <camelContext xmlns="http://camel.apache.org/schema/spring">
+      <route>
+	      <from uri="direct:start"/>
+        <setBody>
+          <simple>Hello ${body}</simple>
+        </setBody>
+        <to uri="mock:result"/>
+      </route>
+  </camelContext>
+
+</beans>

Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/SpringChangeFunctionStartFunctionEndTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/SpringChangeFunctionStartFunctionEndTest.xml?rev=1292760&r1=1292759&r2=1292760&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/SpringChangeFunctionStartFunctionEndTest.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/SpringChangeFunctionStartFunctionEndTest.xml Thu Feb 23 12:11:19 2012
@@ -23,8 +23,8 @@
 
     <!-- configure Simple to use custom prefix/suffix tokens -->
     <bean id="simple" class="org.apache.camel.language.simple.SimpleLanguage">
-      <constructor-arg name="functionStartToken" value="["/>
-      <constructor-arg name="functionEndToken" value="]"/>
+      <property name="functionStartToken" value="["/>
+      <property name="functionEndToken" value="]"/>
     </bean>
 
     <camelContext xmlns="http://camel.apache.org/schema/spring">