You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by al...@apache.org on 2023/01/31 09:11:00 UTC
[camel-quarkus] branch main updated: Split JSON dataformats test
This is an automated email from the ASF dual-hosted git repository.
aldettinger pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 3cd98500ac Split JSON dataformats test
3cd98500ac is described below
commit 3cd98500acab18026ed7b67cf40aa885bf75cc5a
Author: Lucia Drozdova <ld...@redhat.com>
AuthorDate: Mon Jan 30 12:22:35 2023 +0100
Split JSON dataformats test
---
.../JsonComponentsIT.java => gson/GsonJsonIT.java} | 4 +-
.../GsonJsonTest.java} | 31 +++++++++++--
.../dataformats/jackson/json/JacksonJsonTest.java | 13 +++++-
.../dataformats/jackson/xml/JacksonXmlTest.java | 24 ++++++++++
.../JohnzonJsonIT.java} | 4 +-
.../JohnzonJsonTest.java} | 30 ++++++++++--
.../{JsonComponentsTest.java => JsonBaseTest.java} | 54 ++--------------------
.../JsonbJsonIT.java} | 4 +-
.../JsonbJsonTest.java} | 29 ++++++++++--
9 files changed, 123 insertions(+), 70 deletions(-)
diff --git a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsIT.java b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/gson/GsonJsonIT.java
similarity index 88%
copy from integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsIT.java
copy to integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/gson/GsonJsonIT.java
index 5bd53f4e2d..f6d146d599 100644
--- a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsIT.java
+++ b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/gson/GsonJsonIT.java
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.dataformats.json;
+package org.apache.camel.quarkus.component.dataformats.gson;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
-public class JsonComponentsIT extends JsonComponentsTest {
+public class GsonJsonIT extends GsonJsonTest {
}
diff --git a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsIT.java b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/gson/GsonJsonTest.java
similarity index 52%
copy from integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsIT.java
copy to integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/gson/GsonJsonTest.java
index 5bd53f4e2d..8b2d640c43 100644
--- a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsIT.java
+++ b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/gson/GsonJsonTest.java
@@ -14,10 +14,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.dataformats.json;
+package org.apache.camel.quarkus.component.dataformats.gson;
-import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.quarkus.test.junit.QuarkusTest;
+import org.apache.camel.quarkus.component.dataformats.json.JsonBaseTest;
+import org.junit.jupiter.api.Test;
+
+@QuarkusTest
+public class GsonJsonTest extends JsonBaseTest {
+
+ @Test
+ public void testMarshallAndUnmarshall() {
+ testMarshallAndUnmarshall("Gson");
+ }
+
+ @Test
+ public void testUnmarshallingDifferentPojos() {
+ testUnmarshallingDifferentPojos("Gson");
+ }
+
+ @Test
+ public void testUnmarshallTypeAsAttribute() {
+ testUnmarshal("Gson-type-as-attribute");
+ }
+
+ @Test
+ public void testUnmarshallTypeAsHeader() {
+ testUnmarshal("Gson-type-as-header");
+ }
-@QuarkusIntegrationTest
-public class JsonComponentsIT extends JsonComponentsTest {
}
diff --git a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jackson/json/JacksonJsonTest.java b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jackson/json/JacksonJsonTest.java
index e889d8c883..34e59414f3 100644
--- a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jackson/json/JacksonJsonTest.java
+++ b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jackson/json/JacksonJsonTest.java
@@ -18,12 +18,13 @@ package org.apache.camel.quarkus.component.dataformats.jackson.json;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
+import org.apache.camel.quarkus.component.dataformats.json.JsonBaseTest;
import org.junit.jupiter.api.Test;
import static org.hamcrest.Matchers.equalTo;
@QuarkusTest
-public class JacksonJsonTest {
+public class JacksonJsonTest extends JsonBaseTest {
@Test
void jacksonUnmarshalTypeHeader() {
RestAssured.get("/dataformats-json/jackson/unmarshal-typeheader")
@@ -31,6 +32,16 @@ public class JacksonJsonTest {
.statusCode(204);
}
+ @Test
+ public void jacksonUnmarshallTypeAttribute() {
+ testUnmarshal("Jackson-type-as-attribute");
+ }
+
+ @Test
+ public void jacksonUnmarshallingDifferentPojos() {
+ testUnmarshallingDifferentPojos("Jackson");
+ }
+
@Test
void jacksonUnmarshalList() {
RestAssured.get("/dataformats-json/jackson/unmarshal-list")
diff --git a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jackson/xml/JacksonXmlTest.java b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jackson/xml/JacksonXmlTest.java
index bd1893c5e9..8e6b3b2d97 100644
--- a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jackson/xml/JacksonXmlTest.java
+++ b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jackson/xml/JacksonXmlTest.java
@@ -24,7 +24,9 @@ import javax.json.bind.JsonbBuilder;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
import org.apache.camel.quarkus.component.dataformats.json.model.DummyObject;
+import org.apache.camel.quarkus.component.dataformats.json.model.PojoA;
import org.apache.camel.quarkus.component.dataformats.json.model.TestPojo;
import org.junit.jupiter.api.Test;
@@ -33,6 +35,28 @@ import static org.hamcrest.Matchers.equalTo;
@QuarkusTest
public class JacksonXmlTest {
+
+ @Test
+ void jacksonXmlMarshalAndUnmarshal() {
+ final String xml = "<PojoA><name>Joe</name></PojoA>";
+ final String json = JsonbBuilder.create().toJson(new PojoA("Joe"));
+ RestAssured.given()
+ .contentType(ContentType.JSON)
+ .body(json)
+ .post("/dataformats-json/jacksonxml/marshal")
+ .then()
+ .statusCode(200)
+ .body("PojoA.name", equalTo("Joe"));
+
+ RestAssured.given()
+ .contentType("text/xml")
+ .body(xml)
+ .post("/dataformats-json/jacksonxml/unmarshal")
+ .then()
+ .statusCode(200)
+ .body(equalTo(json));
+ }
+
@Test
void jacksonXmlUnmarshalTypeHeader() {
final String testPojoXml = "<pojo name=\"Camel\"/>";
diff --git a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsIT.java b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/johnzon/JohnzonJsonIT.java
similarity index 88%
copy from integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsIT.java
copy to integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/johnzon/JohnzonJsonIT.java
index 5bd53f4e2d..daf30672d1 100644
--- a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsIT.java
+++ b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/johnzon/JohnzonJsonIT.java
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.dataformats.json;
+package org.apache.camel.quarkus.component.dataformats.johnzon;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
-public class JsonComponentsIT extends JsonComponentsTest {
+public class JohnzonJsonIT extends JohnzonJsonTest {
}
diff --git a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsIT.java b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/johnzon/JohnzonJsonTest.java
similarity index 52%
copy from integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsIT.java
copy to integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/johnzon/JohnzonJsonTest.java
index 5bd53f4e2d..af38561196 100644
--- a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsIT.java
+++ b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/johnzon/JohnzonJsonTest.java
@@ -14,10 +14,32 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.dataformats.json;
+package org.apache.camel.quarkus.component.dataformats.johnzon;
-import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.quarkus.test.junit.QuarkusTest;
+import org.apache.camel.quarkus.component.dataformats.json.JsonBaseTest;
+import org.junit.jupiter.api.Test;
-@QuarkusIntegrationTest
-public class JsonComponentsIT extends JsonComponentsTest {
+@QuarkusTest
+public class JohnzonJsonTest extends JsonBaseTest {
+
+ @Test
+ public void testMarshallAndUnmarshall() {
+ testMarshallAndUnmarshall("Johnzon");
+ }
+
+ @Test
+ public void testUnmarshallingDifferentPojos() {
+ testUnmarshallingDifferentPojos("Johnzon");
+ }
+
+ @Test
+ public void testUnmarshallTypeAsAttribute() {
+ testUnmarshal("Johnzon-type-as-attribute");
+ }
+
+ @Test
+ public void testUnmarshallTypeAsHeader() {
+ testUnmarshal("Johnzon-type-as-header");
+ }
}
diff --git a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsTest.java b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonBaseTest.java
similarity index 64%
rename from integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsTest.java
rename to integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonBaseTest.java
index 7728578d69..6f07951f98 100644
--- a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsTest.java
+++ b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonBaseTest.java
@@ -16,33 +16,16 @@
*/
package org.apache.camel.quarkus.component.dataformats.json;
-import java.util.stream.Stream;
-
import javax.json.bind.JsonbBuilder;
-import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import org.apache.camel.quarkus.component.dataformats.json.model.AnotherObject;
-import org.apache.camel.quarkus.component.dataformats.json.model.PojoA;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
-
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-@QuarkusTest
-public class JsonComponentsTest {
-
- private static Stream<String> listJsonDataFormatsToBeTested() {
- return Stream.of("Jackson", "Johnzon", "Gson", "Jsonb");
- }
+import static org.hamcrest.Matchers.*;
- @ParameterizedTest
- @MethodSource("listJsonDataFormatsToBeTested")
- public void testRoutes(String jsonComponent) {
+public class JsonBaseTest {
+ public void testMarshallAndUnmarshall(String jsonComponent) {
RestAssured.given().contentType(ContentType.TEXT)
.queryParam("json-component", jsonComponent)
.body("[{\"dummy_string\": \"value1\"}, {\"dummy_string\": \"value2\"}]")
@@ -61,8 +44,6 @@ public class JsonComponentsTest {
.body("date", containsString("1970"));
}
- @ParameterizedTest
- @MethodSource("listJsonDataFormatsToBeTested")
public void testUnmarshallingDifferentPojos(String jsonComponent) {
String bodyA = "{\"name\":\"name A\"}";
String bodyB = "{\"value\":1.0}";
@@ -87,12 +68,6 @@ public class JsonComponentsTest {
.body(equalTo(bodyB));
}
- private static Stream<String> listDirectUrisFromXmlRoutesToBeTested() {
- return listJsonDataFormatsToBeTested().flatMap(s -> Stream.of(s + "-type-as-attribute", s + "-type-as-header"));
- }
-
- @ParameterizedTest
- @MethodSource("listDirectUrisFromXmlRoutesToBeTested")
public void testUnmarshal(String directId) {
AnotherObject object = new AnotherObject();
object.setDummyString("95f669ce-d287-4519-b212-4450bc791867");
@@ -104,27 +79,4 @@ public class JsonComponentsTest {
.then()
.body("dummyString", is(object.getDummyString()));
}
-
- @Test
- void jacksonXml() {
- final String xml = "<PojoA><name>Joe</name></PojoA>";
- final String json = JsonbBuilder.create().toJson(new PojoA("Joe"));
- RestAssured.given()
- .contentType(ContentType.JSON)
- .body(json)
- .post("/dataformats-json/jacksonxml/marshal")
- .then()
- .statusCode(200)
- .body("PojoA.name", equalTo("Joe"));
-
- RestAssured.given()
- .contentType("text/xml")
- .body(xml)
- .post("/dataformats-json/jacksonxml/unmarshal")
- .then()
- .statusCode(200)
- .body(equalTo(json));
-
- }
-
}
diff --git a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsIT.java b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jsonb/JsonbJsonIT.java
similarity index 88%
copy from integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsIT.java
copy to integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jsonb/JsonbJsonIT.java
index 5bd53f4e2d..448165e714 100644
--- a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsIT.java
+++ b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jsonb/JsonbJsonIT.java
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.dataformats.json;
+package org.apache.camel.quarkus.component.dataformats.jsonb;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
-public class JsonComponentsIT extends JsonComponentsTest {
+public class JsonbJsonIT extends JsonbJsonTest {
}
diff --git a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsIT.java b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jsonb/JsonbJsonTest.java
similarity index 52%
rename from integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsIT.java
rename to integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jsonb/JsonbJsonTest.java
index 5bd53f4e2d..5f2740cac1 100644
--- a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsIT.java
+++ b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jsonb/JsonbJsonTest.java
@@ -14,10 +14,31 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.dataformats.json;
+package org.apache.camel.quarkus.component.dataformats.jsonb;
-import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.quarkus.test.junit.QuarkusTest;
+import org.apache.camel.quarkus.component.dataformats.json.JsonBaseTest;
+import org.junit.jupiter.api.Test;
-@QuarkusIntegrationTest
-public class JsonComponentsIT extends JsonComponentsTest {
+@QuarkusTest
+public class JsonbJsonTest extends JsonBaseTest {
+ @Test
+ public void testMarshallAndUnmarshall() {
+ testMarshallAndUnmarshall("Jsonb");
+ }
+
+ @Test
+ public void testUnmarshallingDifferentPojos() {
+ testUnmarshallingDifferentPojos("Jsonb");
+ }
+
+ @Test
+ public void testUnmarshallTypeAsAttribute() {
+ testUnmarshal("Jsonb-type-as-attribute");
+ }
+
+ @Test
+ public void testUnmarshallTypeAsHeader() {
+ testUnmarshal("Jsonb-type-as-header");
+ }
}