[TOMEE-2291] - Fault Tolerance Microprofile example for @Retry Added missed test for statusOfMonth Changed the return message of statusOfMonth from weekend to month
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/bde89d72 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/bde89d72 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/bde89d72 Branch: refs/heads/master Commit: bde89d72ea282652034d4b602b6bce6eadd366fb Parents: 9bb8a1a Author: josehenriqueventura <J2705hvq*> Authored: Mon Dec 3 20:17:12 2018 +0000 Committer: josehenriqueventura <J2705hvq*> Committed: Mon Dec 3 20:17:12 2018 +0000 ---------------------------------------------------------------------- .../src/main/java/org/superbiz/rest/WeatherGateway.java | 4 ++-- .../src/test/java/org/superbiz/rest/WeatherServiceTest.java | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/bde89d72/examples/mp-faulttolerance-retry/src/main/java/org/superbiz/rest/WeatherGateway.java ---------------------------------------------------------------------- diff --git a/examples/mp-faulttolerance-retry/src/main/java/org/superbiz/rest/WeatherGateway.java b/examples/mp-faulttolerance-retry/src/main/java/org/superbiz/rest/WeatherGateway.java index 110113a..e2cf413 100644 --- a/examples/mp-faulttolerance-retry/src/main/java/org/superbiz/rest/WeatherGateway.java +++ b/examples/mp-faulttolerance-retry/src/main/java/org/superbiz/rest/WeatherGateway.java @@ -73,7 +73,7 @@ public class WeatherGateway { LOGGER.log(Level.SEVERE, String.format(FORECAST_BUSY_MESSAGE, counterStatusOfWeek.get())); throw new WeatherGatewayBusyServiceException(); } - + @Retry(retryOn = WeatherGatewayTimeoutException.class, maxRetries = 5, delay = 500, jitter = 0) public String statusOfWeekend() { if (counterStatusOfWeekend.addAndGet(1) <= 5) { @@ -91,7 +91,7 @@ public class WeatherGateway { statusOfMonthInstant = Instant.now(); throw new WeatherGatewayTimeoutException(); } - return "The Forecast for the Weekend is Scattered Showers."; + return "The Forecast for the Month is sunny most of the days"; } @Retry(retryOn = WeatherGatewayTimeoutException.class, maxRetries = 5, delay = 500, jitter = 500, maxDuration = 1000) http://git-wip-us.apache.org/repos/asf/tomee/blob/bde89d72/examples/mp-faulttolerance-retry/src/test/java/org/superbiz/rest/WeatherServiceTest.java ---------------------------------------------------------------------- diff --git a/examples/mp-faulttolerance-retry/src/test/java/org/superbiz/rest/WeatherServiceTest.java b/examples/mp-faulttolerance-retry/src/test/java/org/superbiz/rest/WeatherServiceTest.java index 4f43926..96fab3d 100644 --- a/examples/mp-faulttolerance-retry/src/test/java/org/superbiz/rest/WeatherServiceTest.java +++ b/examples/mp-faulttolerance-retry/src/test/java/org/superbiz/rest/WeatherServiceTest.java @@ -74,6 +74,13 @@ public class WeatherServiceTest { } @Test + public void testStatusOfMonth() { + WebTarget webTarget = this.client.target(this.base.toExternalForm()); + Response response = webTarget.path("/weather/month/status").request().get(); + assertEquals("The Forecast for the Month is sunny most of the days", response.readEntity(String.class)); + } + + @Test public void testStatusOfYear() { WebTarget webTarget = this.client.target(this.base.toExternalForm()); Response response = webTarget.path("/weather/year/status").request().get();