You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2007/08/07 12:26:39 UTC

svn commit: r563442 - in /activemq/camel/trunk/components: ./ camel-jing/ camel-jing/src/ camel-jing/src/main/ camel-jing/src/main/java/ camel-jing/src/main/java/org/ camel-jing/src/main/java/org/apache/ camel-jing/src/main/java/org/apache/camel/ camel...

Author: jstrachan
Date: Tue Aug  7 03:26:34 2007
New Revision: 563442

URL: http://svn.apache.org/viewvc?view=rev&rev=563442
Log:
added an initial jing componet for validation of XML against RelaxNG or RelaxNG Compact Syntax (RNC) for CAMEL-89

Added:
    activemq/camel/trunk/components/camel-jing/
    activemq/camel/trunk/components/camel-jing/pom.xml   (with props)
    activemq/camel/trunk/components/camel-jing/src/
    activemq/camel/trunk/components/camel-jing/src/main/
    activemq/camel/trunk/components/camel-jing/src/main/java/
    activemq/camel/trunk/components/camel-jing/src/main/java/org/
    activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/
    activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/
    activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/
    activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/
    activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/
    activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/JingComponent.java   (with props)
    activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/JingValidator.java   (with props)
    activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/RelaxNGCompactSyntaxComponent.java   (with props)
    activemq/camel/trunk/components/camel-jing/src/main/resources/
    activemq/camel/trunk/components/camel-jing/src/main/resources/META-INF/
    activemq/camel/trunk/components/camel-jing/src/main/resources/META-INF/services/
    activemq/camel/trunk/components/camel-jing/src/main/resources/META-INF/services/org/
    activemq/camel/trunk/components/camel-jing/src/main/resources/META-INF/services/org/apache/
    activemq/camel/trunk/components/camel-jing/src/main/resources/META-INF/services/org/apache/camel/
    activemq/camel/trunk/components/camel-jing/src/main/resources/META-INF/services/org/apache/camel/component/
    activemq/camel/trunk/components/camel-jing/src/main/resources/META-INF/services/org/apache/camel/component/jing
    activemq/camel/trunk/components/camel-jing/src/test/
    activemq/camel/trunk/components/camel-jing/src/test/java/
    activemq/camel/trunk/components/camel-jing/src/test/java/org/
    activemq/camel/trunk/components/camel-jing/src/test/java/org/apache/
    activemq/camel/trunk/components/camel-jing/src/test/java/org/apache/camel/
    activemq/camel/trunk/components/camel-jing/src/test/java/org/apache/camel/component/
    activemq/camel/trunk/components/camel-jing/src/test/java/org/apache/camel/component/validator/
    activemq/camel/trunk/components/camel-jing/src/test/java/org/apache/camel/component/validator/jing/
    activemq/camel/trunk/components/camel-jing/src/test/java/org/apache/camel/component/validator/jing/JingRouteTest.java   (with props)
    activemq/camel/trunk/components/camel-jing/src/test/resources/
    activemq/camel/trunk/components/camel-jing/src/test/resources/META-INF/
    activemq/camel/trunk/components/camel-jing/src/test/resources/META-INF/services/
    activemq/camel/trunk/components/camel-jing/src/test/resources/META-INF/services/org/
    activemq/camel/trunk/components/camel-jing/src/test/resources/META-INF/services/org/apache/
    activemq/camel/trunk/components/camel-jing/src/test/resources/META-INF/services/org/apache/camel/
    activemq/camel/trunk/components/camel-jing/src/test/resources/META-INF/services/org/apache/camel/component/
    activemq/camel/trunk/components/camel-jing/src/test/resources/META-INF/services/org/apache/camel/component/jing
    activemq/camel/trunk/components/camel-jing/src/test/resources/META-INF/services/org/apache/camel/component/rnc
    activemq/camel/trunk/components/camel-jing/src/test/resources/log4j.properties   (with props)
    activemq/camel/trunk/components/camel-jing/src/test/resources/org/
    activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/
    activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/
    activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/
    activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/
    activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/
    activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/camelContext.xml   (with props)
    activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/schema.rnc   (with props)
    activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/schema.rng   (with props)
Modified:
    activemq/camel/trunk/components/pom.xml

Added: activemq/camel/trunk/components/camel-jing/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jing/pom.xml?view=auto&rev=563442
==============================================================================
--- activemq/camel/trunk/components/camel-jing/pom.xml (added)
+++ activemq/camel/trunk/components/camel-jing/pom.xml Tue Aug  7 03:26:34 2007
@@ -0,0 +1,78 @@
+<?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>1.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-jing</artifactId>
+  <name>Camel :: Jing</name>
+  <description>Camel Jing support</description>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-spring</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>thaiopensource</groupId>
+      <artifactId>jing</artifactId>
+      <version>20030619</version>
+    </dependency>
+
+
+    <!-- for testing -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <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>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>

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

Added: activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/JingComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/JingComponent.java?view=auto&rev=563442
==============================================================================
--- activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/JingComponent.java (added)
+++ activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/JingComponent.java Tue Aug  7 03:26:34 2007
@@ -0,0 +1,50 @@
+/**
+ *
+ * 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.jing;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.ResourceBasedComponent;
+import org.apache.camel.impl.ProcessorEndpoint;
+import org.apache.camel.util.IntrospectionSupport;
+import org.springframework.core.io.Resource;
+
+import java.util.Map;
+
+/**
+ * A component for validating XML payloads using the
+ * <a href="http://www.thaiopensource.com/relaxng/jing.html">Jing library</a>
+ *
+ * @version $Revision: 1.1 $
+ */
+public class JingComponent extends ResourceBasedComponent {
+    protected Endpoint<Exchange> createEndpoint(String uri, String remaining, Map parameters) throws Exception {
+        JingValidator validator = new JingValidator();
+        Resource resource = resolveMandatoryResource(remaining);
+        validator.setSchemaResource(resource);
+        if (log.isDebugEnabled()) {
+            log.debug(this + " using schema resource: " + resource);
+        }
+        configureValidator(validator, uri, remaining, parameters);
+        return new ProcessorEndpoint(uri, this, validator);
+    }
+
+    protected void configureValidator(JingValidator validator, String uri, String remaining, Map parameters) throws Exception {
+        IntrospectionSupport.setProperties(validator, parameters);
+    }
+}

Propchange: activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/JingComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/JingValidator.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/JingValidator.java?view=auto&rev=563442
==============================================================================
--- activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/JingValidator.java (added)
+++ activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/JingValidator.java Tue Aug  7 03:26:34 2007
@@ -0,0 +1,162 @@
+/**
+ *
+ * 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.jing;
+
+import com.thaiopensource.relaxng.SchemaFactory;
+import com.thaiopensource.util.PropertyMap;
+import com.thaiopensource.util.PropertyMapBuilder;
+import com.thaiopensource.validate.IncorrectSchemaException;
+import com.thaiopensource.validate.Schema;
+import com.thaiopensource.validate.ValidateProperty;
+import com.thaiopensource.validate.Validator;
+import com.thaiopensource.xml.sax.Jaxp11XMLReaderCreator;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.processor.validation.DefaultValidationErrorHandler;
+import org.apache.camel.util.ExchangeHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.core.io.Resource;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+import javax.xml.XMLConstants;
+import javax.xml.transform.Source;
+import javax.xml.transform.sax.SAXSource;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * A validator which uses the <a href="http://www.thaiopensource.com/relaxng/jing.html">Jing</a>
+ * library to validate XML against RelaxNG
+ *
+ * @version $Revision: 1.1 $
+ */
+public class JingValidator implements Processor {
+    private static final transient Log log = LogFactory.getLog(JingValidator.class);
+    private Schema schema;
+    private SchemaFactory schemaFactory;
+    private String schemaNamespace = XMLConstants.RELAXNG_NS_URI;
+    private Resource schemaResource;
+    private InputSource inputSource;
+    private boolean compactSyntax = false;
+
+    public void process(Exchange exchange) throws Exception {
+        Jaxp11XMLReaderCreator xmlCreator = new Jaxp11XMLReaderCreator();
+        DefaultValidationErrorHandler errorHandler = new DefaultValidationErrorHandler();
+
+        PropertyMapBuilder mapBuilder = new PropertyMapBuilder();
+        mapBuilder.put(ValidateProperty.XML_READER_CREATOR, xmlCreator);
+        mapBuilder.put(ValidateProperty.ERROR_HANDLER, errorHandler);
+        PropertyMap propertyMap = mapBuilder.toPropertyMap();
+
+        Validator validator = getSchema().createValidator(propertyMap);
+
+        Message in = exchange.getIn();
+        SAXSource saxSource = in.getBody(SAXSource.class);
+        if (saxSource == null) {
+            Source source = ExchangeHelper.getMandatoryInBody(exchange, Source.class);
+            saxSource = ExchangeHelper.convertToMandatoryType(exchange, SAXSource.class, source);
+        }
+        InputSource bodyInput = saxSource.getInputSource();
+
+        // now lets parse the body using the validator
+        XMLReader reader = xmlCreator.createXMLReader();
+        reader.setContentHandler(validator.getContentHandler());
+        reader.setDTDHandler(validator.getDTDHandler());
+        reader.setErrorHandler(errorHandler);
+        reader.parse(bodyInput);
+
+        errorHandler.handleErrors(exchange, schema);
+    }
+
+    // Properties
+    //-------------------------------------------------------------------------
+
+    public Schema getSchema() throws IOException, IncorrectSchemaException, SAXException {
+        if (schema == null) {
+            SchemaFactory factory = getSchemaFactory();
+            schema = factory.createSchema(getInputSource());
+        }
+        return schema;
+    }
+
+    public void setSchema(Schema schema) {
+        this.schema = schema;
+    }
+
+    public InputSource getInputSource() throws IOException {
+        if (inputSource == null) {
+            Resource resource = getSchemaResource();
+            if (resource == null) {
+                throw new IllegalArgumentException("No schemaResource or inputSource specified");
+            }
+            else {
+                InputStream inputStream = resource.getInputStream();
+                if (inputStream == null) {
+                    throw new IllegalArgumentException("No inputStream available for: " + resource);
+                }
+                inputSource = new InputSource(inputStream);
+            }
+        }
+        return inputSource;
+    }
+
+    public void setInputSource(InputSource inputSource) {
+        this.inputSource = inputSource;
+    }
+
+    public SchemaFactory getSchemaFactory() {
+        if (schemaFactory == null) {
+            schemaFactory = new SchemaFactory();
+            schemaFactory.setCompactSyntax(compactSyntax);
+            schemaFactory.setXMLReaderCreator(new Jaxp11XMLReaderCreator());
+        }
+        return schemaFactory;
+    }
+
+    public void setSchemaFactory(SchemaFactory schemaFactory) {
+        this.schemaFactory = schemaFactory;
+    }
+
+    public Resource getSchemaResource() {
+        return schemaResource;
+    }
+
+    public void setSchemaResource(Resource schemaResource) {
+        this.schemaResource = schemaResource;
+    }
+
+    public String getSchemaNamespace() {
+        return schemaNamespace;
+    }
+
+    public void setSchemaNamespace(String schemaNamespace) {
+        this.schemaNamespace = schemaNamespace;
+    }
+
+    public boolean isCompactSyntax() {
+        return compactSyntax;
+    }
+
+    public void setCompactSyntax(boolean compactSyntax) {
+        this.compactSyntax = compactSyntax;
+    }
+}

Propchange: activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/JingValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/RelaxNGCompactSyntaxComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/RelaxNGCompactSyntaxComponent.java?view=auto&rev=563442
==============================================================================
--- activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/RelaxNGCompactSyntaxComponent.java (added)
+++ activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/RelaxNGCompactSyntaxComponent.java Tue Aug  7 03:26:34 2007
@@ -0,0 +1,34 @@
+/**
+ *
+ * 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.jing;
+
+import java.util.Map;
+
+/**
+ * A component for validating the XML payload using
+ * <a href="http://www.oasis-open.org/committees/relax-ng/compact-20021121.html">RelaxNG Compact Syntax</a> using the
+ * <a href="http://www.thaiopensource.com/relaxng/jing.html">Jing library</a>
+ *
+ * @version $Revision: 1.1 $
+ */
+public class RelaxNGCompactSyntaxComponent extends JingComponent {
+    protected void configureValidator(JingValidator validator, String uri, String remaining, Map parameters) throws Exception {
+        validator.setCompactSyntax(true);
+        super.configureValidator(validator, uri, remaining, parameters);
+    }
+}

Propchange: activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/RelaxNGCompactSyntaxComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-jing/src/main/resources/META-INF/services/org/apache/camel/component/jing
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jing/src/main/resources/META-INF/services/org/apache/camel/component/jing?view=auto&rev=563442
==============================================================================
--- activemq/camel/trunk/components/camel-jing/src/main/resources/META-INF/services/org/apache/camel/component/jing (added)
+++ activemq/camel/trunk/components/camel-jing/src/main/resources/META-INF/services/org/apache/camel/component/jing Tue Aug  7 03:26:34 2007
@@ -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.jing.JingComponent
\ No newline at end of file

Added: activemq/camel/trunk/components/camel-jing/src/test/java/org/apache/camel/component/validator/jing/JingRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jing/src/test/java/org/apache/camel/component/validator/jing/JingRouteTest.java?view=auto&rev=563442
==============================================================================
--- activemq/camel/trunk/components/camel-jing/src/test/java/org/apache/camel/component/validator/jing/JingRouteTest.java (added)
+++ activemq/camel/trunk/components/camel-jing/src/test/java/org/apache/camel/component/validator/jing/JingRouteTest.java Tue Aug  7 03:26:34 2007
@@ -0,0 +1,98 @@
+/**
+ *
+ * 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.jing;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.processor.validation.SchemaValidationException;
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class JingRouteTest extends SpringTestSupport {
+    public void testValidMessageUsingRelaxNG() throws Exception {
+        assertValidMessage("direct:rng");
+    }
+
+    public void testInvalidMessageUsingRelaxNG() throws Exception {
+        assertInvalidMessage("direct:rng");
+    }
+
+    public void testValidMessageUsingRelaxNGCompactSyntax() throws Exception {
+        assertValidMessage("direct:rnc");
+    }
+
+    public void testInvalidMessageUsingRelaxNGCompactSyntax() throws Exception {
+        assertInvalidMessage("direct:rnc");
+    }
+
+    protected void assertValidMessage(String endpointUri) throws Exception {
+        String body = "<mail xmlns='http://foo.com/bar'><subject>Hey</subject><body>Hello world!</body></mail>";
+        try {
+            template.sendBody(endpointUri, body);
+        }
+        catch (RuntimeException e) {
+            log.error(e, e);
+            fail("Caught: " + e);
+        }
+        catch (Exception e) {
+            log.error(e, e);
+            fail("Caught: " + e);
+        }
+    }
+
+    protected void assertInvalidMessage(String endpointUri) throws Exception {
+        String body = "<mail xmlns='http://foo.com/bar'><body>Hello world!</body></mail>";
+        try {
+            template.sendBody(endpointUri, body);
+        }
+
+        // TODO ideally we'd not have to wrap validation exceptions!
+        // TODO should we expose checked exceptions on CamelTemplate
+        // or should we make validation errors be runtime exceptions?
+        catch (RuntimeCamelException e) {
+            Throwable cause = e.getCause();
+            if (cause instanceof SchemaValidationException) {
+                log.debug("Caught expected schema validation exception: " + e, e);
+            }
+            else {
+                log.error(e, e);
+                fail("Not a SchemaValidationException: " + e);
+            }
+        }
+        catch (RuntimeException e) {
+            log.error(e, e);
+            fail("Caught: " + e);
+        }
+        catch (Exception e) {
+            log.error(e, e);
+            fail("Caught: " + e);
+        }
+    }
+
+    protected int getExpectedRouteCount() {
+        // TODO why zero?
+        return 0;
+    }
+
+    protected ClassPathXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/component/validator/jing/camelContext.xml");
+    }
+}
+

Propchange: activemq/camel/trunk/components/camel-jing/src/test/java/org/apache/camel/component/validator/jing/JingRouteTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-jing/src/test/resources/META-INF/services/org/apache/camel/component/jing
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jing/src/test/resources/META-INF/services/org/apache/camel/component/jing?view=auto&rev=563442
==============================================================================
--- activemq/camel/trunk/components/camel-jing/src/test/resources/META-INF/services/org/apache/camel/component/jing (added)
+++ activemq/camel/trunk/components/camel-jing/src/test/resources/META-INF/services/org/apache/camel/component/jing Tue Aug  7 03:26:34 2007
@@ -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.jing.JingComponent
\ No newline at end of file

Added: activemq/camel/trunk/components/camel-jing/src/test/resources/META-INF/services/org/apache/camel/component/rnc
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jing/src/test/resources/META-INF/services/org/apache/camel/component/rnc?view=auto&rev=563442
==============================================================================
--- activemq/camel/trunk/components/camel-jing/src/test/resources/META-INF/services/org/apache/camel/component/rnc (added)
+++ activemq/camel/trunk/components/camel-jing/src/test/resources/META-INF/services/org/apache/camel/component/rnc Tue Aug  7 03:26:34 2007
@@ -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.jing.RelaxNGCompactSyntaxComponent
\ No newline at end of file

Added: activemq/camel/trunk/components/camel-jing/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jing/src/test/resources/log4j.properties?view=auto&rev=563442
==============================================================================
--- activemq/camel/trunk/components/camel-jing/src/test/resources/log4j.properties (added)
+++ activemq/camel/trunk/components/camel-jing/src/test/resources/log4j.properties Tue Aug  7 03:26:34 2007
@@ -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.
+## ------------------------------------------------------------------------
+
+#
+# The logging properties used for eclipse testing, We want to see debug output on the console.
+#
+log4j.rootLogger=INFO, out
+
+log4j.logger.org.apache.camel=DEBUG
+log4j.logger.org.springframework=WARN
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n

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

Added: activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/camelContext.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/camelContext.xml?view=auto&rev=563442
==============================================================================
--- activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/camelContext.xml (added)
+++ activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/camelContext.xml Tue Aug  7 03:26:34 2007
@@ -0,0 +1,36 @@
+<?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-2.0.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:rng"/>
+      <to uri="jing:org/apache/camel/component/validator/jing/schema.rng"/>
+    </route>
+    <route>
+      <from uri="direct:rnc"/>
+      <to uri="rnc:org/apache/camel/component/validator/jing/schema.rnc"/>
+    </route>
+  </camelContext>
+
+</beans>

Propchange: activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/camelContext.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/schema.rnc
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/schema.rnc?view=auto&rev=563442
==============================================================================
--- activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/schema.rnc (added)
+++ activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/schema.rnc Tue Aug  7 03:26:34 2007
@@ -0,0 +1,6 @@
+default namespace = "http://foo.com/bar"
+
+element mail {
+  element subject { text },
+  element body { text }
+}
\ No newline at end of file

Propchange: activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/schema.rnc
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/schema.rng
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/schema.rng?view=auto&rev=563442
==============================================================================
--- activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/schema.rng (added)
+++ activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/schema.rng Tue Aug  7 03:26:34 2007
@@ -0,0 +1,8 @@
+<element xmlns="http://relaxng.org/ns/structure/1.0" ns="http://foo.com/bar" name="mail">
+  <element name="subject">
+    <text/>
+  </element>
+  <element name="body">
+    <text/>
+  </element>
+</element>

Propchange: activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/schema.rng
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/camel/trunk/components/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/pom.xml?view=diff&rev=563442&r1=563441&r2=563442
==============================================================================
--- activemq/camel/trunk/components/pom.xml (original)
+++ activemq/camel/trunk/components/pom.xml Tue Aug  7 03:26:34 2007
@@ -43,12 +43,14 @@
     <module>camel-irc</module>
     <module>camel-jaxb</module>
     <module>camel-jbi</module>
+    <module>camel-jing</module>
     <module>camel-jms</module>
     <module>camel-josql</module>
-    <module>camel-jpa</module> 
+    <module>camel-jpa</module>
     <module>camel-mail</module>
     <module>camel-mina</module>
     <module>camel-msv</module>
+    <module>camel-ognl</module>
     <module>camel-quartz</module>
     <module>camel-rmi</module>
     <module>camel-saxon</module>