add noNamespaceSchemaLocation to model

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f887f3c7
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f887f3c7
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f887f3c7

Branch: refs/heads/master
Commit: f887f3c7c8246a1c947d12d1861a857c379bc1f4
Parents: f34dd1c
Author: jonmcewen <jon_mce...@hotmail.com>
Authored: Mon Mar 7 13:51:38 2016 +0000
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Mon Mar 7 15:25:00 2016 +0100

----------------------------------------------------------------------
 .../camel/model/dataformat/JaxbDataFormat.java  | 16 +++++++
 ...JaxbNoNamespaceSchemaLocationSpringTest.java | 47 ++++++++++++++++++++
 .../jaxb/CamelJaxbNoNamespaceSchemaTest.java    |  2 +-
 .../CamelJaxbNoNamespaceSchemaLocationTest.xml  | 40 +++++++++++++++++
 4 files changed, 104 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f887f3c7/camel-core/src/main/java/org/apache/camel/model/dataformat/JaxbDataFormat.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/model/dataformat/JaxbDataFormat.java
 
b/camel-core/src/main/java/org/apache/camel/model/dataformat/JaxbDataFormat.java
index 9ba6703..ca933ed 100644
--- 
a/camel-core/src/main/java/org/apache/camel/model/dataformat/JaxbDataFormat.java
+++ 
b/camel-core/src/main/java/org/apache/camel/model/dataformat/JaxbDataFormat.java
@@ -64,6 +64,8 @@ public class JaxbDataFormat extends DataFormatDefinition {
     private String xmlStreamWriterWrapper;
     @XmlAttribute
     private String schemaLocation;
+    @XmlAttribute
+    private String noNamespaceSchemaLocation;
 
     public JaxbDataFormat() {
         super("jaxb");
@@ -232,6 +234,17 @@ public class JaxbDataFormat extends DataFormatDefinition {
         this.schemaLocation = schemaLocation;
     }
 
+    public String getNoNamespaceSchemaLocation() {
+        return noNamespaceSchemaLocation;
+    }
+
+    /**
+     * To define the location of the namespaceless schema
+     */
+    public void setNoNamespaceSchemaLocation(String schemaLocation) {
+        this.noNamespaceSchemaLocation = schemaLocation;
+    }
+
     @Override
     protected void configureDataFormat(DataFormat dataFormat, CamelContext 
camelContext) {
         Boolean answer = ObjectHelper.toBoolean(getPrettyPrint());
@@ -286,5 +299,8 @@ public class JaxbDataFormat extends DataFormatDefinition {
         if (schemaLocation != null) {
             setProperty(camelContext, dataFormat, "schemaLocation", 
schemaLocation);
         }
+        if (noNamespaceSchemaLocation != null) {
+            setProperty(camelContext, dataFormat, "noNamespaceSchemaLocation", 
noNamespaceSchemaLocation);
+        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/f887f3c7/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbNoNamespaceSchemaLocationSpringTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbNoNamespaceSchemaLocationSpringTest.java
 
b/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbNoNamespaceSchemaLocationSpringTest.java
new file mode 100644
index 0000000..2e43cea
--- /dev/null
+++ 
b/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbNoNamespaceSchemaLocationSpringTest.java
@@ -0,0 +1,47 @@
+/**
+ * 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.jaxb;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Service;
+import org.apache.camel.spring.SpringCamelContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+
+public class CamelJaxbNoNamespaceSchemaLocationSpringTest extends 
CamelJaxbNoNamespaceSchemaTest {
+    
+    protected CamelContext createCamelContext() throws Exception {
+        setUseRouteBuilder(false);
+        final AbstractXmlApplicationContext applicationContext = new 
ClassPathXmlApplicationContext("org/apache/camel/jaxb/CamelJaxbNoNamespaceSchemaLocationTest.xml");
+        setCamelContextService(new Service() {
+            public void start() throws Exception {
+                applicationContext.start();
+            }
+
+            public void stop() throws Exception {
+                applicationContext.stop();
+            }
+        });
+
+        return SpringCamelContext.springCamelContext(applicationContext);
+        
+    }
+    
+   
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/f887f3c7/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbNoNamespaceSchemaTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbNoNamespaceSchemaTest.java
 
b/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbNoNamespaceSchemaTest.java
index efe60f7..2b6095b 100644
--- 
a/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbNoNamespaceSchemaTest.java
+++ 
b/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbNoNamespaceSchemaTest.java
@@ -38,7 +38,7 @@ public class CamelJaxbNoNamespaceSchemaTest extends 
CamelTestSupport {
         resultEndpoint.assertIsSatisfied();
 
         String body = 
resultEndpoint.getReceivedExchanges().get(0).getIn().getBody(String.class);
-        assertTrue("We should get the schemaLocation here", body
+        assertTrue("We should get the noNamespaceSchemaLocation here", body
                 
.contains("noNamespaceSchemaLocation=\"person-no-namespace.xsd\""));
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/f887f3c7/components/camel-jaxb/src/test/resources/org/apache/camel/jaxb/CamelJaxbNoNamespaceSchemaLocationTest.xml
----------------------------------------------------------------------
diff --git 
a/components/camel-jaxb/src/test/resources/org/apache/camel/jaxb/CamelJaxbNoNamespaceSchemaLocationTest.xml
 
b/components/camel-jaxb/src/test/resources/org/apache/camel/jaxb/CamelJaxbNoNamespaceSchemaLocationTest.xml
new file mode 100644
index 0000000..b56b7ea
--- /dev/null
+++ 
b/components/camel-jaxb/src/test/resources/org/apache/camel/jaxb/CamelJaxbNoNamespaceSchemaLocationTest.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <bean id="testXmlStreamWriterWrapper" 
class="org.apache.camel.jaxb.TestXmlStreamWriter"/>
+
+  <!-- START SNIPPET: example -->
+  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring";>
+    <route>
+      <from uri="direct:marshal"/>
+      <marshal>
+        <jaxb contextPath="org.apache.camel.foo.bar" 
noNamespaceSchemaLocation="person-no-namespace.xsd"/>
+      </marshal>          
+      <to uri="mock:result"/>
+    </route>
+
+  </camelContext>
+  <!-- END SNIPPET: example -->
+
+</beans>

Reply via email to