This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 82b960c67011875e0b684d72f213bd8d6063deac Author: Guillaume Nodet <gno...@gmail.com> AuthorDate: Thu Jul 9 10:02:34 2020 +0200 [CAMEL-11807] Upgrade camel-jsonapi to junit5 --- components/camel-jsonapi/pom.xml | 8 ++++---- .../component/jsonapi/JsonApiDataFormatTest.java | 23 ++++++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/components/camel-jsonapi/pom.xml b/components/camel-jsonapi/pom.xml index 55554f4..1944933 100644 --- a/components/camel-jsonapi/pom.xml +++ b/components/camel-jsonapi/pom.xml @@ -51,17 +51,17 @@ <!-- testing --> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test</artifactId> + <artifactId>camel-test-junit5</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test-spring</artifactId> + <artifactId>camel-test-spring-junit5</artifactId> <scope>test</scope> </dependency> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/components/camel-jsonapi/src/test/java/org/apache/camel/component/jsonapi/JsonApiDataFormatTest.java b/components/camel-jsonapi/src/test/java/org/apache/camel/component/jsonapi/JsonApiDataFormatTest.java index 031e135..cf6ee54 100644 --- a/components/camel-jsonapi/src/test/java/org/apache/camel/component/jsonapi/JsonApiDataFormatTest.java +++ b/components/camel-jsonapi/src/test/java/org/apache/camel/component/jsonapi/JsonApiDataFormatTest.java @@ -25,8 +25,12 @@ import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.support.DefaultExchange; -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; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; public class JsonApiDataFormatTest extends CamelTestSupport { @@ -46,24 +50,26 @@ public class JsonApiDataFormatTest extends CamelTestSupport { assertEquals(this.generateTestDataAsString(), jsonApiOutput); } - @Test(expected = DocumentSerializationException.class) + @Test public void testJsonApiMarshalNoAnnotationOnType() throws Exception { Class<?>[] formats = {MyBook.class, MyAuthor.class}; JsonApiDataFormat jsonApiDataFormat = new JsonApiDataFormat(formats); Exchange exchange = new DefaultExchange(context); ByteArrayOutputStream baos = new ByteArrayOutputStream(); - jsonApiDataFormat.marshal(exchange, new FooBar(), baos); + assertThrows(DocumentSerializationException.class, + () -> jsonApiDataFormat.marshal(exchange, new FooBar(), baos)); } - @Test(expected = DocumentSerializationException.class) + @Test public void testJsonApiMarshalWrongType() throws Exception { Class<?>[] formats = {MyBook.class, MyAuthor.class}; JsonApiDataFormat jsonApiDataFormat = new JsonApiDataFormat(formats); Exchange exchange = new DefaultExchange(context); ByteArrayOutputStream baos = new ByteArrayOutputStream(); - jsonApiDataFormat.marshal(exchange, new MyFooBar("bar"), baos); + assertThrows(DocumentSerializationException.class, + () -> jsonApiDataFormat.marshal(exchange, new MyFooBar("bar"), baos)); } @Test @@ -82,7 +88,7 @@ public class JsonApiDataFormatTest extends CamelTestSupport { assertEquals("1", book.getAuthor().getAuthorId()); } - @Test(expected = UnregisteredTypeException.class) + @Test public void testJsonApiUnmarshalWrongType() throws Exception { Class<?>[] formats = {MyBook.class, MyAuthor.class}; JsonApiDataFormat jsonApiDataFormat = new JsonApiDataFormat(); @@ -92,7 +98,8 @@ public class JsonApiDataFormatTest extends CamelTestSupport { String jsonApiInput = "{\"data\":{\"type\":\"animal\",\"id\":\"camel\",\"attributes\":{\"humps\":\"2\"}}}"; Exchange exchange = new DefaultExchange(context); - jsonApiDataFormat.unmarshal(exchange, new ByteArrayInputStream(jsonApiInput.getBytes())); + assertThrows(UnregisteredTypeException.class, + () -> jsonApiDataFormat.unmarshal(exchange, new ByteArrayInputStream(jsonApiInput.getBytes()))); } @Test