From e4f2bed4fd3b435b9e56894b86f6f4b145725e7d Mon Sep 17 00:00:00 2001 From: Alex Theedom Date: Tue, 16 Aug 2016 08:10:45 +0100 Subject: [PATCH] Minor changes after review --- .../java/com/baeldung/hystrix/HystrixController.java | 11 ++++++++--- .../com/baeldung/hystrix/SpringExistingClient.java | 5 ++++- .../hystrix/SpringAndHystrixIntegrationTest.java | 8 ++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/hystrix/src/main/java/com/baeldung/hystrix/HystrixController.java b/hystrix/src/main/java/com/baeldung/hystrix/HystrixController.java index a8ca0adef2..69d9e30ff8 100644 --- a/hystrix/src/main/java/com/baeldung/hystrix/HystrixController.java +++ b/hystrix/src/main/java/com/baeldung/hystrix/HystrixController.java @@ -10,8 +10,13 @@ public class HystrixController { @Autowired private SpringExistingClient client; - @RequestMapping("/") - public String index() throws InterruptedException{ - return client.invokeRemoteService(); + @RequestMapping("/withHystrix") + public String withHystrix() throws InterruptedException{ + return client.invokeRemoteServiceWithHystrix(); + } + + @RequestMapping("/withOutHystrix") + public String withOutHystrix() throws InterruptedException{ + return client.invokeRemoteServiceWithOutHystrix(); } } diff --git a/hystrix/src/main/java/com/baeldung/hystrix/SpringExistingClient.java b/hystrix/src/main/java/com/baeldung/hystrix/SpringExistingClient.java index fab8e611d4..525c7b4785 100644 --- a/hystrix/src/main/java/com/baeldung/hystrix/SpringExistingClient.java +++ b/hystrix/src/main/java/com/baeldung/hystrix/SpringExistingClient.java @@ -10,8 +10,11 @@ public class SpringExistingClient { private int remoteServiceDelay; @HystrixCircuitBreaker - public String invokeRemoteService() throws InterruptedException{ + public String invokeRemoteServiceWithHystrix() throws InterruptedException{ return new RemoteServiceTestSimulator(remoteServiceDelay).execute(); } + public String invokeRemoteServiceWithOutHystrix() throws InterruptedException{ + return new RemoteServiceTestSimulator(remoteServiceDelay).execute(); + } } diff --git a/hystrix/src/test/java/com/baeldung/hystrix/SpringAndHystrixIntegrationTest.java b/hystrix/src/test/java/com/baeldung/hystrix/SpringAndHystrixIntegrationTest.java index 8f443fc5a4..004314b0ed 100644 --- a/hystrix/src/test/java/com/baeldung/hystrix/SpringAndHystrixIntegrationTest.java +++ b/hystrix/src/test/java/com/baeldung/hystrix/SpringAndHystrixIntegrationTest.java @@ -23,10 +23,14 @@ public class SpringAndHystrixIntegrationTest { public final ExpectedException exception = ExpectedException.none(); @Test - public void givenTimeOutOf15000_whenExistingClientCalled_thenExpectHystrixRuntimeException() throws InterruptedException { + public void givenTimeOutOf15000_whenClientCalledWithHystrix_thenExpectHystrixRuntimeException() throws InterruptedException { exception.expect(HystrixRuntimeException.class); - assertThat(hystrixController.index(), equalTo("Success")); + hystrixController.withHystrix(); } + @Test + public void givenTimeOutOf15000_whenClientCalledWithOutHystrix_thenExpectSuccess() throws InterruptedException { + assertThat(hystrixController.withOutHystrix(), equalTo("Success")); + } }