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 2024/04/15 14:12:25 UTC

(camel) branch main updated (3d9e3a3980d -> 2204694f8de)

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

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


    from 3d9e3a3980d Upgrade kubernetes client 6.12.0 and remove unused version (#13793)
     new d4484664c91 (chores) camel-core: simplify collection call
     new 090d0aa972b (chores) camel-core: simplify assertions
     new 0caedf59647 (chores) camel-core: modernized throw-based assertions
     new 2204694f8de (chores) camel-core: fixed incorrect test

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/camel/ThreadPoolRejectedPolicyTest.java | 11 +++++-----
 .../BeanWithExchangeExceptionAnnotationTest.java   | 11 +++++++---
 ...ngeExceptionAnnotationWrappedExceptionTest.java | 13 +++++++----
 .../apache/camel/model/RoutePropertiesTest.java    | 25 +++++++++++-----------
 .../camel/support/cache/SimpleSoftCacheTest.java   |  6 ++----
 .../camel/management/ManagedStartupFailedTest.java |  4 ++--
 6 files changed, 39 insertions(+), 31 deletions(-)


(camel) 04/04: (chores) camel-core: fixed incorrect test

Posted by or...@apache.org.
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 2204694f8deed71daadb0ea64052df16628687d7
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Fri Apr 12 11:42:24 2024 +0200

    (chores) camel-core: fixed incorrect test
    
    The test was always using the bean from the parent class, resulting in the one from the subclass being unused.
---
 .../bean/BeanWithExchangeExceptionAnnotationTest.java       | 11 ++++++++---
 ...WithExchangeExceptionAnnotationWrappedExceptionTest.java | 13 +++++++++----
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithExchangeExceptionAnnotationTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithExchangeExceptionAnnotationTest.java
index d1e20219da3..c51b357150c 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithExchangeExceptionAnnotationTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithExchangeExceptionAnnotationTest.java
@@ -43,10 +43,14 @@ public class BeanWithExchangeExceptionAnnotationTest extends ContextTestSupport
         error.assertIsSatisfied();
     }
 
+    protected Object getBean() {
+        return new MyBean();
+    }
+
     @Override
     protected Registry createCamelRegistry() throws Exception {
         Registry answer = super.createCamelRegistry();
-        answer.bind("myBean", new MyBean());
+        answer.bind("myBean", getBean());
         return answer;
     }
 
@@ -65,14 +69,15 @@ public class BeanWithExchangeExceptionAnnotationTest extends ContextTestSupport
     }
 
     public static class MyBean {
+        private static final String MESSAGE = "I'm being thrown from " + BeanWithExchangeExceptionAnnotationTest.class;
 
         public void throwException() throws MyCustomException {
-            throw new MyCustomException("I'm being thrown!!");
+            throw new MyCustomException(MESSAGE);
         }
 
         public void handleException(@ExchangeException Exception exception) {
             assertNotNull(exception);
-            assertEquals("I'm being thrown!!", exception.getMessage());
+            assertEquals(MESSAGE, exception.getMessage());
         }
     }
 }
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithExchangeExceptionAnnotationWrappedExceptionTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithExchangeExceptionAnnotationWrappedExceptionTest.java
index ef033b2a618..c00f52a50d1 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithExchangeExceptionAnnotationWrappedExceptionTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithExchangeExceptionAnnotationWrappedExceptionTest.java
@@ -25,13 +25,18 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 public class BeanWithExchangeExceptionAnnotationWrappedExceptionTest extends BeanWithExchangeExceptionAnnotationTest {
 
+    @Override
+    protected Object getBean() {
+        return new MyBean();
+    }
+
     public static class MyBean {
+        private static final String MESSAGE
+                = "I'm being thrown from " + BeanWithExchangeExceptionAnnotationWrappedExceptionTest.class;
 
         public void throwException() throws Exception {
             // wrap the problem in an IO exception
-            IOException io = new IOException("Forced");
-            io.initCause(new MyCustomException("I'm being thrown!!"));
-            throw io;
+            throw new IOException("Forced", new MyCustomException(MESSAGE));
         }
 
         // to unit test that we can set a type to the @ExchangeException that we
@@ -39,7 +44,7 @@ public class BeanWithExchangeExceptionAnnotationWrappedExceptionTest extends Bea
         // in the exception hieracy
         public void handleException(@ExchangeException MyCustomException custom) {
             assertNotNull(custom);
-            assertEquals("I'm being thrown!!", custom.getMessage());
+            assertEquals(MESSAGE, custom.getMessage());
         }
     }
 }


(camel) 01/04: (chores) camel-core: simplify collection call

Posted by or...@apache.org.
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 d4484664c91bf3f7ccbb522dcd753ac68e449eb3
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Thu Apr 11 17:23:14 2024 +0200

    (chores) camel-core: simplify collection call
---
 .../java/org/apache/camel/support/cache/SimpleSoftCacheTest.java    | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/core/camel-core/src/test/java/org/apache/camel/support/cache/SimpleSoftCacheTest.java b/core/camel-core/src/test/java/org/apache/camel/support/cache/SimpleSoftCacheTest.java
index 28c6822c549..b79c6cd2ba8 100644
--- a/core/camel-core/src/test/java/org/apache/camel/support/cache/SimpleSoftCacheTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/support/cache/SimpleSoftCacheTest.java
@@ -73,8 +73,7 @@ class SimpleSoftCacheTest {
         cache.put(1, "foo");
         cache.put(2, "bar");
 
-        Map<Integer, Object> tmp = new HashMap<>();
-        tmp.putAll(cache);
+        Map<Integer, Object> tmp = new HashMap<>(cache);
 
         assertEquals("foo", tmp.get(1));
         assertEquals("bar", tmp.get(2));
@@ -84,8 +83,7 @@ class SimpleSoftCacheTest {
 
         cache.getInnerCache().get(1).clear();
 
-        tmp = new HashMap<>();
-        tmp.putAll(cache);
+        tmp = new HashMap<>(cache);
 
         assertNull(tmp.get(1));
         assertEquals("bar", tmp.get(2));


(camel) 03/04: (chores) camel-core: modernized throw-based assertions

Posted by or...@apache.org.
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 0caedf5964722821eb307648cf559afe00b60c19
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Fri Apr 12 11:31:43 2024 +0200

    (chores) camel-core: modernized throw-based assertions
---
 .../apache/camel/ThreadPoolRejectedPolicyTest.java | 11 +++++-----
 .../apache/camel/model/RoutePropertiesTest.java    | 25 +++++++++++-----------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/core/camel-core/src/test/java/org/apache/camel/ThreadPoolRejectedPolicyTest.java b/core/camel-core/src/test/java/org/apache/camel/ThreadPoolRejectedPolicyTest.java
index c55178355a0..d43c206a0ed 100644
--- a/core/camel-core/src/test/java/org/apache/camel/ThreadPoolRejectedPolicyTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/ThreadPoolRejectedPolicyTest.java
@@ -28,6 +28,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.camel.util.concurrent.Rejectable;
 import org.apache.camel.util.concurrent.RejectableThreadPoolExecutor;
 import org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy;
+import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.*;
@@ -35,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.*;
 public class ThreadPoolRejectedPolicyTest extends TestSupport {
 
     @Test
-    public void testAbortAsRejectedExecutionHandler() throws InterruptedException {
+    public void testAbortAsRejectedExecutionHandler() {
 
         final ExecutorService executorService
                 = createTestExecutorService(ThreadPoolRejectedPolicy.Abort.asRejectedExecutionHandler());
@@ -45,11 +46,9 @@ public class ThreadPoolRejectedPolicyTest extends TestSupport {
         final MockRunnable task2 = new MockRunnable();
         final Future<?> result2 = executorService.submit(task2);
         final MockCallable<String> task3 = new MockCallable<>();
-        try {
-            executorService.submit(task3);
-            fail("Third task should have been rejected by a threadpool is full with 1 task and queue is full with 1 task.");
-        } catch (RejectedExecutionException e) {
-        }
+
+        Assertions.assertThrows(RejectedExecutionException.class, () -> executorService.submit(task3),
+                "Third task should have been rejected by a threadpool is full with 1 task and queue is full with 1 task.");
 
         shutdownAndAwait(executorService);
 
diff --git a/core/camel-core/src/test/java/org/apache/camel/model/RoutePropertiesTest.java b/core/camel-core/src/test/java/org/apache/camel/model/RoutePropertiesTest.java
index d5c989ad749..91eb9585463 100644
--- a/core/camel-core/src/test/java/org/apache/camel/model/RoutePropertiesTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/model/RoutePropertiesTest.java
@@ -17,8 +17,11 @@
 package org.apache.camel.model;
 
 import org.apache.camel.ContextTestSupport;
+import org.apache.camel.FailedToCreateRouteException;
 import org.apache.camel.Route;
 import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.*;
@@ -53,20 +56,18 @@ public class RoutePropertiesTest extends ContextTestSupport {
         assertEquals("val2", route.getProperties().get("key2"));
     }
 
+    @DisplayName("Checks that trying to use a reserved property leads to failure")
     @Test
-    public void testRoutePropertiesFailuer() throws Exception {
-        try {
-            context.addRoutes(new RouteBuilder() {
-                @Override
-                public void configure() throws Exception {
-                    from("direct:start").routeId("route-id").routeProperty(Route.ID_PROPERTY, "the id").to("mock:output");
-                }
-            });
+    public void testRoutePropertiesFailure() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:start").routeId("route-id").routeProperty(Route.ID_PROPERTY, "the id").to("mock:output");
+            }
+        });
 
-            context.start();
+        Assertions.assertThrows(FailedToCreateRouteException.class, () -> context.start(),
+                "Should have prevented setting a property with a reserved name");
 
-            fail("");
-        } catch (Exception e) {
-        }
     }
 }


(camel) 02/04: (chores) camel-core: simplify assertions

Posted by or...@apache.org.
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 090d0aa972bb2c984b30a3470dcc2334011db301
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Thu Apr 11 17:23:50 2024 +0200

    (chores) camel-core: simplify assertions
---
 .../java/org/apache/camel/management/ManagedStartupFailedTest.java    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/camel-management/src/test/java/org/apache/camel/management/ManagedStartupFailedTest.java b/core/camel-management/src/test/java/org/apache/camel/management/ManagedStartupFailedTest.java
index 5fa07041ffb..dd0a5793c09 100644
--- a/core/camel-management/src/test/java/org/apache/camel/management/ManagedStartupFailedTest.java
+++ b/core/camel-management/src/test/java/org/apache/camel/management/ManagedStartupFailedTest.java
@@ -29,8 +29,8 @@ import org.junit.jupiter.api.condition.DisabledOnOs;
 import org.junit.jupiter.api.condition.OS;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
 
 @DisabledOnOs(OS.AIX)
@@ -55,7 +55,7 @@ public class ManagedStartupFailedTest extends ManagementTestSupport {
         MBeanServer server = getMBeanServer();
         try {
             Set<ObjectName> onames = server.queryNames(new ObjectName("org.apache.camel:*"), null);
-            assertTrue(!onames.isEmpty());
+            assertFalse(onames.isEmpty());
 
             ProducerTemplate producer = context.createProducerTemplate();
             String result = producer.requestBody("direct:start", "Kermit", String.class);