File tree Expand file tree Collapse file tree
hystrix/src/test/java/com/baeldung/hystrix Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .baeldung .hystrix ;
2+
3+ import com .netflix .hystrix .HystrixCommand ;
4+ import com .netflix .hystrix .HystrixCommandGroupKey ;
5+
6+ class CommandHelloWorld extends HystrixCommand <String > {
7+
8+ private final String name ;
9+
10+ CommandHelloWorld (String name ) {
11+ super (HystrixCommandGroupKey .Factory .asKey ("ExampleGroup" ));
12+ this .name = name ;
13+ }
14+
15+ @ Override
16+ protected String run () {
17+ return "Hello " + name + "!" ;
18+ }
19+ }
Original file line number Diff line number Diff line change 11package com .baeldung .hystrix ;
22
33import com .netflix .hystrix .*;
4+ import com .netflix .hystrix .collapser .RequestCollapserFactory ;
45import com .netflix .hystrix .exception .HystrixRuntimeException ;
56import org .junit .After ;
67import org .junit .Before ;
@@ -23,8 +24,13 @@ public class HystrixTimeoutTest {
2324 @ Before
2425 public void setup () {
2526 config = HystrixCommand
26- .Setter
27- .withGroupKey (HystrixCommandGroupKey .Factory .asKey ("RemoteServiceGroup1" ));
27+ .Setter
28+ .withGroupKey (HystrixCommandGroupKey .Factory .asKey ("RemoteServiceGroup1" ));
29+ }
30+
31+ @ Test
32+ public void givenInputBob_andDefaultSettings_thenReturnHelloBob (){
33+ assertThat (new CommandHelloWorld ("Bob" ).execute (), equalTo ("Hello Bob!" ));
2834 }
2935
3036 @ Test
@@ -36,7 +42,6 @@ public void givenTimeoutEqualTo100_andDefaultSettings_thenReturnSuccess() throws
3642 public void givenTimeoutEqualTo10000_andDefaultSettings_thenExpectHystrixRuntimeException () throws InterruptedException {
3743 exception .expect (HystrixRuntimeException .class );
3844 new RemoteServiceTestCommand (config , new RemoteServiceTestSimulator (10_000 )).execute ();
39-
4045 }
4146
4247 @ Test
@@ -54,5 +59,4 @@ public void givenTimeoutEqualTo15000_andExecutionTimeoutEqualTo10000_thenExpectH
5459 new RemoteServiceTestCommand (config , new RemoteServiceTestSimulator (15_000 )).execute ();
5560 }
5661
57-
5862}
You can’t perform that action at this time.
0 commit comments