This is an automated email from the ASF dual-hosted git repository. aldettinger pushed a commit to branch CAMEL-13826 in repository https://gitbox.apache.org/repos/asf/camel.git
commit f73fc59dd8177536d661b05b8786b9d2bc72136c Author: aldettinger <[email protected]> AuthorDate: Wed Aug 21 17:31:13 2019 +0200 CAMEL-13826: Migrated half of the camel-xstream tests to JUnit 5 (testing coexistence of JUnit 4 and JUnit 5) --- .../camel-test-junit5/src/main/docs/test-junit5.adoc | 3 +++ components/camel-xstream/pom.xml | 9 +++++++++ .../dataformat/xstream/MarshalDomainObjectJSONTest.java | 4 +++- .../camel/dataformat/xstream/MarshalDomainObjectTest.java | 8 +++++--- .../xstream/XStreamDataFormatOmitFieldsTest.java | 15 +++++++++------ .../XStreamDataFormatPermissionsSystemPropertyTest.java | 13 ++++++++----- .../xstream/XStreamDataFormatPermissionsTest.java | 7 +++++-- parent/pom.xml | 4 ++-- .../camel-spring-boot-dependencies-generator/pom.xml | 1 + 9 files changed, 45 insertions(+), 19 deletions(-) diff --git a/components/camel-test-junit5/src/main/docs/test-junit5.adoc b/components/camel-test-junit5/src/main/docs/test-junit5.adoc index f31ff75..41fc9ab 100644 --- a/components/camel-test-junit5/src/main/docs/test-junit5.adoc +++ b/components/camel-test-junit5/src/main/docs/test-junit5.adoc @@ -57,6 +57,9 @@ Projects using `camel-test` would need to use `camel-test-junit5`. For instance, </dependency> ---- +Tips: It's possible to run JUnit4 & JUnit5 based camel tests side by side including the following dependencies `camel-test`, +`camel-test-junit5` and `junit-vintage-engine`. This configuration allows to migrate a camel test at once. + === Typical migration steps linked to JUnit 5 support in Camel Test * Imports of `org.apache.camel.test.junit4.\*` should be replaced with `org.apache.camel.test.junit5.*` * `TestSupport` static methods should be imported where needed, for instance `import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf` diff --git a/components/camel-xstream/pom.xml b/components/camel-xstream/pom.xml index d3fa5d7..5228837 100644 --- a/components/camel-xstream/pom.xml +++ b/components/camel-xstream/pom.xml @@ -77,6 +77,15 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-test-junit5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.vintage</groupId> + <artifactId>junit-vintage-engine</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-spring</artifactId> <scope>test</scope> </dependency> diff --git a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectJSONTest.java b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectJSONTest.java index 6f6ad86..2e6fe37 100644 --- a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectJSONTest.java +++ b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectJSONTest.java @@ -19,7 +19,9 @@ package org.apache.camel.dataformat.xstream; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.model.dataformat.JsonLibrary; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class MarshalDomainObjectJSONTest extends MarshalDomainObjectTest { diff --git a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectTest.java b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectTest.java index 8e429d5..2096c85 100644 --- a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectTest.java +++ b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/MarshalDomainObjectTest.java @@ -18,8 +18,10 @@ package org.apache.camel.dataformat.xstream; 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; /** * Marshal tests with domain objects. @@ -58,7 +60,7 @@ public class MarshalDomainObjectTest extends CamelTestSupport { String body1 = mock.getExchanges().get(0).getIn().getBody(String.class); String body2 = mock.getExchanges().get(1).getIn().getBody(String.class); - assertEquals("The body should marshalled to the same", body1, body2); + assertEquals(body1, body2, "The body should marshalled to the same"); } @Test diff --git a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatOmitFieldsTest.java b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatOmitFieldsTest.java index b6d34e2..b9df598 100644 --- a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatOmitFieldsTest.java +++ b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatOmitFieldsTest.java @@ -21,8 +21,11 @@ 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.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class XStreamDataFormatOmitFieldsTest extends CamelTestSupport { @@ -40,10 +43,10 @@ public class XStreamDataFormatOmitFieldsTest extends CamelTestSupport { assertMockEndpointsSatisfied(); - String body = mock.getReceivedExchanges().get(0).getIn().getBody(String.class); - assertTrue("Should contain name field", body.contains("<name>")); - assertFalse("Should not contain price field", body.contains("price")); - assertTrue("Should contain amount field", body.contains("<amount>")); + String body = mock.getReceivedExchanges().get(0).getIn().getBody(String.class); + assertTrue(body.contains("<name>"), "Should contain name field"); + assertFalse(body.contains("price"), "Should not contain price field"); + assertTrue(body.contains("<amount>"), "Should contain amount field"); } diff --git a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatPermissionsSystemPropertyTest.java b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatPermissionsSystemPropertyTest.java index 99f83d6..acf39a4 100644 --- a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatPermissionsSystemPropertyTest.java +++ b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatPermissionsSystemPropertyTest.java @@ -16,20 +16,23 @@ */ package org.apache.camel.dataformat.xstream; import com.thoughtworks.xstream.XStream; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; public class XStreamDataFormatPermissionsSystemPropertyTest extends XStreamDataFormatPermissionsTest { - @BeforeClass + @BeforeAll public static void setup() { // clear the default permissions system property // see AbstractXStreamWrapper.PERMISSIONS_PROPERTY_DEFAULT XStreamTestUtils.setPermissionSystemProperty("*"); } - @AfterClass + @AfterAll public static void cleanup() { XStreamTestUtils.revertPermissionSystemProperty(); } diff --git a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatPermissionsTest.java b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatPermissionsTest.java index 425be60..ee8a274 100644 --- a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatPermissionsTest.java +++ b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatPermissionsTest.java @@ -18,8 +18,11 @@ package org.apache.camel.dataformat.xstream; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.security.ForbiddenClassException; -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.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; public class XStreamDataFormatPermissionsTest extends CamelTestSupport { protected static final String XML_PURCHASE_ORDER = diff --git a/parent/pom.xml b/parent/pom.xml index ff02f73..152ec2d 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -4793,8 +4793,8 @@ <version>${junit-jupiter-version}</version> </dependency> <dependency> - <groupId>org.junit.jupiter</groupId> - <artifactId>junit-jupiter-vintage</artifactId> + <groupId>org.junit.vintage</groupId> + <artifactId>junit-vintage-engine</artifactId> <version>${junit-jupiter-version}</version> </dependency> <dependency> diff --git a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies-generator/pom.xml b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies-generator/pom.xml index 38b5af6..9e5cc33 100644 --- a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies-generator/pom.xml +++ b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies-generator/pom.xml @@ -160,6 +160,7 @@ <exclude>javax.servlet:javax.servlet-api</exclude> <exclude>junit:*</exclude> <exclude>org.junit.jupiter:*</exclude> + <exclude>org.junit.vintage:*</exclude> <exclude>net.sf.ehcache:ehcache</exclude> <exclude>xml-apis:*</exclude>
