You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by he...@apache.org on 2014/01/13 20:29:05 UTC
git commit: [XMLJSON] Added extra tests.
Updated Branches:
refs/heads/master 6f2ceef62 -> 275207bc1
[XMLJSON] Added extra tests.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/275207bc
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/275207bc
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/275207bc
Branch: refs/heads/master
Commit: 275207bc15896f596194bc51b329cfab70e9a0a5
Parents: 6f2ceef
Author: Henryk Konsek <he...@gmail.com>
Authored: Mon Jan 13 20:28:45 2014 +0100
Committer: Henryk Konsek <he...@gmail.com>
Committed: Mon Jan 13 20:28:45 2014 +0100
----------------------------------------------------------------------
.../xmljson/JsonToXmlAttributesTest.java | 63 ++++++++++++++++++++
.../xmljson/jsonToXmlAttributesMessage.json | 1 +
2 files changed, 64 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/275207bc/components/camel-xmljson/src/test/java/org/apache/camel/dataformat/xmljson/JsonToXmlAttributesTest.java
----------------------------------------------------------------------
diff --git a/components/camel-xmljson/src/test/java/org/apache/camel/dataformat/xmljson/JsonToXmlAttributesTest.java b/components/camel-xmljson/src/test/java/org/apache/camel/dataformat/xmljson/JsonToXmlAttributesTest.java
new file mode 100644
index 0000000..a0b455f
--- /dev/null
+++ b/components/camel-xmljson/src/test/java/org/apache/camel/dataformat/xmljson/JsonToXmlAttributesTest.java
@@ -0,0 +1,63 @@
+/**
+ * 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.xmljson;
+
+import java.io.InputStream;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class JsonToXmlAttributesTest extends CamelTestSupport {
+
+ @Test
+ public void shouldCreateAttribute() {
+ // Given
+ InputStream inStream = getClass().getClassLoader().getResourceAsStream("org/apache/camel/dataformat/xmljson/jsonToXmlAttributesMessage.json");
+ String in = context.getTypeConverter().convertTo(String.class, inStream);
+
+ // When
+ String xml = template.requestBody("direct:unmarshal", in, String.class);
+
+ // Then
+ assertTrue(xml.contains(" b=\"2\""));
+ }
+
+ @Test
+ public void shouldCreateOnlyOneAttribute() {
+ // Given
+ InputStream inStream = getClass().getClassLoader().getResourceAsStream("org/apache/camel/dataformat/xmljson/jsonToXmlAttributesMessage.json");
+ String in = context.getTypeConverter().convertTo(String.class, inStream);
+
+ // When
+ String xml = template.requestBody("direct:unmarshal", in, String.class);
+
+ // Then
+ assertFalse(xml.contains("a="));
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:unmarshal").unmarshal().xmljson().to("mock:xml");
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/275207bc/components/camel-xmljson/src/test/resources/org/apache/camel/dataformat/xmljson/jsonToXmlAttributesMessage.json
----------------------------------------------------------------------
diff --git a/components/camel-xmljson/src/test/resources/org/apache/camel/dataformat/xmljson/jsonToXmlAttributesMessage.json b/components/camel-xmljson/src/test/resources/org/apache/camel/dataformat/xmljson/jsonToXmlAttributesMessage.json
new file mode 100644
index 0000000..33096f4
--- /dev/null
+++ b/components/camel-xmljson/src/test/resources/org/apache/camel/dataformat/xmljson/jsonToXmlAttributesMessage.json
@@ -0,0 +1 @@
+{ "a": "1", "@b": "2"}
\ No newline at end of file