From 34ea6a532a00d9f7b0ea88ee0502caa43049c2a9 Mon Sep 17 00:00:00 2001 From: Emily Jiang Date: Wed, 7 Mar 2018 13:29:29 +0000 Subject: [PATCH] #224 support the exception retrival Signed-off-by: Emily Jiang --- .../microprofile/faulttolerance/ExecutionContext.java | 6 ++++++ .../microprofile/fault/tolerance/tck/FallbackTest.java | 3 +++ .../fallback/clientserver/SecondStringFallbackHandler.java | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/org/eclipse/microprofile/faulttolerance/ExecutionContext.java b/api/src/main/java/org/eclipse/microprofile/faulttolerance/ExecutionContext.java index e23365bf..faca2370 100644 --- a/api/src/main/java/org/eclipse/microprofile/faulttolerance/ExecutionContext.java +++ b/api/src/main/java/org/eclipse/microprofile/faulttolerance/ExecutionContext.java @@ -43,5 +43,11 @@ public interface ExecutionContext { * */ public Object[] getParameters(); + + /** + * Returns the failure of the method execution + * @return the failure of the method execution + */ + public Throwable getFailure(); } diff --git a/tck/src/main/java/org/eclipse/microprofile/fault/tolerance/tck/FallbackTest.java b/tck/src/main/java/org/eclipse/microprofile/fault/tolerance/tck/FallbackTest.java index a1b65f71..88bf290d 100644 --- a/tck/src/main/java/org/eclipse/microprofile/fault/tolerance/tck/FallbackTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/fault/tolerance/tck/FallbackTest.java @@ -152,6 +152,9 @@ public void testClassLevelFallbackSuccess() { String result = fallbackClassLevelClient.serviceB(); Assert.assertTrue(result.contains("second fallback for serviceB"), "The message should be \"second fallback for serviceB\""); + Assert.assertTrue(result.contains(RuntimeException.class.getName()), + "The message should be " + RuntimeException.class.getName()); + } catch (RuntimeException ex) { Assert.fail("serviceB should not throw a RuntimeException in testFallbackSuccess"); diff --git a/tck/src/main/java/org/eclipse/microprofile/fault/tolerance/tck/fallback/clientserver/SecondStringFallbackHandler.java b/tck/src/main/java/org/eclipse/microprofile/fault/tolerance/tck/fallback/clientserver/SecondStringFallbackHandler.java index b78da31d..88296b27 100644 --- a/tck/src/main/java/org/eclipse/microprofile/fault/tolerance/tck/fallback/clientserver/SecondStringFallbackHandler.java +++ b/tck/src/main/java/org/eclipse/microprofile/fault/tolerance/tck/fallback/clientserver/SecondStringFallbackHandler.java @@ -36,7 +36,7 @@ public class SecondStringFallbackHandler implements FallbackHandler { @Override public String handle(ExecutionContext context) { - return "second fallback for " + context.getMethod().getName(); + return "second fallback for " + context.getMethod().getName() + context.getFailure().getClass().getName(); } }