File tree Expand file tree Collapse file tree
main/java/com/baeldung/hystrix
test/java/com/baeldung/hystrix Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments