camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1154743 [1/3] - in /camel/trunk: camel-core/src/main/java/org/apache/camel/component/ camel-core/src/main/java/org/apache/camel/component/validator/ camel-core/src/main/java/org/apache/camel/component/xslt/ camel-core/src/main/java/org/apa...
Date Sun, 07 Aug 2011 18:24:05 GMT
Author: davsclaus
Date: Sun Aug  7 18:24:01 2011
New Revision: 1154743

URL: http://svn.apache.org/viewvc?rev=1154743&view=rev
Log:
CAMEL-4031: resource based components no longer depend on Spring JARs.

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/ResourceBasedEndpoint.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/validator/
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/validator/ValidatorComponent.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/validator/package.html
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/xslt/
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/xslt/XsltComponent.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/xslt/package.html
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/ResourceHelper.java
    camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/validator
    camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/xslt
    camel/trunk/camel-core/src/test/data/
    camel/trunk/camel-core/src/test/data/staff.xml
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/validator/
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorRouteTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/InvalidXsltFileTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/MyEcho.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/MyXPath.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/TestBean.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltContentCacheTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFileNotFoundTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeClasspathTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeRelativeOtherTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeRelativeTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputBytesTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputDOMTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputFileDeleteTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputFileTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputStringTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltReferenceParameterTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltRouteFileTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltRouteTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltTransformingExceptionTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/util/ResourceHelperTest.java
    camel/trunk/camel-core/src/test/resources/org/apache/camel/component/staff_other_template.xsl
    camel/trunk/camel-core/src/test/resources/org/apache/camel/component/validator/
    camel/trunk/camel-core/src/test/resources/org/apache/camel/component/validator/schema.xsd
    camel/trunk/camel-core/src/test/resources/org/apache/camel/component/xslt/
    camel/trunk/camel-core/src/test/resources/org/apache/camel/component/xslt/example.xsl
    camel/trunk/camel-core/src/test/resources/org/apache/camel/component/xslt/invalid.xsl
    camel/trunk/camel-core/src/test/resources/org/apache/camel/component/xslt/staff_include.xsl
    camel/trunk/camel-core/src/test/resources/org/apache/camel/component/xslt/staff_include_classpath.xsl
    camel/trunk/camel-core/src/test/resources/org/apache/camel/component/xslt/staff_include_relative.xsl
    camel/trunk/camel-core/src/test/resources/org/apache/camel/component/xslt/staff_include_relative_other.xsl
    camel/trunk/camel-core/src/test/resources/org/apache/camel/component/xslt/staff_template.xsl
    camel/trunk/camel-core/src/test/resources/org/apache/camel/component/xslt/transform.xsl
    camel/trunk/camel-core/src/test/resources/org/apache/camel/component/xslt/transformCallEcho.xsl
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/validator/SpringValidatorRouteTest.java   (contents, props changed)
      - copied, changed from r1154680, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/validator/ValidatorRouteTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/SpringXsltRouteFileTest.java   (contents, props changed)
      - copied, changed from r1154680, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltRouteFileTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/SpringXsltRouteTest.java   (contents, props changed)
      - copied, changed from r1154680, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltRouteTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/SpringXsltRouteFileTest.xml   (contents, props changed)
      - copied, changed from r1154680, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/XsltRouteFileTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/SpringXsltRouteTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/mytransform.xsl
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/validator/
      - copied from r1154680, camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/spring/validator/
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/xslt/
      - copied from r1154680, camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/spring/xslt/
    camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/core/validator/
      - copied from r1154680, camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/spring/validator/
    camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/core/xslt/
      - copied from r1154680, camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/spring/xslt/
Removed:
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/CamelClassPathResource.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/CamelResourceLoader.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/ResourceBasedComponent.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/ResourceBasedEndpoint.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/package.html
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/validator/
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/xslt/
    camel/trunk/components/camel-spring/src/main/resources/META-INF/services/org/apache/camel/component/validator
    camel/trunk/components/camel-spring/src/main/resources/META-INF/services/org/apache/camel/component/xslt
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/validator/ValidatorRouteTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/InvalidXsltFileTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/MyEcho.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/MyXPath.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/TestBean.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltContentCacheTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltFileNotFoundTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltIncludeClasspathTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltIncludeRelativeOtherTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltIncludeRelativeTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltIncludeTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltOutputBytesTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltOutputDOMTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltOutputFileDeleteTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltOutputFileTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltOutputStringTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltReferenceParameterTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltRouteFileTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltRouteTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltTransformingExceptionTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltXmlFragmentTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/staff_other_template.xsl
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/XsltOutputBytesTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/XsltOutputDOMTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/XsltOutputFileDeleteTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/XsltOutputFileTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/XsltOutputStringTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/XsltRouteFileTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/XsltXmlFragmentTest-context.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/camelContext.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/example.xsl
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/fragment.xsl
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/invalid.xsl
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/staff_include.xsl
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/staff_include_classpath.xsl
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/staff_include_relative.xsl
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/staff_include_relative_other.xsl
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/staff_template.xsl
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/transform.xsl
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/transformCallEcho.xsl
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/spring/validator/
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/spring/xslt/
    camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/spring/validator/
    camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/spring/xslt/
Modified:
    camel/trunk/components/camel-flatpack/pom.xml
    camel/trunk/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/DelimitedEndpoint.java
    camel/trunk/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FixedLengthEndpoint.java
    camel/trunk/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackComponent.java
    camel/trunk/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackDataFormat.java
    camel/trunk/components/camel-flatpack/src/test/java/org/apache/camel/component/flatpack/DelimitedWithNoDescriptorTest.java
    camel/trunk/components/camel-flatpack/src/test/java/org/apache/camel/component/flatpack/FlatpackDelimitedDataFormatTest.java
    camel/trunk/components/camel-flatpack/src/test/java/org/apache/camel/component/flatpack/FlatpackFixedLengthDataFormatTest.java
    camel/trunk/components/camel-flatpack/src/test/java/org/apache/camel/component/flatpack/FlatpackFixedLengthWithHeaderAndTrailerDataFormatTest.java
    camel/trunk/components/camel-flatpack/src/test/resources/log4j.properties
    camel/trunk/components/camel-freemarker/pom.xml
    camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java
    camel/trunk/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java
    camel/trunk/components/camel-ibatis/pom.xml
    camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisComponent.java
    camel/trunk/components/camel-jing/pom.xml
    camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/JingComponent.java
    camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/JingValidator.java
    camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/RelaxNGCompactSyntaxComponent.java
    camel/trunk/components/camel-msv/pom.xml
    camel/trunk/components/camel-msv/src/main/java/org/apache/camel/component/validator/msv/MsvComponent.java
    camel/trunk/components/camel-saxon/pom.xml
    camel/trunk/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryComponent.java
    camel/trunk/components/camel-stringtemplate/pom.xml
    camel/trunk/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateComponent.java
    camel/trunk/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateConstants.java
    camel/trunk/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateEndpoint.java
    camel/trunk/components/camel-velocity/pom.xml
    camel/trunk/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/CamelVelocityClasspathResourceLoader.java
    camel/trunk/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityComponent.java
    camel/trunk/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityConstants.java
    camel/trunk/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityEndpoint.java
    camel/trunk/platforms/karaf/features/src/main/resources/features.xml
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/validator/ValidatorRouteTest.java
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/xslt/XsltRouteTest.java

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/component/ResourceBasedEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/ResourceBasedEndpoint.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/ResourceBasedEndpoint.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/ResourceBasedEndpoint.java Sun Aug  7 18:24:01 2011
@@ -0,0 +1,106 @@
+/**
+ * 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;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.camel.Component;
+import org.apache.camel.Processor;
+import org.apache.camel.converter.IOConverter;
+import org.apache.camel.impl.ProcessorEndpoint;
+import org.apache.camel.util.IOHelper;
+import org.apache.camel.util.ResourceHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A useful base class for endpoints which depend on a resource
+ * such as things like Velocity or XQuery based components.
+ */
+public class ResourceBasedEndpoint extends ProcessorEndpoint {
+    protected final transient Logger log = LoggerFactory.getLogger(getClass());
+    private String resourceUri;
+    private boolean contentCache;
+    private byte[] buffer;
+
+    public ResourceBasedEndpoint() {
+    }
+
+    public ResourceBasedEndpoint(String endpointUri, Processor processor) {
+        super(endpointUri, processor);
+    }
+
+    public ResourceBasedEndpoint(String endpointUri, Component component, String resourceUri) {
+        super(endpointUri, component);
+        this.resourceUri = resourceUri;
+    }
+
+    /**
+     * Gets the resource as an input stream considering the cache flag as well.
+     * <p/>
+     * If cache is enabled then the resource content is cached in an internal buffer and this content is
+     * returned to avoid loading the resource over and over again.
+     *
+     * @return the input stream
+     * @throws IOException is thrown if error loading the content of the resource to the local cache buffer
+     */
+    public InputStream getResourceAsInputStream() throws IOException {
+        // try to get the resource input stream
+        InputStream is;
+        if (contentCache) {
+            synchronized (this) {
+                if (buffer == null) {
+                    log.debug("Reading resource: {} into the content cache", resourceUri);
+                    is = getResourceAsInputStreamWithoutCache();
+                    buffer = IOConverter.toBytes(is);
+                    IOHelper.close(is, resourceUri, log);
+                }
+            }
+            log.debug("Using resource: {} from the content cache", resourceUri);
+            return new ByteArrayInputStream(buffer);
+        }
+
+        return getResourceAsInputStreamWithoutCache();
+    }
+
+    protected InputStream getResourceAsInputStreamWithoutCache() throws IOException {
+        return ResourceHelper.resolveMandatoryResourceAsInputStream(getCamelContext().getClassResolver(), resourceUri);
+    }
+
+    public boolean isContentCache() {
+        return contentCache;
+    }
+
+    /**
+     * Sets whether to use resource content cache or not - default is <tt>false</tt>.
+     *
+     * @see #getResourceAsInputStream()
+     */
+    public void setContentCache(boolean contentCache) {
+        this.contentCache = contentCache;
+    }
+
+    public String getResourceUri() {
+        return resourceUri;
+    }
+
+    public void setResourceUri(String resourceUri) {
+        this.resourceUri = resourceUri;
+    }
+}

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/component/validator/ValidatorComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/validator/ValidatorComponent.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/validator/ValidatorComponent.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/validator/ValidatorComponent.java Sun Aug  7 18:24:01 2011
@@ -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.validator;
+
+import java.io.InputStream;
+import java.util.Map;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.impl.ProcessorEndpoint;
+import org.apache.camel.processor.validation.ValidatingProcessor;
+import org.apache.camel.util.ResourceHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The <a href="http://camel.apache.org/validator.html">Validator Component</a>
+ * for validating XML against some schema
+ */
+public class ValidatorComponent extends DefaultComponent {
+
+    private static final transient Logger LOG = LoggerFactory.getLogger(ValidatorComponent.class);
+
+    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        final String resourceUri = remaining;
+        InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(getCamelContext().getClassResolver(), resourceUri);
+        StreamSource source = new StreamSource(is);
+
+        ValidatingProcessor validator = new ValidatingProcessor();
+        validator.setSchemaSource(source);
+        LOG.debug("{} using schema resource: {}", this, resourceUri);
+        configureValidator(validator, uri, remaining, parameters);
+
+        // force loading of schema at create time otherwise concurrent processing could
+        // cause thread safe issues for the javax.xml.validation.SchemaFactory
+        validator.loadSchema();
+
+        return new ProcessorEndpoint(uri, this, validator);
+    }
+
+    protected void configureValidator(ValidatingProcessor validator, String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        setProperties(validator, parameters);
+    }
+}

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/component/validator/package.html
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/validator/package.html?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/validator/package.html (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/validator/package.html Sun Aug  7 18:24:01 2011
@@ -0,0 +1,25 @@
+<!--
+    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.
+-->
+<html>
+<head>
+</head>
+<body>
+
+The <a href="http://activemq.apache.org/camel/validator.html">Validator Component</a> for validating XML against some schema
+
+</body>
+</html>

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/component/xslt/XsltComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/xslt/XsltComponent.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/xslt/XsltComponent.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/xslt/XsltComponent.java Sun Aug  7 18:24:01 2011
@@ -0,0 +1,180 @@
+/**
+ * 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.xslt;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.URIResolver;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.xml.ResultHandlerFactory;
+import org.apache.camel.builder.xml.XsltBuilder;
+import org.apache.camel.builder.xml.XsltUriResolver;
+import org.apache.camel.converter.jaxp.XmlConverter;
+import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.impl.ProcessorEndpoint;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.ResourceHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An <a href="http://camel.apache.org/xslt.html">XSLT Component</a>
+ * for performing XSLT transforms of messages
+ */
+public class XsltComponent extends DefaultComponent {
+    private static final transient Logger LOG = LoggerFactory.getLogger(XsltComponent.class);
+    private XmlConverter xmlConverter;
+    private URIResolver uriResolver;
+    private boolean contentCache = true;
+
+    public XmlConverter getXmlConverter() {
+        return xmlConverter;
+    }
+
+    public void setXmlConverter(XmlConverter xmlConverter) {
+        this.xmlConverter = xmlConverter;
+    }
+
+    public URIResolver getUriResolver() {
+        return uriResolver;
+    }
+
+    public void setUriResolver(URIResolver uriResolver) {
+        this.uriResolver = uriResolver;
+    }
+
+    public boolean isContentCache() {
+        return contentCache;
+    }
+
+    public void setContentCache(boolean contentCache) {
+        this.contentCache = contentCache;
+    }
+
+    protected Endpoint createEndpoint(String uri, final String remaining, Map<String, Object> parameters) throws Exception {
+        final String resourceUri = remaining;
+        LOG.debug("{} using schema resource: {}", this, resourceUri);
+        final XsltBuilder xslt = getCamelContext().getInjector().newInstance(XsltBuilder.class);
+
+        // lets allow the converter to be configured
+        XmlConverter converter = resolveAndRemoveReferenceParameter(parameters, "converter", XmlConverter.class);
+        if (converter == null) {
+            converter = getXmlConverter();
+        }
+        if (converter != null) {
+            xslt.setConverter(converter);
+        }
+
+        String transformerFactoryClassName = getAndRemoveParameter(parameters, "transformerFactoryClass", String.class);
+        TransformerFactory factory = null;
+        if (transformerFactoryClassName != null) {
+            // provide the class loader of this component to work in OSGi environments
+            Class<?> factoryClass = getCamelContext().getClassResolver().resolveClass(transformerFactoryClassName, XsltComponent.class.getClassLoader());
+            if (factoryClass != null) {
+                factory = (TransformerFactory) getCamelContext().getInjector().newInstance(factoryClass);
+            } else {
+                LOG.warn("Cannot find the TransformerFactoryClass with the class name: {}", transformerFactoryClassName);
+            }
+        }
+
+        if (parameters.get("transformerFactory") != null) {
+            factory = resolveAndRemoveReferenceParameter(parameters, "transformerFactory", TransformerFactory.class);
+        }
+
+        if (factory != null) {
+            xslt.getConverter().setTransformerFactory(factory);
+        }
+
+        // lookup custom resolver to use
+        URIResolver resolver = resolveAndRemoveReferenceParameter(parameters, "uriResolver", URIResolver.class);
+        if (resolver == null) {
+            // not in endpoint then use component specific resolver
+            resolver = getUriResolver();
+        }
+        if (resolver == null) {
+            // fallback to use a Camel specific resolver
+            resolver = new XsltUriResolver(getCamelContext().getClassResolver(), remaining);
+        }
+        // set resolver before input stream as resolver is used when loading the input stream
+        xslt.setUriResolver(resolver);
+
+        ResultHandlerFactory resultHandlerFactory = resolveAndRemoveReferenceParameter(parameters, "resultHandlerFactory", ResultHandlerFactory.class);
+        if (resultHandlerFactory != null) {
+            xslt.setResultHandlerFactory(resultHandlerFactory);
+        }
+
+        Boolean failOnNullBody = getAndRemoveParameter(parameters, "failOnNullBody", Boolean.class);
+        if (failOnNullBody != null) {
+            xslt.setFailOnNullBody(failOnNullBody);
+        }
+        String output = getAndRemoveParameter(parameters, "output", String.class);
+        configureOutput(xslt, output);
+
+        configureXslt(xslt, uri, remaining, parameters);
+        loadResource(xslt, resourceUri);
+
+        // default to use the cache option from the component if the endpoint did not have the contentCache parameter
+        boolean cache = getAndRemoveParameter(parameters, "contentCache", Boolean.class, contentCache);
+        if (!cache) {
+            return new ProcessorEndpoint(uri, this, xslt) {
+                @Override
+                protected void onExchange(Exchange exchange) throws Exception {
+                    // force to load the resource on each exchange as we are not cached
+                    loadResource(xslt, resourceUri);
+                    super.onExchange(exchange);
+                }
+            };
+        } else {
+            // we have already loaded xslt so we are cached
+            return new ProcessorEndpoint(uri, this, xslt);
+        }
+    }
+
+    private void loadResource(XsltBuilder xslt, String resourceUri) throws TransformerConfigurationException, IOException {
+        LOG.trace("{} loading schema resource: {}", this, resourceUri);
+        InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(getCamelContext().getClassResolver(), resourceUri);
+        xslt.setTransformerInputStream(is);
+    }
+
+    protected void configureXslt(XsltBuilder xslt, String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        setProperties(xslt, parameters);
+    }
+
+    protected void configureOutput(XsltBuilder xslt, String output) throws Exception {
+        if (ObjectHelper.isEmpty(output)) {
+            return;
+        }
+
+        if ("string".equalsIgnoreCase(output)) {
+            xslt.outputString();
+        } else if ("bytes".equalsIgnoreCase(output)) {
+            xslt.outputBytes();
+        } else if ("DOM".equalsIgnoreCase(output)) {
+            xslt.outputDOM();
+        } else if ("file".equalsIgnoreCase(output)) {
+            xslt.outputFile();
+        } else {
+            throw new IllegalArgumentException("Unknown output type: " + output);
+        }
+    }
+
+}

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/component/xslt/package.html
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/xslt/package.html?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/xslt/package.html (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/xslt/package.html Sun Aug  7 18:24:01 2011
@@ -0,0 +1,25 @@
+<!--
+    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.
+-->
+<html>
+<head>
+</head>
+<body>
+
+The <a href="http://activemq.apache.org/camel/xslt.html">XSLT Component</a> for transforming messages with XSLT
+
+</body>
+</html>

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/util/ResourceHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ResourceHelper.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/ResourceHelper.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/ResourceHelper.java Sun Aug  7 18:24:01 2011
@@ -0,0 +1,86 @@
+/**
+ * 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.util;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.camel.spi.ClassResolver;
+
+/**
+ * Helper for loading resources on the classpath or file system.
+ */
+public final class ResourceHelper {
+
+    private ResourceHelper() {
+        // utility class
+    }
+
+    /**
+     * Resolves the mandatory resource.
+     *
+     * @param classResolver the class resolver to load the resource from the classpath
+     * @param uri uri of the resource
+     * @return the resource as an {@link InputStream}, remember to close the stream after usage.
+     * @throws java.io.FileNotFoundException is thrown if the resource file could not be found
+     */
+    public static InputStream resolveMandatoryResourceAsInputStream(ClassResolver classResolver, String uri) throws FileNotFoundException {
+        if (uri.startsWith("file:")) {
+            uri = ObjectHelper.after(uri, "file:");
+            return new FileInputStream(uri);
+        } else if (uri.startsWith("classpath:")) {
+            uri = ObjectHelper.after(uri, "classpath:");
+        }
+
+        // load from classpath by default
+        InputStream is = classResolver.loadResourceAsStream(uri);
+        if (is == null) {
+            throw new FileNotFoundException("Cannot find resource in classpath for URI: " + uri);
+        } else {
+            return is;
+        }
+    }
+
+    /**
+     * Resolves the mandatory resource.
+     *
+     * @param classResolver the class resolver to load the resource from the classpath
+     * @param uri uri of the resource
+     * @return the resource as an {@link InputStream}, remember to close the stream after usage.
+     * @throws java.io.FileNotFoundException is thrown if the resource file could not be found
+     * @throws java.net.MalformedURLException if the uri is malformed
+     */
+    public static URL resolveMandatoryResourceAsUrl(ClassResolver classResolver,  String uri) throws FileNotFoundException, MalformedURLException {
+        if (uri.startsWith("file:")) {
+            return new URL(uri);
+        } else if (uri.startsWith("classpath:")) {
+            uri = ObjectHelper.after(uri, "classpath:");
+        }
+
+        // load from classpath by default
+        URL url = classResolver.loadResourceAsURL(uri);
+        if (url == null) {
+            throw new FileNotFoundException("Cannot find resource in classpath for URI: " + uri);
+        } else {
+            return url;
+        }
+    }
+
+}

Added: camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/validator
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/validator?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/validator (added)
+++ camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/validator Sun Aug  7 18:24:01 2011
@@ -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.validator.ValidatorComponent
\ No newline at end of file

Added: camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/xslt
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/xslt?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/xslt (added)
+++ camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/component/xslt Sun Aug  7 18:24:01 2011
@@ -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.xslt.XsltComponent
\ No newline at end of file

Added: camel/trunk/camel-core/src/test/data/staff.xml
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/data/staff.xml?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/data/staff.xml (added)
+++ camel/trunk/camel-core/src/test/data/staff.xml Sun Aug  7 18:24:01 2011
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<!--
+    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.
+-->
+<staff>
+
+    <programmer>
+        <name>Bugs Bunny</name>
+        <dob>03/21/1970</dob>
+        <age>31</age>
+        <address>4895 Wabbit Hole Road</address>
+        <phone>865-111-1111</phone>
+    </programmer>
+
+    <programmer>
+        <name>Daisy Duck</name>
+        <dob>08/09/1949</dob>
+        <age>51</age>
+        <address>748 Golden Pond</address>
+        <phone>865-222-2222</phone>
+    </programmer>
+
+    <programmer>
+        <name>Minnie Mouse</name>
+        <dob>04/13/1977</dob>
+        <age>24</age>
+        <address>4064 Cheese Factory Blvd</address>
+        <phone>865-333-3333</phone>
+    </programmer>
+
+    <programmer>
+        <name>Pluto</name>
+        <dob>07/04/1979</dob>
+        <age>21</age>
+        <address>414 Dog Lane</address>
+        <phone>865-333-3333</phone>
+    </programmer>
+
+    <programmer>
+        <name>Road Runner</name>
+        <dob>01/19/1953</dob>
+        <age>48</age>
+        <address>135 Desert View Street</address>
+        <phone>none</phone>
+    </programmer>
+
+</staff>
\ No newline at end of file

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorRouteTest.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorRouteTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorRouteTest.java Sun Aug  7 18:24:01 2011
@@ -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.validator;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.ValidationException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ *
+ */
+public class ValidatorRouteTest extends ContextTestSupport {
+
+    protected MockEndpoint validEndpoint;
+    protected MockEndpoint finallyEndpoint;
+    protected MockEndpoint invalidEndpoint;
+
+    public void testValidMessage() throws Exception {
+        validEndpoint.expectedMessageCount(1);
+        finallyEndpoint.expectedMessageCount(1);
+
+        template.sendBody("direct:start",
+                "<mail xmlns='http://foo.com/bar'><subject>Hey</subject><body>Hello world!</body></mail>");
+
+        MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint, finallyEndpoint);
+    }
+
+    public void testInvalidMessage() throws Exception {
+        invalidEndpoint.expectedMessageCount(1);
+        finallyEndpoint.expectedMessageCount(1);
+
+        template.sendBody("direct:start",
+                "<mail xmlns='http://foo.com/bar'><body>Hello world!</body></mail>");
+
+        MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint, finallyEndpoint);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        validEndpoint = resolveMandatoryEndpoint("mock:valid", MockEndpoint.class);
+        invalidEndpoint = resolveMandatoryEndpoint("mock:invalid", MockEndpoint.class);
+        finallyEndpoint = resolveMandatoryEndpoint("mock:finally", MockEndpoint.class);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .doTry()
+                        .to("validator:org/apache/camel/component/validator/schema.xsd")
+                        .to("mock:valid")
+                    .doCatch(ValidationException.class)
+                        .to("mock:invalid")
+                    .doFinally()
+                        .to("mock:finally")
+                    .end();
+            }
+        };
+    }
+
+}

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/InvalidXsltFileTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/InvalidXsltFileTest.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/InvalidXsltFileTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/InvalidXsltFileTest.java Sun Aug  7 18:24:01 2011
@@ -0,0 +1,53 @@
+/**
+ * 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.xslt;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.ResolveEndpointFailedException;
+import org.apache.camel.TestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+
+/**
+ *
+ */
+public class InvalidXsltFileTest extends TestSupport {
+
+    public void testInvalidStylesheet() throws Exception {
+        try {
+            RouteBuilder builder = createRouteBuilder();
+            CamelContext context = new DefaultCamelContext();
+            context.addRoutes(builder);
+            context.start();
+
+            fail("Should have thrown an exception due XSL compilation error");
+        } catch (FailedToCreateRouteException e) {
+            // expected
+            assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
+        }
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("seda:a").to("xslt:org/apache/camel/component/xslt/invalid.xsl");
+            }
+        };
+    }
+
+}

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/MyEcho.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/MyEcho.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/MyEcho.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/MyEcho.java Sun Aug  7 18:24:01 2011
@@ -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.
+ */
+package org.apache.camel.component.xslt;
+
+/**
+ *
+ */
+public final class MyEcho {
+
+    private MyEcho() {
+        //Helper class
+    }
+
+    public static String echoString(String str) {
+        // throw a runtime exception
+        if (str == null || str.length() == 0) {
+            throw new IllegalArgumentException("Cannot take the null String.");
+        }
+        return str;
+    }
+
+}

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/MyXPath.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/MyXPath.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/MyXPath.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/MyXPath.java Sun Aug  7 18:24:01 2011
@@ -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.xslt;
+
+//START SNIPPET: example
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.w3c.dom.NodeList;
+
+import org.apache.camel.component.bean.XPathAnnotationExpressionFactory;
+import org.apache.camel.language.LanguageAnnotation;
+import org.apache.camel.language.NamespacePrefix;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
+@LanguageAnnotation(language = "xpath", factory = XPathAnnotationExpressionFactory.class)
+public @interface MyXPath {
+    String value();
+
+    // You can add the namespaces as the default value of the annotation
+    NamespacePrefix[] namespaces() default {
+    @NamespacePrefix(prefix = "n1", uri = "http://example.org/ns1"),
+    @NamespacePrefix(prefix = "n2", uri = "http://example.org/ns2")};
+
+    Class<?> resultType() default NodeList.class;
+}
+//END SNIPPET: example

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/TestBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/TestBean.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/TestBean.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/TestBean.java Sun Aug  7 18:24:01 2011
@@ -0,0 +1,33 @@
+/**
+ * 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.xslt;
+
+/**
+ *
+ */
+public class TestBean {
+
+    private String subject;
+
+    public void onMethod(@MyXPath("/*/@subject") String subject) {
+        this.subject = subject;
+    }
+
+    public String getSubject() {
+        return subject;
+    }
+}

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltContentCacheTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltContentCacheTest.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltContentCacheTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltContentCacheTest.java Sun Aug  7 18:24:01 2011
@@ -0,0 +1,121 @@
+/**
+ * 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.xslt;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ *
+ */
+public class XsltContentCacheTest extends ContextTestSupport {
+
+    private static final String ORIGINAL_XSL =
+        "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">"
+            + "<xsl:template match=\"/\"><goodbye><xsl:value-of select=\"/hello\"/></goodbye></xsl:template>"
+            + "</xsl:stylesheet>";
+
+    private static final String NEW_XSL =
+        "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">"
+            + "<xsl:template match=\"/\"><goodnight><xsl:value-of select=\"/hello\"/></goodnight></xsl:template>"
+            + "</xsl:stylesheet>";
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+
+        // create file with original XSL transformation
+        template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/xslt?fileExist=Override", ORIGINAL_XSL, Exchange.FILE_NAME, "hello.xsl");
+
+        // start the context AFTER we've created the hello.xsl file, otherwise the xslt routes will fail
+        super.startCamelContext();
+    }
+
+    @Override
+    protected void startCamelContext() throws Exception {
+        // Override so we can start the context ourself in the setUp
+    }
+
+    public void testNotCached() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>");
+
+        template.sendBody("direct:a", "<hello>world!</hello>");
+        mock.assertIsSatisfied();
+
+        // now replace the file with a new XSL transformation
+        template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/xslt?fileExist=Override", NEW_XSL, Exchange.FILE_NAME, "hello.xsl");
+
+        mock.reset();
+        // we expect the new output as the cache is not enabled, so it's "goodnight" and not "goodbye"
+        mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodnight>world!</goodnight>");
+
+        template.sendBody("direct:a", "<hello>world!</hello>");
+        mock.assertIsSatisfied();
+    }
+
+    public void testCached() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>");
+
+        template.sendBody("direct:b", "<hello>world!</hello>");
+        mock.assertIsSatisfied();
+
+        // now replace the file with a new XSL transformation
+        template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/xslt?fileExist=Override", NEW_XSL, Exchange.FILE_NAME, "hello.xsl");
+
+        mock.reset();
+        // we expect the original output as the cache is enabled, so it's "goodbye" and not "goodnight"
+        mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>");
+
+        template.sendBody("direct:b", "<hello>world!</hello>");
+        mock.assertIsSatisfied();
+    }
+
+    public void testCachedIsDefault() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>");
+
+        template.sendBody("direct:c", "<hello>world!</hello>");
+        mock.assertIsSatisfied();
+
+        // now replace the file with a new XSL transformation
+        template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/xslt?fileExist=Override", NEW_XSL, Exchange.FILE_NAME, "hello.xsl");
+
+        mock.reset();
+        // we expect the original output as the cache is enabled, so it's "goodbye" and not "goodnight"
+        mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>");
+
+        template.sendBody("direct:c", "<hello>world!</hello>");
+        mock.assertIsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("direct:a").to("xslt://org/apache/camel/component/xslt/hello.xsl?output=string&contentCache=false").to("mock:result");
+
+                from("direct:b").to("xslt://org/apache/camel/component/xslt/hello.xsl?output=string&contentCache=true").to("mock:result");
+
+                from("direct:c").to("xslt://org/apache/camel/component/xslt/hello.xsl?output=string").to("mock:result");
+            }
+        };
+    }
+
+}

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFileNotFoundTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFileNotFoundTest.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFileNotFoundTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFileNotFoundTest.java Sun Aug  7 18:24:01 2011
@@ -0,0 +1,57 @@
+/**
+ * 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.xslt;
+
+import java.io.FileNotFoundException;
+import javax.xml.transform.TransformerConfigurationException;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.ResolveEndpointFailedException;
+import org.apache.camel.TestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+
+/**
+ *
+ */
+public class XsltFileNotFoundTest extends TestSupport {
+
+    public void testNoXsltFile() throws Exception {
+        try {
+            RouteBuilder builder = createRouteBuilder();
+            CamelContext context = new DefaultCamelContext();
+            context.addRoutes(builder);
+            context.start();
+
+            fail("Should have thrown an exception due XSLT file not found");
+        } catch (FailedToCreateRouteException e) {
+            // expected
+            assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
+            assertIsInstanceOf(FileNotFoundException.class, e.getCause().getCause());
+        }
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("seda:a").to("xslt:org/apache/camel/component/xslt/notfound.xsl");
+            }
+        };
+    }
+
+}

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeClasspathTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeClasspathTest.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeClasspathTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeClasspathTest.java Sun Aug  7 18:24:01 2011
@@ -0,0 +1,49 @@
+/**
+ * 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.xslt;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ *
+ */
+public class XsltIncludeClasspathTest extends ContextTestSupport {
+
+    public void testXsltIncludeClasspath() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        // the include file has the span style so check that its there
+        mock.message(0).body().contains("<span style=\"font-size=22px;\">Minnie Mouse</span>");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("file:src/test/data/?fileName=staff.xml&noop=true")
+                    .to("xslt:org/apache/camel/component/xslt/staff_include_classpath.xsl")
+                    .to("log:foo")
+                    .to("mock:result");
+            }
+        };
+    }
+}
\ No newline at end of file

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeRelativeOtherTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeRelativeOtherTest.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeRelativeOtherTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeRelativeOtherTest.java Sun Aug  7 18:24:01 2011
@@ -0,0 +1,49 @@
+/**
+ * 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.xslt;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ *
+ */
+public class XsltIncludeRelativeOtherTest extends ContextTestSupport {
+
+    public void testXsltIncludeRelativeOther() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        // the include file has the span style so check that its there
+        mock.message(0).body().contains("<span style=\"color:yellow;\">48</span>");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("file:src/test/data/?fileName=staff.xml&noop=true")
+                    .to("xslt:org/apache/camel/component/xslt/staff_include_relative_other.xsl")
+                    .to("log:foo")
+                    .to("mock:result");
+            }
+        };
+    }
+}
\ No newline at end of file

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeRelativeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeRelativeTest.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeRelativeTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeRelativeTest.java Sun Aug  7 18:24:01 2011
@@ -0,0 +1,49 @@
+/**
+ * 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.xslt;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ *
+ */
+public class XsltIncludeRelativeTest extends ContextTestSupport {
+
+    public void testXsltIncludeRelative() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        // the include file has the span style so check that its there
+        mock.message(0).body().contains("<span style=\"font-size=22px;\">Minnie Mouse</span>");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("file:src/test/data/?fileName=staff.xml&noop=true")
+                    .to("xslt:org/apache/camel/component/xslt/staff_include_relative.xsl")
+                    .to("log:foo")
+                    .to("mock:result");
+            }
+        };
+    }
+}
\ No newline at end of file

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeTest.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltIncludeTest.java Sun Aug  7 18:24:01 2011
@@ -0,0 +1,49 @@
+/**
+ * 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.xslt;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ *
+ */
+public class XsltIncludeTest extends ContextTestSupport {
+
+    public void testXsltInclude() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        // the include file has the span style so check that its there
+        mock.message(0).body().contains("<span style=\"font-size=22px;\">Minnie Mouse</span>");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("file:src/test/data/?fileName=staff.xml&noop=true")
+                    .to("xslt:org/apache/camel/component/xslt/staff_include.xsl")
+                    .to("log:foo")
+                    .to("mock:result");
+            }
+        };
+    }
+}

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputBytesTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputBytesTest.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputBytesTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputBytesTest.java Sun Aug  7 18:24:01 2011
@@ -0,0 +1,49 @@
+/**
+ * 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.xslt;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ *
+ */
+public class XsltOutputBytesTest extends ContextTestSupport {
+
+    public void testXsltOutput() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>");
+        mock.message(0).body().isInstanceOf(byte[].class);
+
+        template.sendBody("direct:start", "<hello>world!</hello>");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("xslt:org/apache/camel/component/xslt/example.xsl?output=bytes")
+                    .to("mock:result");
+            }
+        };
+    }
+}

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputDOMTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputDOMTest.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputDOMTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputDOMTest.java Sun Aug  7 18:24:01 2011
@@ -0,0 +1,51 @@
+/**
+ * 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.xslt;
+
+import org.w3c.dom.Document;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ *
+ */
+public class XsltOutputDOMTest extends ContextTestSupport {
+
+    public void testXsltOutput() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("<goodbye>world!</goodbye>");
+        mock.message(0).body().isInstanceOf(Document.class);
+
+        template.sendBody("direct:start", "<hello>world!</hello>");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("xslt:org/apache/camel/component/xslt/example.xsl?output=dom")
+                    .to("mock:result");
+            }
+        };
+    }
+}

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputFileDeleteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputFileDeleteTest.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputFileDeleteTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputFileDeleteTest.java Sun Aug  7 18:24:01 2011
@@ -0,0 +1,57 @@
+/**
+ * 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.xslt;
+
+import java.io.File;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ *
+ */
+public class XsltOutputFileDeleteTest extends ContextTestSupport {
+
+    public void testXsltOutputDeleteFile() throws Exception {
+        createDirectory("target/xslt");
+
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>");
+        template.sendBodyAndHeader("direct:start", "<hello>world!</hello>", Exchange.XSLT_FILE_NAME, "target/xslt/xsltme.xml");
+
+        assertMockEndpointsSatisfied();
+        oneExchangeDone.matchesMockWaitTime();
+
+        // assert file deleted
+        File file = new File("target/xslt/xsltme.xml").getAbsoluteFile();
+        assertFalse("File should be deleted", file.exists());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("xslt:org/apache/camel/component/xslt/example.xsl?output=file&deleteOutputFile=true")
+                    .to("mock:result");
+            }
+        };
+    }
+}
\ No newline at end of file

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputFileTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputFileTest.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputFileTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputFileTest.java Sun Aug  7 18:24:01 2011
@@ -0,0 +1,68 @@
+/**
+ * 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.xslt;
+
+import java.io.File;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.NoSuchHeaderException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ *
+ */
+public class XsltOutputFileTest extends ContextTestSupport {
+
+    public void testXsltOutput() throws Exception {
+        createDirectory("target/xslt");
+
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>");
+        mock.expectedFileExists("target/xslt/xsltme.xml");
+        mock.message(0).body().isInstanceOf(File.class);
+
+        template.sendBodyAndHeader("direct:start", "<hello>world!</hello>", Exchange.XSLT_FILE_NAME, "target/xslt/xsltme.xml");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testXsltOutputFileMissingHeader() throws Exception {
+        try {
+            template.sendBody("direct:start", "<hello>world!</hello>");
+            fail("Should thrown exception");
+        } catch (CamelExecutionException e) {
+            NoSuchHeaderException nshe = assertIsInstanceOf(NoSuchHeaderException.class, e.getCause());
+            assertEquals(Exchange.XSLT_FILE_NAME, nshe.getHeaderName());
+        }
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("xslt:org/apache/camel/component/xslt/example.xsl?output=file")
+                    .to("mock:result");
+            }
+        };
+    }
+
+}

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputStringTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputStringTest.java?rev=1154743&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputStringTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/xslt/XsltOutputStringTest.java Sun Aug  7 18:24:01 2011
@@ -0,0 +1,49 @@
+/**
+ * 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.xslt;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ *
+ */
+public class XsltOutputStringTest extends ContextTestSupport {
+
+    public void testXsltOutput() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>");
+        mock.message(0).body().isInstanceOf(String.class);
+
+        template.sendBody("direct:start", "<hello>world!</hello>");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("xslt:org/apache/camel/component/xslt/example.xsl?output=string")
+                    .to("mock:result");
+            }
+        };
+    }
+}



Mime
View raw message