1010import static org .hamcrest .MatcherAssert .assertThat ;
1111import static org .hamcrest .Matchers .equalTo ;
1212
13- public class HystrixTimeoutIntegrationTest {
13+ public class HystrixTimeoutManualTest {
1414
1515 @ Test
16- public void givenInputBobAndDefaultSettings_whenCommandExecuted_thenReturnHelloBob (){
16+ public void givenInputBobAndDefaultSettings_whenCommandExecuted_thenReturnHelloBob () {
1717 assertThat (new CommandHelloWorld ("Bob" ).execute (), equalTo ("Hello Bob!" ));
1818 }
1919
2020 @ Test
2121 public void givenSvcTimeoutOf100AndDefaultSettings_whenRemoteSvcExecuted_thenReturnSuccess ()
22- throws InterruptedException {
22+ throws InterruptedException {
2323 HystrixCommand .Setter config = HystrixCommand
24- .Setter
25- .withGroupKey (HystrixCommandGroupKey .Factory .asKey ("RemoteServiceGroup2" ));
24+ .Setter
25+ .withGroupKey (HystrixCommandGroupKey .Factory .asKey ("RemoteServiceGroup2" ));
2626
2727 assertThat (new RemoteServiceTestCommand (config , new RemoteServiceTestSimulator (100 )).execute (),
28- equalTo ("Success" ));
28+ equalTo ("Success" ));
2929 }
3030
3131 @ Test (expected = HystrixRuntimeException .class )
3232 public void givenSvcTimeoutOf10000AndDefaultSettings__whenRemoteSvcExecuted_thenExpectHRE () throws InterruptedException {
3333 HystrixCommand .Setter config = HystrixCommand
34- .Setter
35- .withGroupKey (HystrixCommandGroupKey .Factory .asKey ("RemoteServiceGroupTest3" ));
34+ .Setter
35+ .withGroupKey (HystrixCommandGroupKey .Factory .asKey ("RemoteServiceGroupTest3" ));
3636 new RemoteServiceTestCommand (config , new RemoteServiceTestSimulator (10_000 )).execute ();
3737 }
3838
3939 @ Test
4040 public void givenSvcTimeoutOf5000AndExecTimeoutOf10000_whenRemoteSvcExecuted_thenReturnSuccess ()
41- throws InterruptedException {
41+ throws InterruptedException {
4242
4343 HystrixCommand .Setter config = HystrixCommand
44- .Setter
45- .withGroupKey (HystrixCommandGroupKey .Factory .asKey ("RemoteServiceGroupTest4" ));
44+ .Setter
45+ .withGroupKey (HystrixCommandGroupKey .Factory .asKey ("RemoteServiceGroupTest4" ));
4646 HystrixCommandProperties .Setter commandProperties = HystrixCommandProperties .Setter ();
4747 commandProperties .withExecutionTimeoutInMilliseconds (10_000 );
4848 config .andCommandPropertiesDefaults (commandProperties );
4949
5050 assertThat (new RemoteServiceTestCommand (config , new RemoteServiceTestSimulator (500 )).execute (),
51- equalTo ("Success" ));
51+ equalTo ("Success" ));
5252 }
5353
5454 @ Test (expected = HystrixRuntimeException .class )
5555 public void givenSvcTimeoutOf15000AndExecTimeoutOf5000__whenExecuted_thenExpectHRE ()
56- throws InterruptedException {
56+ throws InterruptedException {
5757 HystrixCommand .Setter config = HystrixCommand
58- .Setter
59- .withGroupKey (HystrixCommandGroupKey .Factory .asKey ("RemoteServiceGroupTest5" ));
58+ .Setter
59+ .withGroupKey (HystrixCommandGroupKey .Factory .asKey ("RemoteServiceGroupTest5" ));
6060 HystrixCommandProperties .Setter commandProperties = HystrixCommandProperties .Setter ();
6161 commandProperties .withExecutionTimeoutInMilliseconds (5_000 );
6262 config .andCommandPropertiesDefaults (commandProperties );
@@ -65,65 +65,65 @@ public void givenSvcTimeoutOf15000AndExecTimeoutOf5000__whenExecuted_thenExpectH
6565
6666 @ Test
6767 public void givenSvcTimeoutOf500AndExecTimeoutOf10000AndThreadPool__whenExecuted_thenReturnSuccess ()
68- throws InterruptedException {
68+ throws InterruptedException {
6969
7070 HystrixCommand .Setter config = HystrixCommand
71- .Setter
72- .withGroupKey (HystrixCommandGroupKey .Factory .asKey ("RemoteServiceGroupThreadPool" ));
71+ .Setter
72+ .withGroupKey (HystrixCommandGroupKey .Factory .asKey ("RemoteServiceGroupThreadPool" ));
7373 HystrixCommandProperties .Setter commandProperties = HystrixCommandProperties .Setter ();
7474 commandProperties .withExecutionTimeoutInMilliseconds (10_000 );
7575 config .andCommandPropertiesDefaults (commandProperties );
7676 config .andThreadPoolPropertiesDefaults (HystrixThreadPoolProperties .Setter ()
77- .withMaxQueueSize (10 )
78- .withCoreSize (3 )
79- .withQueueSizeRejectionThreshold (10 ));
77+ .withMaxQueueSize (10 )
78+ .withCoreSize (3 )
79+ .withQueueSizeRejectionThreshold (10 ));
8080
8181 assertThat (new RemoteServiceTestCommand (config , new RemoteServiceTestSimulator (500 )).execute (),
82- equalTo ("Success" ));
82+ equalTo ("Success" ));
8383 }
8484
8585 @ Test
8686 public void givenCircuitBreakerSetup__whenRemoteSvcCmdExecuted_thenReturnSuccess ()
87- throws InterruptedException {
87+ throws InterruptedException {
8888
8989 HystrixCommand .Setter config = HystrixCommand
90- .Setter
91- .withGroupKey (HystrixCommandGroupKey .Factory .asKey ("RemoteServiceGroupCircuitBreaker" ));
90+ .Setter
91+ .withGroupKey (HystrixCommandGroupKey .Factory .asKey ("RemoteServiceGroupCircuitBreaker" ));
9292 HystrixCommandProperties .Setter properties = HystrixCommandProperties .Setter ();
9393 properties .withExecutionTimeoutInMilliseconds (1000 );
9494
9595 properties .withCircuitBreakerSleepWindowInMilliseconds (4000 );
9696 properties .withExecutionIsolationStrategy (
97- HystrixCommandProperties .ExecutionIsolationStrategy .THREAD );
97+ HystrixCommandProperties .ExecutionIsolationStrategy .THREAD );
9898 properties .withCircuitBreakerEnabled (true );
9999 properties .withCircuitBreakerRequestVolumeThreshold (1 );
100100
101101 config .andCommandPropertiesDefaults (properties );
102102
103103 config .andThreadPoolPropertiesDefaults (HystrixThreadPoolProperties .Setter ()
104- .withMaxQueueSize (1 )
105- .withCoreSize (1 )
106- .withQueueSizeRejectionThreshold (1 ));
104+ .withMaxQueueSize (1 )
105+ .withCoreSize (1 )
106+ .withQueueSizeRejectionThreshold (1 ));
107107
108108 assertThat (this .invokeRemoteService (config , 10_000 ), equalTo (null ));
109109 assertThat (this .invokeRemoteService (config , 10_000 ), equalTo (null ));
110110 assertThat (this .invokeRemoteService (config , 10_000 ), equalTo (null ));
111111 Thread .sleep (5000 );
112112
113113 assertThat (new RemoteServiceTestCommand (config , new RemoteServiceTestSimulator (500 )).execute (),
114- equalTo ("Success" ));
114+ equalTo ("Success" ));
115115 assertThat (new RemoteServiceTestCommand (config , new RemoteServiceTestSimulator (500 )).execute (),
116- equalTo ("Success" ));
116+ equalTo ("Success" ));
117117 assertThat (new RemoteServiceTestCommand (config , new RemoteServiceTestSimulator (500 )).execute (),
118- equalTo ("Success" ));
118+ equalTo ("Success" ));
119119 }
120120
121121 public String invokeRemoteService (HystrixCommand .Setter config , int timeout )
122- throws InterruptedException {
122+ throws InterruptedException {
123123 String response = null ;
124124 try {
125125 response = new RemoteServiceTestCommand (config ,
126- new RemoteServiceTestSimulator (timeout )).execute ();
126+ new RemoteServiceTestSimulator (timeout )).execute ();
127127 } catch (HystrixRuntimeException ex ) {
128128 System .out .println ("ex = " + ex );
129129 }
0 commit comments