You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/05/15 09:03:52 UTC

[camel] 07/11: CAMEL-13522: camel3 - The various Camel exceptions should favour extending runtime exception

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

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

commit 8ae96e7c45ed8a7487ffb6485505d8456ad0a4cc
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue May 14 13:42:33 2019 +0200

    CAMEL-13522: camel3 - The various Camel exceptions should favour extending runtime exception
---
 .../camel/component/bean/AmbiguousMethodCallException.java     |  5 ++---
 .../apache/camel/component/bean/MethodNotFoundException.java   |  5 ++---
 .../apache/camel/component/bean/ParameterBindingException.java |  1 -
 .../java/org/apache/camel/FailedToStartRouteException.java     |  8 ++++++++
 .../apache/camel/component/bean/BeanRefMethodNotFoundTest.java |  2 +-
 .../org/apache/camel/component/bean/BeanRefNotFoundTest.java   |  4 ++--
 .../component/bean/MethodCallBeanRefMethodNotFoundTest.java    |  4 ++--
 .../camel/component/bean/MethodCallBeanRefNotFoundTest.java    |  4 ++--
 .../directvm/DirectVmTwoCamelContextDuplicateConsumerTest.java |  2 +-
 .../seda/SameSedaQueueMultipleConsumersDifferenceTest.java     |  8 +++-----
 .../camel/impl/GracefulShutdownNoAutoStartOrderClashTest.java  |  2 +-
 .../apache/camel/impl/LifecycleStrategyFailOnStartupTest.java  |  2 +-
 .../org/apache/camel/impl/MultipleConsumersSupportTest.java    |  2 +-
 .../src/test/java/org/apache/camel/impl/RouteNoOutputTest.java |  4 ++--
 .../org/apache/camel/impl/engine/DefaultFactoryFinderTest.java |  2 +-
 .../apache/camel/processor/WeightedRandomLoadBalanceTest.java  |  3 ++-
 .../aggregator/AggregateUnknownExecutorServiceRefTest.java     |  2 +-
 .../onexception/OnExceptionHandledAndContinueTest.java         |  4 ++--
 .../processor/onexception/OnExceptionMisconfiguredTest.java    | 10 +++++-----
 19 files changed, 39 insertions(+), 35 deletions(-)

diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/AmbiguousMethodCallException.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/AmbiguousMethodCallException.java
index c99c2f4..94a20a3 100644
--- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/AmbiguousMethodCallException.java
+++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/AmbiguousMethodCallException.java
@@ -18,15 +18,14 @@ package org.apache.camel.component.bean;
 
 import java.util.Collection;
 
-import org.apache.camel.CamelExchangeException;
 import org.apache.camel.Exchange;
+import org.apache.camel.RuntimeExchangeException;
 
 /**
  * An exception thrown if an attempted method invocation resulted in an ambiguous method
  * such that multiple methods match the inbound message exchange
  */
-public class AmbiguousMethodCallException extends CamelExchangeException {
-    private static final long serialVersionUID = -8867010485101806951L;
+public class AmbiguousMethodCallException extends RuntimeExchangeException {
 
     private final Collection<MethodInfo> methods;
 
diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodNotFoundException.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodNotFoundException.java
index 1c7673c..c6a3aa6 100644
--- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodNotFoundException.java
+++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodNotFoundException.java
@@ -16,12 +16,11 @@
  */
 package org.apache.camel.component.bean;
 
-import org.apache.camel.CamelExchangeException;
 import org.apache.camel.Exchange;
+import org.apache.camel.RuntimeExchangeException;
 import org.apache.camel.util.ObjectHelper;
 
-public class MethodNotFoundException extends CamelExchangeException {
-    private static final long serialVersionUID = -7411465307141051012L;
+public class MethodNotFoundException extends RuntimeExchangeException {
 
     private final Object bean;
     private final String methodName;
diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/ParameterBindingException.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/ParameterBindingException.java
index 70f31bb..4ff9831 100644
--- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/ParameterBindingException.java
+++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/ParameterBindingException.java
@@ -23,7 +23,6 @@ import org.apache.camel.util.ObjectHelper;
 
 public class ParameterBindingException extends RuntimeCamelException {
 
-    private static final long serialVersionUID = 1L;
     private final Method method;
     private final int index;
     private final Class<?> parameterType;
diff --git a/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java b/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java
index 35f3fff..f3195d1 100644
--- a/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java
@@ -21,17 +21,25 @@ package org.apache.camel;
  */
 public class FailedToStartRouteException extends RuntimeCamelException {
 
+    private String routeId;
+
     public FailedToStartRouteException(String routeId, String message) {
         super("Failed to start route " + routeId + " because of " + message);
+        this.routeId = routeId;
     }
 
     public FailedToStartRouteException(String routeId, String message, Throwable cause) {
         super("Failed to start route " + routeId + " because of " + message, cause);
+        this.routeId = routeId;
     }
 
     public FailedToStartRouteException(Throwable cause) {
         super(cause);
     }
+
+    public String getRouteId() {
+        return routeId;
+    }
 }
 
 
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefMethodNotFoundTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefMethodNotFoundTest.java
index a1c40f96..f70a3cf 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefMethodNotFoundTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefMethodNotFoundTest.java
@@ -45,7 +45,7 @@ public class BeanRefMethodNotFoundTest extends ContextTestSupport {
             context.start();
             fail("Should have thrown exception");
         } catch (Exception e) {
-            FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+            FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e);
             assertEquals("b", failed.getRouteId());
             MethodNotFoundException cause = assertIsInstanceOf(MethodNotFoundException.class, e.getCause().getCause());
             assertEquals("bye", cause.getMethodName());
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefNotFoundTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefNotFoundTest.java
index da4c26d..414a019 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefNotFoundTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefNotFoundTest.java
@@ -46,9 +46,9 @@ public class BeanRefNotFoundTest extends ContextTestSupport {
             context.start();
             fail("Should have thrown exception");
         } catch (Exception e) {
-            FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+            FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e);
             assertEquals("b", failed.getRouteId());
-            NoSuchBeanException cause = assertIsInstanceOf(NoSuchBeanException.class, e.getCause().getCause());
+            NoSuchBeanException cause = assertIsInstanceOf(NoSuchBeanException.class, e.getCause());
             assertEquals("bar", cause.getName());
         }
     }
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefMethodNotFoundTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefMethodNotFoundTest.java
index 60b7042..d7b5fee 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefMethodNotFoundTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefMethodNotFoundTest.java
@@ -45,9 +45,9 @@ public class MethodCallBeanRefMethodNotFoundTest extends ContextTestSupport {
             context.start();
             fail("Should have thrown exception");
         } catch (Exception e) {
-            FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+            FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e);
             assertEquals("b", failed.getRouteId());
-            MethodNotFoundException cause = assertIsInstanceOf(MethodNotFoundException.class, e.getCause().getCause());
+            MethodNotFoundException cause = assertIsInstanceOf(MethodNotFoundException.class, e.getCause());
             assertEquals("bye", cause.getMethodName());
         }
     }
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefNotFoundTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefNotFoundTest.java
index cc2ef4a..4cd58ea 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefNotFoundTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefNotFoundTest.java
@@ -46,9 +46,9 @@ public class MethodCallBeanRefNotFoundTest extends ContextTestSupport {
             context.start();
             fail("Should have thrown exception");
         } catch (Exception e) {
-            FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+            FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e);
             assertEquals("b", failed.getRouteId());
-            NoSuchBeanException cause = assertIsInstanceOf(NoSuchBeanException.class, e.getCause().getCause());
+            NoSuchBeanException cause = assertIsInstanceOf(NoSuchBeanException.class, e.getCause());
             assertEquals("bar", cause.getName());
         }
     }
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmTwoCamelContextDuplicateConsumerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmTwoCamelContextDuplicateConsumerTest.java
index 1b37fe7..917d4af 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmTwoCamelContextDuplicateConsumerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmTwoCamelContextDuplicateConsumerTest.java
@@ -35,7 +35,7 @@ public class DirectVmTwoCamelContextDuplicateConsumerTest extends AbstractDirect
             third.start();
             fail("Should have thrown exception");
         } catch (Exception e) {
-            assertEquals("A consumer Consumer[direct-vm://foo] already exists from CamelContext: camel-1. Multiple consumers not supported", e.getCause().getMessage());
+            assertEquals("A consumer Consumer[direct-vm://foo] already exists from CamelContext: camel-1. Multiple consumers not supported", e.getMessage());
         }
 
         // stop first camel context then
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueMultipleConsumersDifferenceTest.java b/core/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueMultipleConsumersDifferenceTest.java
index dca1826..d036902 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueMultipleConsumersDifferenceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueMultipleConsumersDifferenceTest.java
@@ -18,12 +18,10 @@ package org.apache.camel.component.seda;
 
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.FailedToStartRouteException;
 import org.apache.camel.builder.RouteBuilder;
 import org.junit.Test;
 
-/**
- *
- */
 public class SameSedaQueueMultipleConsumersDifferenceTest extends ContextTestSupport {
 
     @Test
@@ -57,9 +55,9 @@ public class SameSedaQueueMultipleConsumersDifferenceTest extends ContextTestSup
             });
             fail("Should have thrown exception");
         } catch (Exception e) {
-            FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+            FailedToStartRouteException failed = assertIsInstanceOf(FailedToStartRouteException.class, e);
             assertEquals("fail", failed.getRouteId());
-            assertEquals("Cannot use existing queue seda://foo as the existing queue multiple consumers true does not match given multiple consumers false", e.getCause().getCause().getMessage());
+            assertEquals("Cannot use existing queue seda://foo as the existing queue multiple consumers true does not match given multiple consumers false", e.getCause().getMessage());
         }
     }
 
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/GracefulShutdownNoAutoStartOrderClashTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/GracefulShutdownNoAutoStartOrderClashTest.java
index 13ed47f..bbb8298 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/GracefulShutdownNoAutoStartOrderClashTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/GracefulShutdownNoAutoStartOrderClashTest.java
@@ -41,7 +41,7 @@ public class GracefulShutdownNoAutoStartOrderClashTest extends ContextTestSuppor
             fail("Should have thrown an exception");
         } catch (Exception e) {
             assertEquals("Failed to start route bar because of startupOrder clash. Route foo already has startupOrder 5 configured"
-                + " which this route have as well. Please correct startupOrder to be unique among all your routes.", e.getCause().getMessage());
+                + " which this route have as well. Please correct startupOrder to be unique among all your routes.", e.getMessage());
         }
     }
 
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyFailOnStartupTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyFailOnStartupTest.java
index 1c5d1f1..bdd6c4a 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyFailOnStartupTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyFailOnStartupTest.java
@@ -39,7 +39,7 @@ public class LifecycleStrategyFailOnStartupTest extends TestSupport {
             context.start();
             fail("Should have thrown exception");
         } catch (Exception e) {
-            assertEquals("Forced", e.getCause().getMessage());
+            assertEquals("Forced", e.getMessage());
         }
     }
 
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/MultipleConsumersSupportTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/MultipleConsumersSupportTest.java
index 8237e05..7eec9d1 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/MultipleConsumersSupportTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/MultipleConsumersSupportTest.java
@@ -53,7 +53,7 @@ public class MultipleConsumersSupportTest extends ContextTestSupport {
             context.start();
             fail("Should have thrown exception");
         } catch (Exception e) {
-            assertTrue(e.getCause().getMessage().endsWith("Multiple consumers for the same endpoint is not allowed: my:endpoint"));
+            assertTrue(e.getMessage().endsWith("Multiple consumers for the same endpoint is not allowed: my:endpoint"));
         }
     }
 
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/RouteNoOutputTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/RouteNoOutputTest.java
index 48d2eb1..f545e8e 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/RouteNoOutputTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/RouteNoOutputTest.java
@@ -30,9 +30,9 @@ public class RouteNoOutputTest extends ContextTestSupport {
             super.setUp();
             fail("Should have thrown exception");
         } catch (Exception e) {
-            FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+            FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e);
             assertEquals("route1", failed.getRouteId());
-            assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
+            assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
             assertEquals("Route route1 has no output processors. You need to add outputs to the route such as to(\"log:foo\").", e.getCause().getMessage());
         }
     }
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/engine/DefaultFactoryFinderTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/engine/DefaultFactoryFinderTest.java
index f26cf24..0389d2d 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/engine/DefaultFactoryFinderTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/engine/DefaultFactoryFinderTest.java
@@ -97,7 +97,7 @@ public class DefaultFactoryFinderTest {
             factoryFinder.newInstance("TestImplX");
             fail("NoFactoryAvailableException should have been thrown");
         } catch (final NoFactoryAvailableException e) {
-            assertEquals("Could not find factory class for resource: TestImplX", e.getMessage());
+            assertEquals("Cannot find factory class for resource: TestImplX", e.getMessage());
         }
     }
 
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRandomLoadBalanceTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRandomLoadBalanceTest.java
index 4d09486..5d4de65 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRandomLoadBalanceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRandomLoadBalanceTest.java
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 package org.apache.camel.processor;
+
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
@@ -124,7 +125,7 @@ public class WeightedRandomLoadBalanceTest extends ContextTestSupport {
             context.start();
             fail("Should have thrown exception");
         } catch (Exception e) {
-            IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+            IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
             assertEquals("Loadbalacing with 3 should match number of distributions 2", iae.getMessage());
         }
     }
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateUnknownExecutorServiceRefTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateUnknownExecutorServiceRefTest.java
index b9692e5..491a237 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateUnknownExecutorServiceRefTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateUnknownExecutorServiceRefTest.java
@@ -48,7 +48,7 @@ public class AggregateUnknownExecutorServiceRefTest extends ContextTestSupport {
             context.start();
             fail("Should have thrown exception");
         } catch (Exception e) {
-            IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
+            IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
             assertTrue(cause.getMessage().contains("myUnknownProfile"));
         }
     }
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledAndContinueTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledAndContinueTest.java
index 38c360c..3c1f8c2 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledAndContinueTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledAndContinueTest.java
@@ -45,8 +45,8 @@ public class OnExceptionHandledAndContinueTest extends ContextTestSupport {
             context.start();
             fail("Should thrown an exception");
         } catch (Exception e) {
-            assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
-            assertTrue(e.getCause().getCause().getMessage().startsWith("Only one of handled or continued is allowed to be configured"));
+            assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+            assertTrue(e.getCause().getMessage().startsWith("Only one of handled or continued is allowed to be configured"));
         }
     }
 
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java
index 6475f91..a56cab4 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java
@@ -48,7 +48,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
             context.start();
             fail("Should have thrown exception");
         } catch (Exception e) {
-            IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
+            IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
             assertEquals("OnException[[java.lang.Exception] -> []] is not configured.", iae.getMessage());
         }
     }
@@ -67,7 +67,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
             context.start();
             fail("Should have thrown exception");
         } catch (Exception e) {
-            IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
+            IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
             assertEquals("OnException[[java.lang.Exception] -> []] is not configured.", iae.getMessage());
         }
     }
@@ -87,7 +87,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
             context.start();
             fail("Should have thrown exception");
         } catch (Exception e) {
-            IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
+            IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
             assertEquals("OnException[[java.lang.Exception] -> []] is not configured.", iae.getMessage());
         }
     }
@@ -107,7 +107,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
             context.start();
             fail("Should have thrown exception");
         } catch (Exception e) {
-            IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
+            IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
             assertEquals("OnException[[java.lang.Exception] -> []] is not configured.", iae.getMessage());
         }
     }
@@ -128,7 +128,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
             context.start();
             fail("Should have thrown exception");
         } catch (Exception e) {
-            IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
+            IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
             assertTrue(iae.getMessage().startsWith("At least one exception must be configured"));
         }
     }