camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1427787 - in /camel/trunk: components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/ components/camel-stringtemplate/src/test/java/org/apache/camel/component/stringtemplate/ components/camel-stringtemplate/sr...
Date Wed, 02 Jan 2013 13:46:01 GMT
Author: davsclaus
Date: Wed Jan  2 13:46:01 2013
New Revision: 1427787

URL: http://svn.apache.org/viewvc?rev=1427787&view=rev
Log:
CAMEL-5923: Upgraded to stringtemplate 4.0.2

Modified:
    camel/trunk/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateEndpoint.java
    camel/trunk/components/camel-stringtemplate/src/test/java/org/apache/camel/component/stringtemplate/StringTemplateContentCacheTest.java
    camel/trunk/components/camel-stringtemplate/src/test/resources/org/apache/camel/component/stringtemplate/Concurrent.tm
    camel/trunk/components/camel-stringtemplate/src/test/resources/org/apache/camel/component/stringtemplate/letter.tm
    camel/trunk/components/camel-stringtemplate/src/test/resources/org/apache/camel/component/stringtemplate/template.tm
    camel/trunk/parent/pom.xml

Modified: camel/trunk/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateEndpoint.java?rev=1427787&r1=1427786&r2=1427787&view=diff
==============================================================================
--- camel/trunk/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateEndpoint.java
(original)
+++ camel/trunk/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateEndpoint.java
Wed Jan  2 13:46:01 2013
@@ -19,14 +19,15 @@ package org.apache.camel.component.strin
 import java.io.StringWriter;
 import java.util.Map;
 
-import org.antlr.stringtemplate.AutoIndentWriter;
-import org.antlr.stringtemplate.StringTemplate;
 import org.apache.camel.Component;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.Message;
 import org.apache.camel.component.ResourceEndpoint;
 import org.apache.camel.util.ExchangeHelper;
+import org.stringtemplate.v4.AutoIndentWriter;
+import org.stringtemplate.v4.NoIndentWriter;
+import org.stringtemplate.v4.ST;
 
 /**
  * @version 
@@ -57,10 +58,12 @@ public class StringTemplateEndpoint exte
 
         // getResourceAsInputStream also considers the content cache
         String text = exchange.getContext().getTypeConverter().mandatoryConvertTo(String.class,
getResourceAsInputStream());
-        StringTemplate template = new StringTemplate(text);
-        template.setAttributes(variableMap);
+        ST template = new ST(text);
+        for (Map.Entry<String, Object> entry : variableMap.entrySet()) {
+            template.add(entry.getKey(), entry.getValue());
+        }
         log.debug("StringTemplate is writing using attributes: {}", variableMap);
-        template.write(new AutoIndentWriter(buffer));
+        template.write(new NoIndentWriter(buffer));
 
         // now lets output the results to the exchange
         Message out = exchange.getOut();
@@ -69,4 +72,5 @@ public class StringTemplateEndpoint exte
         out.setHeader(StringTemplateConstants.STRINGTEMPLATE_RESOURCE_URI, getResourceUri());
         out.setAttachments(exchange.getIn().getAttachments());
     }
+
 }
\ No newline at end of file

Modified: camel/trunk/components/camel-stringtemplate/src/test/java/org/apache/camel/component/stringtemplate/StringTemplateContentCacheTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-stringtemplate/src/test/java/org/apache/camel/component/stringtemplate/StringTemplateContentCacheTest.java?rev=1427787&r1=1427786&r2=1427787&view=diff
==============================================================================
--- camel/trunk/components/camel-stringtemplate/src/test/java/org/apache/camel/component/stringtemplate/StringTemplateContentCacheTest.java
(original)
+++ camel/trunk/components/camel-stringtemplate/src/test/java/org/apache/camel/component/stringtemplate/StringTemplateContentCacheTest.java
Wed Jan  2 13:46:01 2013
@@ -39,7 +39,7 @@ public class StringTemplateContentCacheT
         super.setUp();
 
         // create a tm file in the classpath as this is the tricky reloading stuff
-        template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/stringtemplate?fileExist=Override",
"Hello $headers.name$", Exchange.FILE_NAME, "hello.tm");
+        template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/stringtemplate?fileExist=Override",
"Hello <headers.name>", Exchange.FILE_NAME, "hello.tm");
     }
     
     @Override
@@ -56,7 +56,7 @@ public class StringTemplateContentCacheT
         mock.assertIsSatisfied();
 
         // now change content in the file in the classpath and try again
-        template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/stringtemplate?fileExist=Override",
"Bye $headers.name$", Exchange.FILE_NAME, "hello.tm");
+        template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/stringtemplate?fileExist=Override",
"Bye <headers.name>", Exchange.FILE_NAME, "hello.tm");
 
         mock.reset();
         mock.expectedBodiesReceived("Bye Paris");
@@ -74,7 +74,7 @@ public class StringTemplateContentCacheT
         mock.assertIsSatisfied();
 
         // now change content in the file in the classpath and try again
-        template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/stringtemplate?fileExist=Override",
"Bye $headers.name$", Exchange.FILE_NAME, "hello.tm");
+        template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/stringtemplate?fileExist=Override",
"Bye <headers.name>", Exchange.FILE_NAME, "hello.tm");
 
         mock.reset();
         // we must expected the original filecontent as the cache is enabled, so its Hello
and not Bye
@@ -93,7 +93,7 @@ public class StringTemplateContentCacheT
         mock.assertIsSatisfied();
 
         // now change content in the file in the classpath and try again
-        template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/stringtemplate?fileExist=Override",
"Bye $headers.name$", Exchange.FILE_NAME, "hello.tm");
+        template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/stringtemplate?fileExist=Override",
"Bye <headers.name>", Exchange.FILE_NAME, "hello.tm");
 
         mock.reset();
         // we must expected the original filecontent as the cache is enabled, so its Hello
and not Bye
@@ -111,14 +111,14 @@ public class StringTemplateContentCacheT
         mock.reset();
         // we expect that the new resource will be set as the cached value, since the cache
has been cleared
         mock.expectedBodiesReceived("Bye Paris");
-        template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/stringtemplate?fileExist=Override",
"Bye $headers.name$", Exchange.FILE_NAME, "hello.tm");    
+        template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/stringtemplate?fileExist=Override",
"Bye <headers.name>", Exchange.FILE_NAME, "hello.tm");
         template.sendBodyAndHeader("direct:b", "Body", "name", "Paris");
         mock.assertIsSatisfied();
         
         mock.reset();
         // we expect that the cached value will not be replaced by a different resource since
the cache is now re-established
         mock.expectedBodiesReceived("Bye Paris");
-        template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/stringtemplate?fileExist=Override",
"Hello $headers.name$", Exchange.FILE_NAME, "hello.tm");
+        template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/stringtemplate?fileExist=Override",
"Hello <headers.name>", Exchange.FILE_NAME, "hello.tm");
         template.sendBodyAndHeader("direct:b", "Body", "name", "Paris");
         mock.assertIsSatisfied();
     }

Modified: camel/trunk/components/camel-stringtemplate/src/test/resources/org/apache/camel/component/stringtemplate/Concurrent.tm
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-stringtemplate/src/test/resources/org/apache/camel/component/stringtemplate/Concurrent.tm?rev=1427787&r1=1427786&r2=1427787&view=diff
==============================================================================
--- camel/trunk/components/camel-stringtemplate/src/test/resources/org/apache/camel/component/stringtemplate/Concurrent.tm
(original)
+++ camel/trunk/components/camel-stringtemplate/src/test/resources/org/apache/camel/component/stringtemplate/Concurrent.tm
Wed Jan  2 13:46:01 2013
@@ -1,4 +1,4 @@
-$! ------------------------------------------------------------------------
+<! ------------------------------------------------------------------------
 ## 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.
@@ -13,5 +13,5 @@ $! -------------------------------------
 ## 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.
-## ------------------------------------------------------------------------ !$
-Bye $body$
\ No newline at end of file
+## ------------------------------------------------------------------------ !>
+Bye <body>
\ No newline at end of file

Modified: camel/trunk/components/camel-stringtemplate/src/test/resources/org/apache/camel/component/stringtemplate/letter.tm
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-stringtemplate/src/test/resources/org/apache/camel/component/stringtemplate/letter.tm?rev=1427787&r1=1427786&r2=1427787&view=diff
==============================================================================
--- camel/trunk/components/camel-stringtemplate/src/test/resources/org/apache/camel/component/stringtemplate/letter.tm
(original)
+++ camel/trunk/components/camel-stringtemplate/src/test/resources/org/apache/camel/component/stringtemplate/letter.tm
Wed Jan  2 13:46:01 2013
@@ -1,4 +1,4 @@
-$! ------------------------------------------------------------------------
+<! ------------------------------------------------------------------------
 ## 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.
@@ -13,5 +13,5 @@ $! -------------------------------------
 ## 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.
-## ------------------------------------------------------------------------ !$
-Dear $headers.lastName$, $headers.firstName$! Thanks for the order of $headers.item$. Regards
Camel Riders Bookstore $body$
\ No newline at end of file
+## ------------------------------------------------------------------------ !>
+Dear <headers.lastName>, <headers.firstName>! Thanks for the order of <headers.item>.
Regards Camel Riders Bookstore <body>
\ No newline at end of file

Modified: camel/trunk/components/camel-stringtemplate/src/test/resources/org/apache/camel/component/stringtemplate/template.tm
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-stringtemplate/src/test/resources/org/apache/camel/component/stringtemplate/template.tm?rev=1427787&r1=1427786&r2=1427787&view=diff
==============================================================================
--- camel/trunk/components/camel-stringtemplate/src/test/resources/org/apache/camel/component/stringtemplate/template.tm
(original)
+++ camel/trunk/components/camel-stringtemplate/src/test/resources/org/apache/camel/component/stringtemplate/template.tm
Wed Jan  2 13:46:01 2013
@@ -1,4 +1,4 @@
-$!-----------------------------------------------------------------------
+<! -----------------------------------------------------------------------
  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.
@@ -13,5 +13,5 @@ $!--------------------------------------
  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.
- ------------------------------------------------------------------------
-!$Dear $headers.name$. You ordered item $exchange.properties.item$ on $body$.
\ No newline at end of file
+ ------------------------------------------------------------------------ !>
+Dear <headers.name>. You ordered item <exchange.properties.item> on <body>.
\ No newline at end of file

Modified: camel/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/parent/pom.xml?rev=1427787&r1=1427786&r2=1427787&view=diff
==============================================================================
--- camel/trunk/parent/pom.xml (original)
+++ camel/trunk/parent/pom.xml Wed Jan  2 13:46:01 2013
@@ -319,8 +319,8 @@
     <sshd-version>0.8.0</sshd-version>
     <stax-api-version>1.0.1</stax-api-version>
     <stax2-api-bundle-version>3.1.1</stax2-api-bundle-version>
-    <stringtemplate-bundle-version>3.2_5</stringtemplate-bundle-version>
-    <stringtemplate-version>3.2.1</stringtemplate-version>
+    <stringtemplate-bundle-version>4.0.2_2</stringtemplate-bundle-version>
+    <stringtemplate-version>4.0.2</stringtemplate-version>
     <tagsoup-bundle-version>1.2_5</tagsoup-bundle-version>
     <tagsoup-version>1.2.1</tagsoup-version>
     <testng-version>6.8</testng-version>



Mime
View raw message