You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/01/27 16:39:16 UTC
[1/2] camel git commit: CAMEL-6913 - Fix checkstyle violations
Repository: camel
Updated Branches:
refs/heads/master 5af2c600f -> e8404114c
CAMEL-6913 - Fix checkstyle violations
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e8404114
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e8404114
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e8404114
Branch: refs/heads/master
Commit: e8404114c2bc7fbb3cc53b679c74c600990dc291
Parents: 8a6c87a
Author: lburgazzoli <lb...@gmail.com>
Authored: Wed Jan 27 14:46:02 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Jan 27 16:39:06 2016 +0100
----------------------------------------------------------------------
.../camel/dataformat/jibx/JibxDataFormatMarshallTest.java | 2 +-
.../jibx/JibxDataFormatMarshallWithBindingNameTest.java | 2 +-
.../camel/dataformat/jibx/JibxDataFormatSpringDslTest.java | 2 +-
.../camel/dataformat/jibx/JibxDataFormatUnmarshallFail.java | 6 +++---
.../camel/dataformat/jibx/JibxDataFormatUnmarshallTest.java | 2 +-
.../jibx/JibxDataFormatUnmarshallWithBindingNameTest.java | 2 +-
.../jibx/JibxDataFormatUnmarshallWithDynamicClass.java | 6 +++---
.../org/apache/camel/dataformat/jibx/model/PurchaseOrder.java | 2 +-
.../org/apache/camel/dataformat/jibx/model/PurchaseOrder2.java | 2 +-
9 files changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/e8404114/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallTest.java b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallTest.java
index 17aaea6..240a336 100644
--- a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallTest.java
+++ b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallTest.java
@@ -22,13 +22,13 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import org.apache.camel.dataformat.jibx.model.PurchaseOrder;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.dataformat.jibx.model.PurchaseOrder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/camel/blob/e8404114/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallWithBindingNameTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallWithBindingNameTest.java b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallWithBindingNameTest.java
index 6c5b03d..0a3e6f5 100644
--- a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallWithBindingNameTest.java
+++ b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallWithBindingNameTest.java
@@ -23,7 +23,6 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import org.apache.camel.dataformat.jibx.model.PurchaseOrder;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;
@@ -31,6 +30,7 @@ import org.xml.sax.SAXException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.dataformat.jibx.model.PurchaseOrder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/camel/blob/e8404114/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatSpringDslTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatSpringDslTest.java b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatSpringDslTest.java
index c175099..9ce8c25 100644
--- a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatSpringDslTest.java
+++ b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatSpringDslTest.java
@@ -22,7 +22,6 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import org.apache.camel.dataformat.jibx.model.PurchaseOrder;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -30,6 +29,7 @@ import org.xml.sax.SAXException;
import org.apache.camel.CamelContext;
import org.apache.camel.Service;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.dataformat.jibx.model.PurchaseOrder;
import org.apache.camel.spring.SpringCamelContext;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/camel/blob/e8404114/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallFail.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallFail.java b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallFail.java
index 6111112..02bf2e6 100644
--- a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallFail.java
+++ b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallFail.java
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -14,19 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.camel.dataformat.jibx;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
+import org.xml.sax.SAXException;
+
import org.apache.camel.CamelExecutionException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.dataformat.jibx.model.PurchaseOrder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
-import org.xml.sax.SAXException;
public class JibxDataFormatUnmarshallFail extends CamelTestSupport {
http://git-wip-us.apache.org/repos/asf/camel/blob/e8404114/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallTest.java b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallTest.java
index 1d24b3b..c5f5b57 100644
--- a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallTest.java
+++ b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallTest.java
@@ -19,11 +19,11 @@ package org.apache.camel.dataformat.jibx;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
-import org.apache.camel.dataformat.jibx.model.PurchaseOrder;
import org.xml.sax.SAXException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.dataformat.jibx.model.PurchaseOrder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/camel/blob/e8404114/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallWithBindingNameTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallWithBindingNameTest.java b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallWithBindingNameTest.java
index c086666..66979ae 100644
--- a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallWithBindingNameTest.java
+++ b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallWithBindingNameTest.java
@@ -20,11 +20,11 @@ import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
-import org.apache.camel.dataformat.jibx.model.PurchaseOrder;
import org.xml.sax.SAXException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.dataformat.jibx.model.PurchaseOrder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/camel/blob/e8404114/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallWithDynamicClass.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallWithDynamicClass.java b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallWithDynamicClass.java
index e64b3df..e47497e 100644
--- a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallWithDynamicClass.java
+++ b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallWithDynamicClass.java
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -19,14 +19,14 @@ package org.apache.camel.dataformat.jibx;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
+import org.xml.sax.SAXException;
+
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.dataformat.jibx.model.PurchaseOrder;
import org.apache.camel.dataformat.jibx.model.PurchaseOrder2;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
-import org.xml.sax.SAXException;
-
public class JibxDataFormatUnmarshallWithDynamicClass extends CamelTestSupport {
@Test
http://git-wip-us.apache.org/repos/asf/camel/blob/e8404114/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/model/PurchaseOrder.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/model/PurchaseOrder.java b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/model/PurchaseOrder.java
index a0722dc..778528a 100644
--- a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/model/PurchaseOrder.java
+++ b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/model/PurchaseOrder.java
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/camel/blob/e8404114/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/model/PurchaseOrder2.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/model/PurchaseOrder2.java b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/model/PurchaseOrder2.java
index afd2a97..edc5152 100644
--- a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/model/PurchaseOrder2.java
+++ b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/model/PurchaseOrder2.java
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
[2/2] camel git commit: CAMEL-6913 - Add dynamic unmarshalling
capability to JiBX data format
Posted by da...@apache.org.
CAMEL-6913 - Add dynamic unmarshalling capability to JiBX data format
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8a6c87a4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8a6c87a4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8a6c87a4
Branch: refs/heads/master
Commit: 8a6c87a44ef5a67a1d1f382b0d4a39f33881b060
Parents: 5af2c60
Author: lburgazzoli <lb...@gmail.com>
Authored: Wed Jan 27 12:24:37 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Jan 27 16:39:06 2016 +0100
----------------------------------------------------------------------
.../camel/dataformat/jibx/JibxDataFormat.java | 13 +++-
.../jibx/JibxDataFormatMarshallTest.java | 1 +
...bxDataFormatMarshallWithBindingNameTest.java | 1 +
.../jibx/JibxDataFormatSpringDslTest.java | 1 +
.../jibx/JibxDataFormatUnmarshallFail.java | 67 ++++++++++++++++++
.../jibx/JibxDataFormatUnmarshallTest.java | 1 +
...DataFormatUnmarshallWithBindingNameTest.java | 4 +-
...ibxDataFormatUnmarshallWithDynamicClass.java | 65 +++++++++++++++++
.../camel/dataformat/jibx/PurchaseOrder.java | 72 -------------------
.../dataformat/jibx/model/PurchaseOrder.java | 72 +++++++++++++++++++
.../dataformat/jibx/model/PurchaseOrder2.java | 73 ++++++++++++++++++++
.../jibx/SpringJibxConfigurationTest.xml | 2 +-
.../dataformat/jibx/purchaseOrder-jibx.xml | 7 +-
13 files changed, 301 insertions(+), 78 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/8a6c87a4/components/camel-jibx/src/main/java/org/apache/camel/dataformat/jibx/JibxDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/main/java/org/apache/camel/dataformat/jibx/JibxDataFormat.java b/components/camel-jibx/src/main/java/org/apache/camel/dataformat/jibx/JibxDataFormat.java
index 6d9d519..e48daa5 100644
--- a/components/camel-jibx/src/main/java/org/apache/camel/dataformat/jibx/JibxDataFormat.java
+++ b/components/camel-jibx/src/main/java/org/apache/camel/dataformat/jibx/JibxDataFormat.java
@@ -31,6 +31,8 @@ import org.jibx.runtime.IUnmarshallingContext;
import org.jibx.runtime.JiBXException;
public class JibxDataFormat extends ServiceSupport implements DataFormat, DataFormatName {
+ public static final String UNMARSHALL_CLASS = "CamelJibxUnmarshallClass";
+
private Class<?> unmarshallClass;
private String bindingName;
@@ -58,8 +60,14 @@ public class JibxDataFormat extends ServiceSupport implements DataFormat, DataFo
}
public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
- ObjectHelper.notNull(getUnmarshallClass(), "unmarshallClass");
- IBindingFactory bindingFactory = createBindingFactory(getUnmarshallClass(), bindingName);
+ Class<?> unmarshallType = exchange.getIn().getHeader(UNMARSHALL_CLASS, Class.class);
+ if (unmarshallType == null) {
+ unmarshallType = getUnmarshallClass();
+ }
+
+ ObjectHelper.notNull(unmarshallType, "unmarshallClass or CamelJibxUnmarshallClass header");
+
+ IBindingFactory bindingFactory = createBindingFactory(unmarshallType, bindingName);
IUnmarshallingContext unmarshallingContext = bindingFactory.createUnmarshallingContext();
return unmarshallingContext.unmarshalDocument(stream, null);
}
@@ -74,6 +82,7 @@ public class JibxDataFormat extends ServiceSupport implements DataFormat, DataFo
protected void doStop() throws Exception {
// noop
}
+
public Class<?> getUnmarshallClass() {
return unmarshallClass;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/8a6c87a4/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallTest.java b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallTest.java
index 115a637..17aaea6 100644
--- a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallTest.java
+++ b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallTest.java
@@ -22,6 +22,7 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import org.apache.camel.dataformat.jibx.model.PurchaseOrder;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
http://git-wip-us.apache.org/repos/asf/camel/blob/8a6c87a4/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallWithBindingNameTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallWithBindingNameTest.java b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallWithBindingNameTest.java
index 2dd7bcb..6c5b03d 100644
--- a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallWithBindingNameTest.java
+++ b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatMarshallWithBindingNameTest.java
@@ -23,6 +23,7 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import org.apache.camel.dataformat.jibx.model.PurchaseOrder;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;
http://git-wip-us.apache.org/repos/asf/camel/blob/8a6c87a4/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatSpringDslTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatSpringDslTest.java b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatSpringDslTest.java
index 72eb332..c175099 100644
--- a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatSpringDslTest.java
+++ b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatSpringDslTest.java
@@ -22,6 +22,7 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import org.apache.camel.dataformat.jibx.model.PurchaseOrder;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
http://git-wip-us.apache.org/repos/asf/camel/blob/8a6c87a4/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallFail.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallFail.java b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallFail.java
new file mode 100644
index 0000000..6111112
--- /dev/null
+++ b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallFail.java
@@ -0,0 +1,67 @@
+/*
+ * 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.dataformat.jibx;
+
+import java.io.IOException;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.dataformat.jibx.model.PurchaseOrder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+import org.xml.sax.SAXException;
+
+
+public class JibxDataFormatUnmarshallFail extends CamelTestSupport {
+
+ @Test(expected = CamelExecutionException.class)
+ public void testUnmarshallFail() throws InterruptedException, ParserConfigurationException, IOException,
+ SAXException {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+
+ String name = "foo";
+ double price = 1;
+ double amount = 2;
+ String purchaseOrderXml = String.format("<order name='%s' price='%s' amount='%s' />", name, price + "", amount
+ + "");
+
+ template.sendBody("direct:start", purchaseOrderXml);
+
+ assertMockEndpointsSatisfied();
+
+ PurchaseOrder body = mock.getReceivedExchanges().get(0).getIn().getBody(PurchaseOrder.class);
+ assertEquals(name, body.getName());
+ assertEquals(price, body.getPrice(), 1);
+ assertEquals(amount, body.getAmount(), 1);
+ }
+
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .unmarshal(new JibxDataFormat())
+ .convertBodyTo(PurchaseOrder.class)
+ .to("mock:result");
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/8a6c87a4/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallTest.java b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallTest.java
index 45ad32c..1d24b3b 100644
--- a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallTest.java
+++ b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.dataformat.jibx;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
+import org.apache.camel.dataformat.jibx.model.PurchaseOrder;
import org.xml.sax.SAXException;
import org.apache.camel.builder.RouteBuilder;
http://git-wip-us.apache.org/repos/asf/camel/blob/8a6c87a4/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallWithBindingNameTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallWithBindingNameTest.java b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallWithBindingNameTest.java
index 6709fa8..c086666 100644
--- a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallWithBindingNameTest.java
+++ b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallWithBindingNameTest.java
@@ -20,6 +20,7 @@ import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
+import org.apache.camel.dataformat.jibx.model.PurchaseOrder;
import org.xml.sax.SAXException;
import org.apache.camel.builder.RouteBuilder;
@@ -32,8 +33,7 @@ public class JibxDataFormatUnmarshallWithBindingNameTest extends CamelTestSuppor
private static final String BINDING_NAME = "purchaseOrder-jibx";
@Test
- public void testUnmarshallWithBindingName() throws InterruptedException, ParserConfigurationException, IOException,
- SAXException {
+ public void testUnmarshallWithBindingName() throws InterruptedException, ParserConfigurationException, IOException, SAXException {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
http://git-wip-us.apache.org/repos/asf/camel/blob/8a6c87a4/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallWithDynamicClass.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallWithDynamicClass.java b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallWithDynamicClass.java
new file mode 100644
index 0000000..e64b3df
--- /dev/null
+++ b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/JibxDataFormatUnmarshallWithDynamicClass.java
@@ -0,0 +1,65 @@
+/*
+ * 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.dataformat.jibx;
+
+import java.io.IOException;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.dataformat.jibx.model.PurchaseOrder;
+import org.apache.camel.dataformat.jibx.model.PurchaseOrder2;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+import org.xml.sax.SAXException;
+
+
+public class JibxDataFormatUnmarshallWithDynamicClass extends CamelTestSupport {
+ @Test
+ public void testUnmarshallWithDynamicClass() throws InterruptedException, ParserConfigurationException, IOException,
+ SAXException {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+
+ String name = "foo";
+ double price = 1;
+ double amount = 2;
+ String purchaseOrderXml = String.format("<order2 name='%s' price='%s' amount='%s' />", name, price + "", amount + "");
+
+ template.sendBody("direct:start", purchaseOrderXml);
+
+ assertMockEndpointsSatisfied();
+
+ PurchaseOrder2 body = mock.getReceivedExchanges().get(0).getIn().getBody(PurchaseOrder2.class);
+ assertEquals(name, body.getName());
+ assertEquals(price, body.getPrice(), 1);
+ assertEquals(amount, body.getAmount(), 1);
+ }
+
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .setHeader(JibxDataFormat.UNMARSHALL_CLASS, constant(PurchaseOrder2.class))
+ .unmarshal(new JibxDataFormat(PurchaseOrder.class))
+ .convertBodyTo(PurchaseOrder2.class)
+ .to("mock:result");
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/8a6c87a4/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/PurchaseOrder.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/PurchaseOrder.java b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/PurchaseOrder.java
deleted file mode 100644
index bea8286..0000000
--- a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/PurchaseOrder.java
+++ /dev/null
@@ -1,72 +0,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.
- */
-package org.apache.camel.dataformat.jibx;
-
-import org.apache.camel.util.ObjectHelper;
-
-/**
- * @version
- */
-public class PurchaseOrder {
- private String name;
- private double price;
- private double amount;
-
- @Override
- public String toString() {
- return "PurchaseOrder[name: " + name + " amount: " + amount + " price: " + price + "]";
- }
-
- @Override
- public boolean equals(Object o) {
- if (o instanceof PurchaseOrder) {
- PurchaseOrder that = (PurchaseOrder) o;
- return ObjectHelper.equal(this.name, that.name)
- && ObjectHelper.equal(this.amount, that.amount)
- && ObjectHelper.equal(this.price, that.price);
- }
- return false;
- }
-
- public int hashCode() {
- return (int) (name.hashCode() + (price * 100) + (amount * 100));
- }
-
- public double getAmount() {
- return amount;
- }
-
- public void setAmount(double amount) {
- this.amount = amount;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public double getPrice() {
- return price;
- }
-
- public void setPrice(double price) {
- this.price = price;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/8a6c87a4/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/model/PurchaseOrder.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/model/PurchaseOrder.java b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/model/PurchaseOrder.java
new file mode 100644
index 0000000..a0722dc
--- /dev/null
+++ b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/model/PurchaseOrder.java
@@ -0,0 +1,72 @@
+/*
+ * 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.dataformat.jibx.model;
+
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * @version
+ */
+public class PurchaseOrder {
+ private String name;
+ private double price;
+ private double amount;
+
+ @Override
+ public String toString() {
+ return "PurchaseOrder[name: " + name + " amount: " + amount + " price: " + price + "]";
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof PurchaseOrder) {
+ PurchaseOrder that = (PurchaseOrder) o;
+ return ObjectHelper.equal(this.name, that.name)
+ && ObjectHelper.equal(this.amount, that.amount)
+ && ObjectHelper.equal(this.price, that.price);
+ }
+ return false;
+ }
+
+ public int hashCode() {
+ return (int) (name.hashCode() + (price * 100) + (amount * 100));
+ }
+
+ public double getAmount() {
+ return amount;
+ }
+
+ public void setAmount(double amount) {
+ this.amount = amount;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public double getPrice() {
+ return price;
+ }
+
+ public void setPrice(double price) {
+ this.price = price;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/8a6c87a4/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/model/PurchaseOrder2.java
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/model/PurchaseOrder2.java b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/model/PurchaseOrder2.java
new file mode 100644
index 0000000..afd2a97
--- /dev/null
+++ b/components/camel-jibx/src/test/java/org/apache/camel/dataformat/jibx/model/PurchaseOrder2.java
@@ -0,0 +1,73 @@
+/*
+ * 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.dataformat.jibx.model;
+
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * @version
+ */
+public class PurchaseOrder2 {
+ private String name;
+ private double price;
+ private double amount;
+
+ @Override
+ public String toString() {
+ return "PurchaseOrder[name: " + name + " amount: " + amount + " price: " + price + "]";
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof PurchaseOrder2) {
+ PurchaseOrder2 that = (PurchaseOrder2) o;
+ return ObjectHelper.equal(this.name, that.name)
+ && ObjectHelper.equal(this.amount, that.amount)
+ && ObjectHelper.equal(this.price, that.price);
+ }
+ return false;
+ }
+
+ public int hashCode() {
+ return (int) (name.hashCode() + (price * 100) + (amount * 100));
+ }
+
+ public double getAmount() {
+ return amount;
+ }
+
+ public void setAmount(double amount) {
+ this.amount = amount;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public double getPrice() {
+ return price;
+ }
+
+ public void setPrice(double price) {
+ this.price = price;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/8a6c87a4/components/camel-jibx/src/test/resources/org/apache/camel/dataformat/jibx/SpringJibxConfigurationTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/resources/org/apache/camel/dataformat/jibx/SpringJibxConfigurationTest.xml b/components/camel-jibx/src/test/resources/org/apache/camel/dataformat/jibx/SpringJibxConfigurationTest.xml
index 81aabc4..6588f59 100644
--- a/components/camel-jibx/src/test/resources/org/apache/camel/dataformat/jibx/SpringJibxConfigurationTest.xml
+++ b/components/camel-jibx/src/test/resources/org/apache/camel/dataformat/jibx/SpringJibxConfigurationTest.xml
@@ -25,7 +25,7 @@
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<dataFormats>
- <jibx id="jibx" unmarshallClass="org.apache.camel.dataformat.jibx.PurchaseOrder"/>
+ <jibx id="jibx" unmarshallClass="org.apache.camel.dataformat.jibx.model.PurchaseOrder"/>
</dataFormats>
<route>
http://git-wip-us.apache.org/repos/asf/camel/blob/8a6c87a4/components/camel-jibx/src/test/resources/org/apache/camel/dataformat/jibx/purchaseOrder-jibx.xml
----------------------------------------------------------------------
diff --git a/components/camel-jibx/src/test/resources/org/apache/camel/dataformat/jibx/purchaseOrder-jibx.xml b/components/camel-jibx/src/test/resources/org/apache/camel/dataformat/jibx/purchaseOrder-jibx.xml
index 80681f1..020a6f5 100644
--- a/components/camel-jibx/src/test/resources/org/apache/camel/dataformat/jibx/purchaseOrder-jibx.xml
+++ b/components/camel-jibx/src/test/resources/org/apache/camel/dataformat/jibx/purchaseOrder-jibx.xml
@@ -16,7 +16,12 @@
limitations under the License.
-->
<binding>
- <mapping name="order" class="org.apache.camel.dataformat.jibx.PurchaseOrder">
+ <mapping name="order" class="org.apache.camel.dataformat.jibx.model.PurchaseOrder">
+ <value name="name" field="name" style="attribute"/>
+ <value name="price" field="price" style="attribute"/>
+ <value name="amount" field="amount" style="attribute"/>
+ </mapping>
+ <mapping name="order2" class="org.apache.camel.dataformat.jibx.model.PurchaseOrder2">
<value name="name" field="name" style="attribute"/>
<value name="price" field="price" style="attribute"/>
<value name="amount" field="amount" style="attribute"/>