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 2020/02/28 15:48:14 UTC
[camel] branch master updated: CAMEL-11807: Migrated camel-johnzon
tests to JUnit 5
This is an automated email from the ASF dual-hosted git repository.
aldettinger pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 29a59cd CAMEL-11807: Migrated camel-johnzon tests to JUnit 5
29a59cd is described below
commit 29a59cd81555ff774044c8987b36115ace469bd0
Author: aldettinger <al...@gmail.com>
AuthorDate: Fri Feb 28 16:46:21 2020 +0100
CAMEL-11807: Migrated camel-johnzon tests to JUnit 5
---
components/camel-johnzon/pom.xml | 7 +----
.../johnzon/JohnzonAttributeOrderTest.java | 10 +++---
.../component/johnzon/JohnzonDataFormatTest.java | 36 +++++++++++++---------
.../johnzon/JohnzonJsonDataFormatTest.java | 2 +-
.../component/johnzon/JohnzonMarshalTest.java | 10 +++---
.../component/johnzon/JohnzonSkipNullTest.java | 8 ++---
.../johnzon/SpringJohnzonJsonDataFormatTest.java | 6 ++--
7 files changed, 43 insertions(+), 36 deletions(-)
diff --git a/components/camel-johnzon/pom.xml b/components/camel-johnzon/pom.xml
index 0c2c34a..5de7e78 100644
--- a/components/camel-johnzon/pom.xml
+++ b/components/camel-johnzon/pom.xml
@@ -60,7 +60,7 @@
<!-- testing -->
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test-spring</artifactId>
+ <artifactId>camel-test-spring-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -78,11 +78,6 @@
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git a/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonAttributeOrderTest.java b/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonAttributeOrderTest.java
index eb067da..2dff562 100644
--- a/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonAttributeOrderTest.java
+++ b/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonAttributeOrderTest.java
@@ -21,8 +21,10 @@ import java.util.Comparator;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class JohnzonAttributeOrderTest extends CamelTestSupport {
@@ -53,11 +55,11 @@ public class JohnzonAttributeOrderTest extends CamelTestSupport {
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
- public void configure() throws Exception {
+ public void configure() {
final Comparator<String> attributeOrder = new Comparator<String>() {
@Override
public int compare(final String o1, final String o2) {
diff --git a/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonDataFormatTest.java b/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonDataFormatTest.java
index 0f96224..c7a6140 100644
--- a/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonDataFormatTest.java
+++ b/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonDataFormatTest.java
@@ -26,9 +26,9 @@ import java.util.Map;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.support.DefaultExchange;
import org.apache.johnzon.mapper.reflection.JohnzonParameterizedType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class JohnzonDataFormatTest {
@@ -61,20 +61,26 @@ public class JohnzonDataFormatTest {
new ArrayList<>(Collections.singletonList(Collections.emptyList())), null, type);
}
- private void testJson(String json, Object expected, Class<?> unmarshalType,
- JohnzonParameterizedType parameterizedType) throws Exception {
+ private void testJson(String json, Object expected, Class<?> unmarshalType, JohnzonParameterizedType parameterizedType) throws Exception {
Object unmarshalled;
- JohnzonDataFormat johnzonDataFormat;
- if (unmarshalType != null) {
- johnzonDataFormat = new JohnzonDataFormat(unmarshalType);
- } else {
- johnzonDataFormat = new JohnzonDataFormat(parameterizedType);
- }
- johnzonDataFormat.setSkipEmptyArray(true);
- johnzonDataFormat.doStart();
- try (InputStream in = new ByteArrayInputStream(json.getBytes())) {
- unmarshalled = johnzonDataFormat.unmarshal(new DefaultExchange(new DefaultCamelContext()), in);
+ JohnzonDataFormat johnzonDataFormat = null;
+
+ try {
+ if (unmarshalType != null) {
+ johnzonDataFormat = new JohnzonDataFormat(unmarshalType);
+ } else {
+ johnzonDataFormat = new JohnzonDataFormat(parameterizedType);
+ }
+ johnzonDataFormat.setSkipEmptyArray(true);
+ johnzonDataFormat.doStart();
+ try (InputStream in = new ByteArrayInputStream(json.getBytes())) {
+ unmarshalled = johnzonDataFormat.unmarshal(new DefaultExchange(new DefaultCamelContext()), in);
+ }
+ assertEquals(expected, unmarshalled);
+ } finally {
+ if (johnzonDataFormat != null) {
+ johnzonDataFormat.close();
+ }
}
- assertEquals(expected, unmarshalled);
}
}
diff --git a/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonJsonDataFormatTest.java b/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonJsonDataFormatTest.java
index 05162fc..939e9a4 100644
--- a/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonJsonDataFormatTest.java
+++ b/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonJsonDataFormatTest.java
@@ -22,7 +22,7 @@ import org.apache.camel.model.dataformat.JsonLibrary;
public class JohnzonJsonDataFormatTest extends JohnzonMarshalTest {
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
diff --git a/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonMarshalTest.java b/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonMarshalTest.java
index 85c55a0..e688fef 100644
--- a/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonMarshalTest.java
+++ b/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonMarshalTest.java
@@ -21,8 +21,10 @@ import java.util.Map;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class JohnzonMarshalTest extends CamelTestSupport {
@@ -65,11 +67,11 @@ public class JohnzonMarshalTest extends CamelTestSupport {
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
- public void configure() throws Exception {
+ public void configure() {
JohnzonDataFormat format = new JohnzonDataFormat();
from("direct:in").marshal(format);
diff --git a/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonSkipNullTest.java b/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonSkipNullTest.java
index 6bda921..137c02a 100644
--- a/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonSkipNullTest.java
+++ b/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/JohnzonSkipNullTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.component.johnzon;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
public class JohnzonSkipNullTest extends CamelTestSupport {
@@ -39,11 +39,11 @@ public class JohnzonSkipNullTest extends CamelTestSupport {
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
- public void configure() throws Exception {
+ public void configure() {
JohnzonDataFormat format = new JohnzonDataFormat();
format.setSkipNull(true);
diff --git a/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/SpringJohnzonJsonDataFormatTest.java b/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/SpringJohnzonJsonDataFormatTest.java
index efea8f7..720ef6a 100644
--- a/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/SpringJohnzonJsonDataFormatTest.java
+++ b/components/camel-johnzon/src/test/java/org/apache/camel/component/johnzon/SpringJohnzonJsonDataFormatTest.java
@@ -20,11 +20,13 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.spring.CamelSpringTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
+import org.junit.jupiter.api.Test;
import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class SpringJohnzonJsonDataFormatTest extends CamelSpringTestSupport {
@Test