Minor changes after review
This commit is contained in:
parent
fa3581339c
commit
e4f2bed4fd
|
@ -10,8 +10,13 @@ public class HystrixController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SpringExistingClient client;
|
private SpringExistingClient client;
|
||||||
|
|
||||||
@RequestMapping("/")
|
@RequestMapping("/withHystrix")
|
||||||
public String index() throws InterruptedException{
|
public String withHystrix() throws InterruptedException{
|
||||||
return client.invokeRemoteService();
|
return client.invokeRemoteServiceWithHystrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/withOutHystrix")
|
||||||
|
public String withOutHystrix() throws InterruptedException{
|
||||||
|
return client.invokeRemoteServiceWithOutHystrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,11 @@ public class SpringExistingClient {
|
||||||
private int remoteServiceDelay;
|
private int remoteServiceDelay;
|
||||||
|
|
||||||
@HystrixCircuitBreaker
|
@HystrixCircuitBreaker
|
||||||
public String invokeRemoteService() throws InterruptedException{
|
public String invokeRemoteServiceWithHystrix() throws InterruptedException{
|
||||||
return new RemoteServiceTestSimulator(remoteServiceDelay).execute();
|
return new RemoteServiceTestSimulator(remoteServiceDelay).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String invokeRemoteServiceWithOutHystrix() throws InterruptedException{
|
||||||
|
return new RemoteServiceTestSimulator(remoteServiceDelay).execute();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,14 @@ public class SpringAndHystrixIntegrationTest {
|
||||||
public final ExpectedException exception = ExpectedException.none();
|
public final ExpectedException exception = ExpectedException.none();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenTimeOutOf15000_whenExistingClientCalled_thenExpectHystrixRuntimeException() throws InterruptedException {
|
public void givenTimeOutOf15000_whenClientCalledWithHystrix_thenExpectHystrixRuntimeException() throws InterruptedException {
|
||||||
exception.expect(HystrixRuntimeException.class);
|
exception.expect(HystrixRuntimeException.class);
|
||||||
assertThat(hystrixController.index(), equalTo("Success"));
|
hystrixController.withHystrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenTimeOutOf15000_whenClientCalledWithOutHystrix_thenExpectSuccess() throws InterruptedException {
|
||||||
|
assertThat(hystrixController.withOutHystrix(), equalTo("Success"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue