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 a8b8a190c227f9e37fb23e2f2846f67ca3913dea Author: Guillaume Nodet <[email protected]> AuthorDate: Thu Jun 11 08:39:01 2020 +0200 [CAMEL-11807] Upgrade camel-google-calendar to junit5 --- components/camel-google-calendar/pom.xml | 2 +- .../calendar/AbstractGoogleCalendarTestSupport.java | 18 +++++++----------- .../google/calendar/CalendarAclIntegrationTest.java | 4 +++- .../calendar/CalendarCalendarListIntegrationTest.java | 6 ++++-- .../calendar/CalendarCalendarsIntegrationTest.java | 7 +++++-- .../google/calendar/CalendarColorsIntegrationTest.java | 6 ++++-- .../google/calendar/CalendarConfigurationTest.java | 13 ++++++++----- .../google/calendar/CalendarEventsIntegrationTest.java | 7 +++++-- .../calendar/CalendarFreebusyIntegrationTest.java | 6 ++++-- .../calendar/CalendarSettingsIntegrationTest.java | 8 +++++--- .../AbstractGoogleCalendarStreamTestSupport.java | 9 +++------ .../GoogleCalendarStreamConsumerIntegrationTest.java | 2 +- 12 files changed, 50 insertions(+), 38 deletions(-) diff --git a/components/camel-google-calendar/pom.xml b/components/camel-google-calendar/pom.xml index 52f3b4c..1249547 100644 --- a/components/camel-google-calendar/pom.xml +++ b/components/camel-google-calendar/pom.xml @@ -85,7 +85,7 @@ <!-- testing --> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test</artifactId> + <artifactId>camel-test-junit5</artifactId> <scope>test</scope> </dependency> </dependencies> diff --git a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/AbstractGoogleCalendarTestSupport.java b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/AbstractGoogleCalendarTestSupport.java index e906f9f..3f1adbe 100644 --- a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/AbstractGoogleCalendarTestSupport.java +++ b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/AbstractGoogleCalendarTestSupport.java @@ -26,20 +26,22 @@ import com.google.api.services.calendar.model.Calendar; import org.apache.camel.CamelContext; import org.apache.camel.CamelExecutionException; import org.apache.camel.support.PropertyBindingSupport; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.After; -import org.junit.Before; +import org.apache.camel.test.junit5.CamelTestSupport; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInstance; /** * Abstract base class for GoogleCalendar Integration tests generated by Camel * API component maven plugin. */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class AbstractGoogleCalendarTestSupport extends CamelTestSupport { private static final String TEST_OPTIONS_PROPERTIES = "/test-options.properties"; private Calendar calendar; - @Before + @BeforeEach public void createTestCalendar() { Calendar calendar = new Calendar(); Random rand = new Random(); @@ -50,7 +52,7 @@ public class AbstractGoogleCalendarTestSupport extends CamelTestSupport { this.calendar = requestBody("google-calendar://calendars/insert?inBody=content", calendar); } - @After + @AfterEach public void deleteTestCalendar() { try { if (calendar != null) { @@ -91,12 +93,6 @@ public class AbstractGoogleCalendarTestSupport extends CamelTestSupport { return context; } - @Override - public boolean isCreateCamelContextPerClass() { - // only create the context once for this class - return true; - } - @SuppressWarnings("unchecked") protected <T> T requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) throws CamelExecutionException { return (T) template().requestBodyAndHeaders(endpointUri, body, headers); diff --git a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarAclIntegrationTest.java b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarAclIntegrationTest.java index 1566b61..f613016 100644 --- a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarAclIntegrationTest.java +++ b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarAclIntegrationTest.java @@ -19,10 +19,12 @@ package org.apache.camel.component.google.calendar; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.google.calendar.internal.CalendarAclApiMethod; import org.apache.camel.component.google.calendar.internal.GoogleCalendarApiCollection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Test class for {@link com.google.api.services.calendar.Calendar$Acl} APIs. */ diff --git a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarCalendarListIntegrationTest.java b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarCalendarListIntegrationTest.java index 7351707..2b3a272 100644 --- a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarCalendarListIntegrationTest.java +++ b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarCalendarListIntegrationTest.java @@ -22,7 +22,9 @@ import com.google.api.services.calendar.model.CalendarListEntry; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.google.calendar.internal.CalendarCalendarListApiMethod; import org.apache.camel.component.google.calendar.internal.GoogleCalendarApiCollection; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test class for {@link com.google.api.services.calendar.Calendar$CalendarList} APIs. @@ -34,7 +36,7 @@ public class CalendarCalendarListIntegrationTest extends AbstractGoogleCalendarT @Test public void testCalendarList() throws Exception { Calendar calendar = getCalendar(); - assertTrue("Test calendar should be in the list", isCalendarInList(calendar)); + assertTrue(isCalendarInList(calendar), "Test calendar should be in the list"); CalendarListEntry calendarFromGet = requestBody("direct://GET", calendar.getId()); assertTrue(calendar.getId().equals(calendarFromGet.getId())); diff --git a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarCalendarsIntegrationTest.java b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarCalendarsIntegrationTest.java index 71882ea..1b55f5e 100644 --- a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarCalendarsIntegrationTest.java +++ b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarCalendarsIntegrationTest.java @@ -23,7 +23,10 @@ import com.google.api.services.calendar.model.Calendar; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.google.calendar.internal.CalendarCalendarsApiMethod; import org.apache.camel.component.google.calendar.internal.GoogleCalendarApiCollection; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Test class for {@link com.google.api.services.calendar.Calendar$Calendars} APIs. @@ -50,7 +53,7 @@ public class CalendarCalendarsIntegrationTest extends AbstractGoogleCalendarTest requestBody("direct://DELETE", calendar.getId()); try { calendarFromGet = requestBody("direct://GET", calendar.getId()); - assertTrue("Should have not found deleted calendar.", false); + fail("Should have not found deleted calendar."); } catch (Exception e) { e.printStackTrace(); } diff --git a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarColorsIntegrationTest.java b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarColorsIntegrationTest.java index eddaf40..b6b34f6 100644 --- a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarColorsIntegrationTest.java +++ b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarColorsIntegrationTest.java @@ -19,10 +19,12 @@ package org.apache.camel.component.google.calendar; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.google.calendar.internal.CalendarColorsApiMethod; import org.apache.camel.component.google.calendar.internal.GoogleCalendarApiCollection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.jupiter.api.Assertions.assertNotNull; + /** * Test class for {@link com.google.api.services.calendar.Calendar$Colors} APIs. */ @@ -35,7 +37,7 @@ public class CalendarColorsIntegrationTest extends AbstractGoogleCalendarTestSup public void testGet() throws Exception { com.google.api.services.calendar.model.Colors result = requestBody("direct://GET", null); - assertNotNull("get result", result); + assertNotNull(result, "get result"); LOG.debug("get: " + result); } diff --git a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarConfigurationTest.java b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarConfigurationTest.java index ff549d9..c00fdb9 100644 --- a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarConfigurationTest.java +++ b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarConfigurationTest.java @@ -21,24 +21,27 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.google.calendar.internal.CalendarCalendarsApiMethod; import org.apache.camel.component.google.calendar.internal.GoogleCalendarApiCollection; import org.apache.camel.impl.DefaultCamelContext; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class CalendarConfigurationTest extends AbstractGoogleCalendarTestSupport { private static final Logger LOG = LoggerFactory.getLogger(CalendarConfigurationTest.class); private static final String PATH_PREFIX = GoogleCalendarApiCollection.getCollection().getApiName(CalendarCalendarsApiMethod.class).getName(); private static final String TEST_URI = "google-calendar://" + PATH_PREFIX + "/get?clientId=a&clientSecret=b&applicationName=c&accessToken=d&refreshToken=e"; - @Before + @BeforeEach @Override public void createTestCalendar() { } - @After + @AfterEach @Override public void deleteTestCalendar() { } diff --git a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarEventsIntegrationTest.java b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarEventsIntegrationTest.java index 8216904..e2a7aeb 100644 --- a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarEventsIntegrationTest.java +++ b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarEventsIntegrationTest.java @@ -29,10 +29,13 @@ import com.google.api.services.calendar.model.EventDateTime; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.google.calendar.internal.CalendarEventsApiMethod; import org.apache.camel.component.google.calendar.internal.GoogleCalendarApiCollection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + /** * Test class for {@link com.google.api.services.calendar.Calendar$Events} APIs. */ @@ -80,7 +83,7 @@ public class CalendarEventsIntegrationTest extends AbstractGoogleCalendarTestSup // parameter type is String headers.put("CamelGoogleCalendar.text", "Feed the Camel"); com.google.api.services.calendar.model.Event result = requestBodyAndHeaders("direct://QUICKADD", null, headers); - assertNotNull("quickAdd result", result); + assertNotNull(result, "quickAdd result"); // Check if it is in the list of events for this calendar com.google.api.services.calendar.model.Events events = requestBody("direct://LIST", getCalendar().getId()); diff --git a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarFreebusyIntegrationTest.java b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarFreebusyIntegrationTest.java index 5d8c3e6..902e894 100644 --- a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarFreebusyIntegrationTest.java +++ b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarFreebusyIntegrationTest.java @@ -25,10 +25,12 @@ import com.google.api.services.calendar.model.FreeBusyRequestItem; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.google.calendar.internal.CalendarFreebusyApiMethod; import org.apache.camel.component.google.calendar.internal.GoogleCalendarApiCollection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.jupiter.api.Assertions.assertNotNull; + /** * The class source won't be generated again if the generator MOJO finds it under src/test/java. */ @@ -51,7 +53,7 @@ public class CalendarFreebusyIntegrationTest extends AbstractGoogleCalendarTestS final com.google.api.services.calendar.model.FreeBusyResponse result = requestBody("direct://QUERY", request); - assertNotNull("query result", result); + assertNotNull(result, "query result"); LOG.debug("query: " + result); } diff --git a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarSettingsIntegrationTest.java b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarSettingsIntegrationTest.java index 7bf25ee..b2e3f24 100644 --- a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarSettingsIntegrationTest.java +++ b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/CalendarSettingsIntegrationTest.java @@ -19,10 +19,12 @@ package org.apache.camel.component.google.calendar; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.google.calendar.internal.CalendarSettingsApiMethod; import org.apache.camel.component.google.calendar.internal.GoogleCalendarApiCollection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.jupiter.api.Assertions.assertNotNull; + /** * Test class for {@link com.google.api.services.calendar.Calendar$Settings} APIs. */ @@ -36,7 +38,7 @@ public class CalendarSettingsIntegrationTest extends AbstractGoogleCalendarTestS // using String message body for single parameter "setting" final com.google.api.services.calendar.model.Setting result = requestBody("direct://GET", "timezone"); - assertNotNull("get result", result); + assertNotNull(result, "get result"); LOG.debug("get: " + result); } @@ -44,7 +46,7 @@ public class CalendarSettingsIntegrationTest extends AbstractGoogleCalendarTestS public void testList() throws Exception { final com.google.api.services.calendar.model.Settings result = requestBody("direct://LIST", null); - assertNotNull("list result", result); + assertNotNull(result, "list result"); LOG.debug("list: " + result); } diff --git a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/AbstractGoogleCalendarStreamTestSupport.java b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/AbstractGoogleCalendarStreamTestSupport.java index e0e2fb9..70cd11d 100644 --- a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/AbstractGoogleCalendarStreamTestSupport.java +++ b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/AbstractGoogleCalendarStreamTestSupport.java @@ -23,12 +23,14 @@ import java.util.Properties; import org.apache.camel.CamelContext; import org.apache.camel.support.PropertyBindingSupport; -import org.apache.camel.test.junit4.CamelTestSupport; +import org.apache.camel.test.junit5.CamelTestSupport; +import org.junit.jupiter.api.TestInstance; /** * Abstract base class for GoogleCalendar Integration tests generated by Camel API * component maven plugin. */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class AbstractGoogleCalendarStreamTestSupport extends CamelTestSupport { // userid of the currently authenticated user @@ -64,9 +66,4 @@ public class AbstractGoogleCalendarStreamTestSupport extends CamelTestSupport { return context; } - @Override - public boolean isCreateCamelContextPerClass() { - // only create the context once for this class - return true; - } } diff --git a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConsumerIntegrationTest.java b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConsumerIntegrationTest.java index d58ed8f..d99b1f5 100644 --- a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConsumerIntegrationTest.java +++ b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConsumerIntegrationTest.java @@ -18,7 +18,7 @@ package org.apache.camel.component.google.calendar.stream; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class GoogleCalendarStreamConsumerIntegrationTest extends AbstractGoogleCalendarStreamTestSupport {
