camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r736617 - in /camel/trunk/components/camel-freemarker: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/camel/ src/main/java/org/apache/camel/component/ src/main/java/org/apache/camel/co...
Date Thu, 22 Jan 2009 12:17:45 GMT
Author: davsclaus
Date: Thu Jan 22 04:17:44 2009
New Revision: 736617

URL: http://svn.apache.org/viewvc?rev=736617&view=rev
Log:
CAMEL-1287: Added freemarker component.

Added:
    camel/trunk/components/camel-freemarker/   (with props)
    camel/trunk/components/camel-freemarker/pom.xml   (with props)
    camel/trunk/components/camel-freemarker/src/
    camel/trunk/components/camel-freemarker/src/main/
    camel/trunk/components/camel-freemarker/src/main/java/
    camel/trunk/components/camel-freemarker/src/main/java/org/
    camel/trunk/components/camel-freemarker/src/main/java/org/apache/
    camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/
    camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/
    camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/
    camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java   (with props)
    camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java   (with props)
    camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/NoCacheStorage.java   (with props)
    camel/trunk/components/camel-freemarker/src/main/resources/
    camel/trunk/components/camel-freemarker/src/main/resources/META-INF/
    camel/trunk/components/camel-freemarker/src/main/resources/META-INF/LICENSE.txt   (with props)
    camel/trunk/components/camel-freemarker/src/main/resources/META-INF/NOTICE.txt   (with props)
    camel/trunk/components/camel-freemarker/src/main/resources/META-INF/services/
    camel/trunk/components/camel-freemarker/src/main/resources/META-INF/services/org/
    camel/trunk/components/camel-freemarker/src/main/resources/META-INF/services/org/apache/
    camel/trunk/components/camel-freemarker/src/main/resources/META-INF/services/org/apache/camel/
    camel/trunk/components/camel-freemarker/src/main/resources/META-INF/services/org/apache/camel/component/
    camel/trunk/components/camel-freemarker/src/main/resources/META-INF/services/org/apache/camel/component/freemarker
    camel/trunk/components/camel-freemarker/src/test/
    camel/trunk/components/camel-freemarker/src/test/java/
    camel/trunk/components/camel-freemarker/src/test/java/org/
    camel/trunk/components/camel-freemarker/src/test/java/org/apache/
    camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/
    camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/
    camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/
    camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerBodyAsDomainObjectTest.java   (with props)
    camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerContentCacheTest.java   (with props)
    camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerEncodingTest.java   (with props)
    camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerLetterTest.java   (with props)
    camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerSetHeaderTest.java   (with props)
    camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerTest.java   (with props)
    camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FruitFilter.java   (with props)
    camel/trunk/components/camel-freemarker/src/test/resources/
    camel/trunk/components/camel-freemarker/src/test/resources/log4j.properties   (with props)
    camel/trunk/components/camel-freemarker/src/test/resources/org/
    camel/trunk/components/camel-freemarker/src/test/resources/org/apache/
    camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/
    camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/
    camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/
    camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/AppleTemplate.ftl
    camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/BodyAsDomainObject.ftl
    camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/OrangeTemplate.ftl
    camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/camel-context.xml   (with props)
    camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/example.ftl
    camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/letter-utf16.ftl   (with props)
    camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/letter.ftl

Propchange: camel/trunk/components/camel-freemarker/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Jan 22 04:17:44 2009
@@ -0,0 +1,9 @@
+.project
+.checkstyle
+.pmd
+.classpath
+target
+.settings
+eclipse-classes
+velocity.log
+*.i??

Added: camel/trunk/components/camel-freemarker/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/pom.xml?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/pom.xml (added)
+++ camel/trunk/components/camel-freemarker/pom.xml Thu Jan 22 04:17:44 2009
@@ -0,0 +1,87 @@
+<?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.
+-->
+
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-parent</artifactId>
+        <version>2.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-freemarker</artifactId>
+    <packaging>bundle</packaging>
+    <name>Camel :: Freemarker</name>
+    <description>Camel Freemarker support</description>
+
+    <properties>
+        <camel.osgi.export.pkg>org.apache.camel.component.freemarker.*</camel.osgi.export.pkg>
+    </properties>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-spring</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.freemarker</groupId>
+            <artifactId>freemarker</artifactId>
+            <version>2.3.15</version>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+        </dependency>
+
+        <!-- testing -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-core</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-spring</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>
+
+

Propchange: camel/trunk/components/camel-freemarker/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-freemarker/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-freemarker/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java (added)
+++ camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java Thu Jan 22 04:17:44 2009
@@ -0,0 +1,74 @@
+/**
+ * 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.component.freemarker;
+
+import java.util.Map;
+
+import freemarker.cache.ClassTemplateLoader;
+import freemarker.template.Configuration;
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+import org.springframework.core.io.Resource;
+
+/**
+ * Freemarker component.
+ */
+public class FreemarkerComponent extends DefaultComponent {
+
+    private Configuration configuraiton;
+    private Configuration noCacheConfiguration;
+
+    protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception {
+        FreemarkerEndpoint endpoint = new FreemarkerEndpoint(uri, this, remaining, parameters);
+
+        // should we use regular configuration or no cache (content cache is default true)
+        Configuration config;
+        boolean cache = getAndRemoveParameter(parameters, "contentCache", Boolean.class, Boolean.TRUE);
+        if (cache) {
+            config = getConfiguraiton();
+        } else {
+            config = getNoCacheConfiguration();
+        }
+
+        endpoint.setConfiguration(config);
+        return endpoint;
+    }
+
+    public synchronized Configuration getConfiguraiton() {
+        if (configuraiton == null) {
+            configuraiton = new Configuration();
+            // use class template loader using Spring Resource class and / as root in classpath
+            configuraiton.setTemplateLoader(new ClassTemplateLoader(Resource.class, "/"));
+        }
+        return (Configuration) configuraiton.clone();
+    }
+
+    public void setConfiguraiton(Configuration configuraiton) {
+        this.configuraiton = configuraiton;
+    }
+
+    private synchronized Configuration getNoCacheConfiguration() {
+        if (noCacheConfiguration == null) {
+            // create a clone of the regular configuration
+            noCacheConfiguration = (Configuration) getConfiguraiton().clone();
+            // set this one to not use cache
+            noCacheConfiguration.setCacheStorage(new NoCacheStorage());
+        }
+        return noCacheConfiguration;
+    }
+
+}

Propchange: camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java (added)
+++ camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java Thu Jan 22 04:17:44 2009
@@ -0,0 +1,112 @@
+/**
+ * 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.component.freemarker;
+
+import java.io.StringWriter;
+import java.util.Map;
+
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+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.ResourceBasedEndpoint;
+import org.apache.camel.util.ExchangeHelper;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * Freemarker endpoint
+ */
+public class FreemarkerEndpoint extends ResourceBasedEndpoint {
+
+    private String encoding;
+    private Configuration configuration;
+
+    public FreemarkerEndpoint(String uri, Component component, String resourceUri, Map parameters) {
+        super(uri, component, resourceUri, null);
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+
+    @Override
+    public ExchangePattern getExchangePattern() {
+        return ExchangePattern.InOut;
+    }
+
+    /**
+     * Sets the encoding to be used for loading the template file.
+     */
+    public void setEncoding(String encoding) {
+        this.encoding = encoding;
+    }
+
+    public String getEncoding() {
+        return encoding;
+    }
+
+    public Configuration getConfiguration() {
+        return configuration;
+    }
+
+    /**
+     * Sets the Freemarker configuration to use
+     */
+    public void setConfiguration(Configuration configuration) {
+        this.configuration = configuration;
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    protected void onExchange(Exchange exchange) throws Exception {
+        String path = getResourceUri();
+        ObjectHelper.notNull(configuration, "configuration");
+        ObjectHelper.notNull(path, "resourceUri");
+
+        Map variableMap = ExchangeHelper.createVariableMap(exchange);
+
+        if (log.isDebugEnabled()) {
+            log.debug("Freemarker is evaluating " + path + " using context: " + variableMap);
+        }
+
+        // let freemarker parse and generate the result in buffer
+        Template template;
+        if (encoding != null) {
+            template = configuration.getTemplate(path, encoding);
+        } else {
+            template = configuration.getTemplate(path);
+        }
+        StringWriter buffer = new StringWriter();
+        template.process(variableMap, buffer);
+        buffer.flush();
+
+        // now lets output the results to the exchange
+        Message out = exchange.getOut(true);
+        out.setBody(buffer.toString());
+        out.setHeader("org.apache.camel.freemarker.resource", getResource());
+        out.setHeader("org.apache.camel.freemarker.resourceUri", path);
+        Map<String, Object> headers = (Map<String, Object>) variableMap.get("headers");
+        for (String key : headers.keySet()) {
+            out.setHeader(key, headers.get(key));
+        }
+    }
+
+}
+

Propchange: camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/NoCacheStorage.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/NoCacheStorage.java?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/NoCacheStorage.java (added)
+++ camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/NoCacheStorage.java Thu Jan 22 04:17:44 2009
@@ -0,0 +1,44 @@
+/**
+ * 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.component.freemarker;
+
+import freemarker.cache.CacheStorage;
+
+/**
+ * A cache storage for Freemarker with no cache used for development to force reload of templates
+ * on every request.
+ */
+public class NoCacheStorage implements CacheStorage {
+
+    public Object get(Object key) {
+        // noop
+        return null;
+    }
+
+    public void put(Object key, Object value) {
+        // noop
+    }
+
+    public void remove(Object key) {
+        // noop
+    }
+
+    public void clear() {
+        // noop
+    }
+
+}

Propchange: camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/NoCacheStorage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/NoCacheStorage.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-freemarker/src/main/resources/META-INF/LICENSE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/main/resources/META-INF/LICENSE.txt?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/main/resources/META-INF/LICENSE.txt (added)
+++ camel/trunk/components/camel-freemarker/src/main/resources/META-INF/LICENSE.txt Thu Jan 22 04:17:44 2009
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+

Propchange: camel/trunk/components/camel-freemarker/src/main/resources/META-INF/LICENSE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-freemarker/src/main/resources/META-INF/LICENSE.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: camel/trunk/components/camel-freemarker/src/main/resources/META-INF/NOTICE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/main/resources/META-INF/NOTICE.txt?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/main/resources/META-INF/NOTICE.txt (added)
+++ camel/trunk/components/camel-freemarker/src/main/resources/META-INF/NOTICE.txt Thu Jan 22 04:17:44 2009
@@ -0,0 +1,11 @@
+   =========================================================================
+   ==  NOTICE file corresponding to the section 4 d of                    ==
+   ==  the Apache License, Version 2.0,                                   ==
+   ==  in this case for the Apache Camel distribution.                    ==
+   =========================================================================
+
+   This product includes software developed by
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Please read the different LICENSE files present in the licenses directory of
+   this distribution.

Propchange: camel/trunk/components/camel-freemarker/src/main/resources/META-INF/NOTICE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-freemarker/src/main/resources/META-INF/NOTICE.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: camel/trunk/components/camel-freemarker/src/main/resources/META-INF/services/org/apache/camel/component/freemarker
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/main/resources/META-INF/services/org/apache/camel/component/freemarker?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/main/resources/META-INF/services/org/apache/camel/component/freemarker (added)
+++ camel/trunk/components/camel-freemarker/src/main/resources/META-INF/services/org/apache/camel/component/freemarker Thu Jan 22 04:17:44 2009
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.component.freemarker.FreemarkerComponent

Added: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerBodyAsDomainObjectTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerBodyAsDomainObjectTest.java?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerBodyAsDomainObjectTest.java (added)
+++ camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerBodyAsDomainObjectTest.java Thu Jan 22 04:17:44 2009
@@ -0,0 +1,84 @@
+/**
+ * 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.component.freemarker;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * Unit test with the body as a Domain object.
+ *
+ * @version $Revision$
+ */
+public class FreemarkerBodyAsDomainObjectTest extends ContextTestSupport {
+
+    public void testWithObject() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived("Hi Claus how are you? Its a nice day.\nGive my regards to the family Ibsen.");
+
+        MyPerson person = new MyPerson();
+        person.setFamilyName("Ibsen");
+        person.setGivenName("Claus");
+
+        template.requestBody("direct:in", person);
+
+        mock.assertIsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:in")
+                    .to("freemarker:org/apache/camel/component/freemarker/BodyAsDomainObject.ftl")
+                    .to("mock:result");
+            }
+        };
+    }
+
+    public static class MyPerson {
+        private String givenName;
+        private String familyName;
+
+        public String getGivenName() {
+            return givenName;
+        }
+
+        public void setGivenName(String givenName) {
+            this.givenName = givenName;
+        }
+
+        public String getFamilyName() {
+            return familyName;
+        }
+
+        public void setFamilyName(String familyName) {
+            this.familyName = familyName;
+        }
+
+        public String toString() {
+            return "MyPerson{"
+                + "givenName='"
+                + givenName + '\''
+                + ", familyName='"
+                + familyName + '\''
+                + '}';
+        }
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerBodyAsDomainObjectTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerBodyAsDomainObjectTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerContentCacheTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerContentCacheTest.java?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerContentCacheTest.java (added)
+++ camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerContentCacheTest.java Thu Jan 22 04:17:44 2009
@@ -0,0 +1,80 @@
+/**
+ * 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.component.freemarker;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.file.FileComponent;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * Unit test the cache when reloading .ftl files in the classpath
+ */
+public class FreemarkerContentCacheTest extends ContextTestSupport {
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // create a vm file in the classpath as this is the tricky reloading stuff
+        template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/freemarker?append=false", "Hello ${headers.name}", FileComponent.HEADER_FILE_NAME, "hello.ftl");
+    }
+
+    public void testNotCached() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello London");
+
+        template.sendBodyAndHeader("direct:a", "Body", "name", "London");
+        mock.assertIsSatisfied();
+
+        // now change content in the file in the classpath and try again
+        template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/freemarker?append=false", "Bye ${headers.name}", FileComponent.HEADER_FILE_NAME, "hello.ftl");
+
+        mock.reset();
+        mock.expectedBodiesReceived("Bye Paris");
+
+        template.sendBodyAndHeader("direct:a", "Body", "name", "Paris");
+        mock.assertIsSatisfied();
+    }
+
+    public void testCached() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello London");
+
+        template.sendBodyAndHeader("direct:b", "Body", "name", "London");
+        mock.assertIsSatisfied();
+
+        // now change content in the file in the classpath and try again
+        template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/freemarker?append=false", "Bye ${headers.name}", FileComponent.HEADER_FILE_NAME, "hello.ftl");
+
+        mock.reset();
+        // we must expected the original filecontent as the cache is enabled, so its Hello and not Bye
+        mock.expectedBodiesReceived("Hello Paris");
+
+        template.sendBodyAndHeader("direct:b", "Body", "name", "Paris");
+        mock.assertIsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("direct:a").to("freemarker://org/apache/camel/component/freemarker/hello.ftl?contentCache=false").to("mock:result");
+
+                from("direct:b").to("freemarker://org/apache/camel/component/freemarker/hello.ftl?contentCache=true").to("mock:result");
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerContentCacheTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerContentCacheTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerEncodingTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerEncodingTest.java?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerEncodingTest.java (added)
+++ camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerEncodingTest.java Thu Jan 22 04:17:44 2009
@@ -0,0 +1,30 @@
+/**
+ * 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.component.freemarker;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class FreemarkerEncodingTest extends FreemarkerLetterTest {
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("direct:a").to("freemarker:org/apache/camel/component/freemarker/letter-utf16.ftl?encoding=UTF-16").to("mock:result");
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerEncodingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerEncodingTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerLetterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerLetterTest.java?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerLetterTest.java (added)
+++ camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerLetterTest.java Thu Jan 22 04:17:44 2009
@@ -0,0 +1,59 @@
+/**
+ * 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.component.freemarker;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * Unit test for wiki documentation
+ */
+public class FreemarkerLetterTest extends ContextTestSupport {
+
+    // START SNIPPET: e1
+    private Exchange createLetter() {
+        Exchange exchange = context.getEndpoint("direct:a").createExchange();
+        Message msg = exchange.getIn();
+        msg.setHeader("firstName", "Claus");
+        msg.setHeader("lastName", "Ibsen");
+        msg.setHeader("item", "Camel in Action");
+        msg.setBody("PS: Next beer is on me, James");
+        return exchange;
+    }
+
+    public void testFreemarkerLetter() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived("Dear Ibsen, Claus\n\nThanks for the order of Camel in Action.\n\nRegards Camel Riders Bookstore\nPS: Next beer is on me, James");
+
+        template.send("direct:a", createLetter());
+
+        mock.assertIsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("direct:a").to("freemarker:org/apache/camel/component/freemarker/letter.ftl").to("mock:result");
+            }
+        };
+    }
+    // END SNIPPET: e1
+}

Propchange: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerLetterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerLetterTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerSetHeaderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerSetHeaderTest.java?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerSetHeaderTest.java (added)
+++ camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerSetHeaderTest.java Thu Jan 22 04:17:44 2009
@@ -0,0 +1,60 @@
+/**
+ * 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.component.freemarker;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.InvalidPayloadException;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision$
+ */
+public class FreemarkerSetHeaderTest extends SpringTestSupport {
+    public void testSendingApple() throws Exception {
+        assertRespondsWith("apple", "I am an apple");
+    }
+
+    public void testSendingOrgane() throws Exception {
+        assertRespondsWith("orange", "I am an orange");
+    }
+
+    protected void assertRespondsWith(final String value, String expectedBody) throws InvalidPayloadException, InterruptedException {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        //mock.expectedHeaderReceived("fruit", value);
+        mock.expectedBodiesReceived(expectedBody);
+        template.request("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                Message in = exchange.getIn();
+                in.setBody(value);
+
+            }
+        });
+        mock.assertIsSatisfied();
+    }
+
+    @Override
+    protected ClassPathXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/component/freemarker/camel-context.xml");
+    }
+
+
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerSetHeaderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerSetHeaderTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerTest.java?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerTest.java (added)
+++ camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerTest.java Thu Jan 22 04:17:44 2009
@@ -0,0 +1,59 @@
+/**
+ * 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.component.freemarker;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * Freemarker unit test
+ */
+public class FreemarkerTest extends ContextTestSupport {
+
+    public void testReceivesFooResponse() throws Exception {
+        assertRespondsWith("foo", "<hello>foo</hello>");
+    }
+
+    public void testReceivesBarResponse() throws Exception {
+        assertRespondsWith("bar", "<hello>bar</hello>");
+    }
+
+    protected void assertRespondsWith(final String value, String expectedBody) throws Exception {
+        Exchange response = template.request("direct:a", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                Message in = exchange.getIn();
+                in.setBody("answer");
+                in.setHeader("cheese", value);
+            }
+        });
+        assertOutMessageBodyEquals(response, expectedBody);
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                // START SNIPPET: example
+                from("direct:a").
+                        to("freemarker:org/apache/camel/component/freemarker/example.ftl");
+                // END SNIPPET: example
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FruitFilter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FruitFilter.java?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FruitFilter.java (added)
+++ camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FruitFilter.java Thu Jan 22 04:17:44 2009
@@ -0,0 +1,28 @@
+/**
+ * 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.component.freemarker;
+
+public class FruitFilter {
+
+    public boolean isApple(String body) {
+        return "apple".equalsIgnoreCase(body);
+    }
+
+    public boolean isOrange(String body) {
+        return "orange".equalsIgnoreCase(body);
+    }
+}

Propchange: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FruitFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FruitFilter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-freemarker/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/test/resources/log4j.properties?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/test/resources/log4j.properties (added)
+++ camel/trunk/components/camel-freemarker/src/test/resources/log4j.properties Thu Jan 22 04:17:44 2009
@@ -0,0 +1,36 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=INFO, out
+
+log4j.logger.org.apache.activemq.spring=WARN
+log4j.logger.org.apache.camel.component.freemarker=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/camel-freemarker-test.log
+log4j.appender.out.append=true

Propchange: camel/trunk/components/camel-freemarker/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-freemarker/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-freemarker/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/AppleTemplate.ftl
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/AppleTemplate.ftl?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/AppleTemplate.ftl (added)
+++ camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/AppleTemplate.ftl Thu Jan 22 04:17:44 2009
@@ -0,0 +1,19 @@
+<#--
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+-->
+${request.setHeader('fruit', 'apple')}I am an ${body}
\ No newline at end of file

Added: camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/BodyAsDomainObject.ftl
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/BodyAsDomainObject.ftl?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/BodyAsDomainObject.ftl (added)
+++ camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/BodyAsDomainObject.ftl Thu Jan 22 04:17:44 2009
@@ -0,0 +1,20 @@
+<#--
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+-->
+Hi ${body.givenName} how are you? Its a nice day.
+Give my regards to the family ${body.familyName}.
\ No newline at end of file

Added: camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/OrangeTemplate.ftl
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/OrangeTemplate.ftl?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/OrangeTemplate.ftl (added)
+++ camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/OrangeTemplate.ftl Thu Jan 22 04:17:44 2009
@@ -0,0 +1,19 @@
+<#--
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+-->
+${request.setHeader('fruit', 'orange')}I am an ${body}
\ No newline at end of file

Added: camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/camel-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/camel-context.xml?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/camel-context.xml (added)
+++ camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/camel-context.xml Thu Jan 22 04:17:44 2009
@@ -0,0 +1,42 @@
+<?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://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
+
+  <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
+    <route>
+	   	<from uri="direct:start"/>
+	    <filter>
+	   		<method bean="fruitFilter" method="isApple"/>
+        	<to uri="freemarker:org/apache/camel/component/freemarker/AppleTemplate.ftl" />
+        	<to uri="mock:result" />
+	    </filter>
+	    <filter>
+	   		<method bean="fruitFilter" method="isOrange"/>
+        	<to uri="freemarker:org/apache/camel/component/freemarker/OrangeTemplate.ftl" />
+    	    <to uri="mock:result" />
+	    </filter>
+   </route>
+  </camelContext>
+
+  <bean id="fruitFilter" class="org.apache.camel.component.freemarker.FruitFilter"/>
+  
+</beans>

Propchange: camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/camel-context.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/camel-context.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/camel-context.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/example.ftl
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/example.ftl?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/example.ftl (added)
+++ camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/example.ftl Thu Jan 22 04:17:44 2009
@@ -0,0 +1,19 @@
+<#--
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+-->
+<hello>${headers.cheese}</hello>
\ No newline at end of file

Added: camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/letter-utf16.ftl
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/letter-utf16.ftl?rev=736617&view=auto
==============================================================================
Binary file - no diff available.

Propchange: camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/letter-utf16.ftl
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/letter.ftl
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/letter.ftl?rev=736617&view=auto
==============================================================================
--- camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/letter.ftl (added)
+++ camel/trunk/components/camel-freemarker/src/test/resources/org/apache/camel/component/freemarker/letter.ftl Thu Jan 22 04:17:44 2009
@@ -0,0 +1,24 @@
+<#--
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+-->
+Dear ${headers.lastName}, ${headers.firstName}
+
+Thanks for the order of ${headers.item}.
+
+Regards Camel Riders Bookstore
+${body}
\ No newline at end of file



Mime
View raw message