You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2023/03/22 14:52:52 UTC

[camel] 02/02: (chores) camel-cron: cleaned up duplicated test code

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit bb04c47d9d41fd23cd90d77ee7164459937a1c67
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Wed Mar 22 14:43:10 2023 +0100

    (chores) camel-cron: cleaned up duplicated test code
---
 .../camel/component/cron/CronPatternsTest.java     | 41 ++++++----------------
 1 file changed, 10 insertions(+), 31 deletions(-)

diff --git a/components/camel-cron/src/test/java/org/apache/camel/component/cron/CronPatternsTest.java b/components/camel-cron/src/test/java/org/apache/camel/component/cron/CronPatternsTest.java
index e9a1d7e9177..5460a1a896c 100644
--- a/components/camel-cron/src/test/java/org/apache/camel/component/cron/CronPatternsTest.java
+++ b/components/camel-cron/src/test/java/org/apache/camel/component/cron/CronPatternsTest.java
@@ -22,32 +22,25 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.spi.BeanIntrospection;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
 
 import static org.junit.jupiter.api.Assertions.assertThrows;
 
 public class CronPatternsTest extends CamelTestSupport {
 
-    @Test
-    void testTooManyParts() throws Exception {
-        context.addRoutes(new RouteBuilder() {
-            @Override
-            public void configure() {
-                from("cron:tab?schedule=0/1 * * * * ? 1 2")
-                        .to("mock:result");
-            }
-        });
-        assertThrows(FailedToCreateRouteException.class, () -> {
-            context.start();
-        });
-    }
-
-    @Test
-    void testTooLittleParts() throws Exception {
+    @ParameterizedTest
+    @ValueSource(strings = {
+            "cron:tab?schedule=0/1 * * * * ? 1 2", "cron:tab?schedule=wrong pattern",
+            "cron://name?schedule=0+0/5+12-18+?+*+MON-FRI+2019+1" })
+    @DisplayName("Test parsing with too many, too little and invalid characters in the pattern")
+    void testParts(String endpointUri) throws Exception {
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() {
-                from("cron:tab?schedule=wrong pattern")
+                from(endpointUri)
                         .to("mock:result");
             }
         });
@@ -78,20 +71,6 @@ public class CronPatternsTest extends CamelTestSupport {
         Assertions.assertEquals(0, bi.getInvokedCounter());
     }
 
-    @Test
-    void testPlusInURINok() throws Exception {
-        context.addRoutes(new RouteBuilder() {
-            @Override
-            public void configure() {
-                from("cron://name?schedule=0+0/5+12-18+?+*+MON-FRI+2019+1")
-                        .to("mock:result");
-            }
-        });
-        assertThrows(FailedToCreateRouteException.class, () -> {
-            context.start();
-        });
-    }
-
     @Override
     public boolean isUseRouteBuilder() {
         return false;