Skip to content

Commit e4f2bed

Browse files
committed
Minor changes after review
1 parent fa35813 commit e4f2bed

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

hystrix/src/main/java/com/baeldung/hystrix/HystrixController.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ public class HystrixController {
1010
@Autowired
1111
private SpringExistingClient client;
1212

13-
@RequestMapping("/")
14-
public String index() throws InterruptedException{
15-
return client.invokeRemoteService();
13+
@RequestMapping("/withHystrix")
14+
public String withHystrix() throws InterruptedException{
15+
return client.invokeRemoteServiceWithHystrix();
16+
}
17+
18+
@RequestMapping("/withOutHystrix")
19+
public String withOutHystrix() throws InterruptedException{
20+
return client.invokeRemoteServiceWithOutHystrix();
1621
}
1722
}

hystrix/src/main/java/com/baeldung/hystrix/SpringExistingClient.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ public class SpringExistingClient {
1010
private int remoteServiceDelay;
1111

1212
@HystrixCircuitBreaker
13-
public String invokeRemoteService() throws InterruptedException{
13+
public String invokeRemoteServiceWithHystrix() throws InterruptedException{
1414
return new RemoteServiceTestSimulator(remoteServiceDelay).execute();
1515
}
1616

17+
public String invokeRemoteServiceWithOutHystrix() throws InterruptedException{
18+
return new RemoteServiceTestSimulator(remoteServiceDelay).execute();
19+
}
1720
}

hystrix/src/test/java/com/baeldung/hystrix/SpringAndHystrixIntegrationTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ public class SpringAndHystrixIntegrationTest {
2323
public final ExpectedException exception = ExpectedException.none();
2424

2525
@Test
26-
public void givenTimeOutOf15000_whenExistingClientCalled_thenExpectHystrixRuntimeException() throws InterruptedException {
26+
public void givenTimeOutOf15000_whenClientCalledWithHystrix_thenExpectHystrixRuntimeException() throws InterruptedException {
2727
exception.expect(HystrixRuntimeException.class);
28-
assertThat(hystrixController.index(), equalTo("Success"));
28+
hystrixController.withHystrix();
2929
}
3030

31+
@Test
32+
public void givenTimeOutOf15000_whenClientCalledWithOutHystrix_thenExpectSuccess() throws InterruptedException {
33+
assertThat(hystrixController.withOutHystrix(), equalTo("Success"));
34+
}
3135

3236
}

0 commit comments

Comments
 (0)