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 2011/09/15 20:31:55 UTC

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

Author: davsclaus
Date: Thu Sep 15 18:31:55 2011
New Revision: 1171215

URL: http://svn.apache.org/viewvc?rev=1171215&view=rev
Log:
CAMEL-4028: Simple language can change function start/end tokens. Thanks to Taariq for the patch.

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

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=1171215&r1=1171214&r2=1171215&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 Sep 15 18:31:55 2011
@@ -94,6 +94,23 @@ public class SimpleLanguage implements L
 
     private Class<?> resultType;
 
+    /**
+     * Default constructor.
+     */
+    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;
     }
@@ -172,5 +189,4 @@ public class SimpleLanguage implements L
     public static void changeFunctionEndToken(String... endToken) {
         SimpleTokenizer.changeFunctionEndToken(endToken);
     }
-
 }

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/SpringChangeFunctionStartFunctionEndTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/SpringChangeFunctionStartFunctionEndTest.java?rev=1171215&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/SpringChangeFunctionStartFunctionEndTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/SpringChangeFunctionStartFunctionEndTest.java Thu Sep 15 18:31:55 2011
@@ -0,0 +1,39 @@
+/**
+ * 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;
+
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * Tests changing the function start and function end tokens using a spring bean.
+ */
+public class SpringChangeFunctionStartFunctionEndTest extends SpringTestSupport {
+
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/SpringChangeFunctionStartFunctionEndTest.xml");
+    }
+
+    public void testSimpleWithPrefix() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Custom tokens is cool");
+
+        template.sendBody("direct:start", "Custom tokens");
+
+        assertMockEndpointsSatisfied();
+    }
+
+}

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

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

Added: 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=1171215&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/SpringChangeFunctionStartFunctionEndTest.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/SpringChangeFunctionStartFunctionEndTest.xml Thu Sep 15 18:31:55 2011
@@ -0,0 +1,44 @@
+<?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">
+
+    <!-- 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="]"/>
+    </bean>
+
+    <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+        <!-- This route transforms the body using simple with custom prefix and suffix tokens configured by "simple" bean,
+        the text ' is cool' is appended to the body and then routed to mock:result. -->
+        <route>
+            <from uri="direct:start"/>
+            <transform>
+                <simple>[body] is cool</simple>
+            </transform>
+            <to uri="mock:result"/>
+        </route>
+
+    </camelContext>
+
+</beans>

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

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

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