22
33import com .netflix .hystrix .HystrixInvokableInfo ;
44import com .netflix .hystrix .HystrixRequestLog ;
5+ import com .netflix .hystrix .HystrixThreadPoolProperties ;
56import com .netflix .hystrix .contrib .javanica .annotation .DefaultProperties ;
67import com .netflix .hystrix .contrib .javanica .annotation .HystrixCommand ;
8+ import com .netflix .hystrix .contrib .javanica .annotation .HystrixProperty ;
79import com .netflix .hystrix .contrib .javanica .test .common .BasicHystrixTest ;
810import org .junit .Before ;
911import org .junit .Test ;
1012
13+ import static com .netflix .hystrix .contrib .javanica .conf .HystrixPropertiesManager .EXECUTION_ISOLATION_THREAD_TIMEOUT_IN_MILLISECONDS ;
1114import static org .junit .Assert .assertEquals ;
1215
1316/**
@@ -26,7 +29,7 @@ public void setUp() throws Exception {
2629
2730 @ Test
2831 public void testCommandInheritsDefaultGroupKey () {
29- service .commandInheritsGroupKey ();
32+ service .commandInheritsDefaultProperties ();
3033 HystrixInvokableInfo <?> command = HystrixRequestLog .getCurrentRequest ()
3134 .getAllExecutedCommands ().iterator ().next ();
3235 assertEquals ("DefaultGroupKey" , command .getCommandGroup ().name ());
@@ -42,7 +45,7 @@ public void testCommandOverridesDefaultGroupKey() {
4245
4346 @ Test
4447 public void testCommandInheritsDefaultThreadPoolKey () {
45- service .commandInheritsThreadPoolKey ();
48+ service .commandInheritsDefaultProperties ();
4649 HystrixInvokableInfo <?> command = HystrixRequestLog .getCurrentRequest ()
4750 .getAllExecutedCommands ().iterator ().next ();
4851 assertEquals ("DefaultThreadPoolKey" , command .getThreadPoolKey ().name ());
@@ -56,11 +59,56 @@ public void testCommandOverridesDefaultThreadPoolKey() {
5659 assertEquals ("SpecificThreadPoolKey" , command .getThreadPoolKey ().name ());
5760 }
5861
59- @ DefaultProperties (groupKey = "DefaultGroupKey" , threadPoolKey = "DefaultThreadPoolKey" )
62+ @ Test
63+ public void testCommandInheritsDefaultCommandProperties () {
64+ service .commandInheritsDefaultProperties ();
65+ HystrixInvokableInfo <?> command = HystrixRequestLog .getCurrentRequest ()
66+ .getAllExecutedCommands ().iterator ().next ();
67+ assertEquals (456 , command .getProperties ().executionTimeoutInMilliseconds ().get ().intValue ());
68+ }
69+
70+ @ Test
71+ public void testCommandOverridesDefaultCommandProperties () {
72+ service .commandOverridesDefaultCommandProperties ();
73+ HystrixInvokableInfo <?> command = HystrixRequestLog .getCurrentRequest ()
74+ .getAllExecutedCommands ().iterator ().next ();
75+ assertEquals (654 , command .getProperties ().executionTimeoutInMilliseconds ().get ().intValue ());
76+ }
77+
78+ @ Test
79+ public void testCommandInheritsThreadPollProperties () {
80+ service .commandInheritsDefaultProperties ();
81+ HystrixInvokableInfo <?> command = HystrixRequestLog .getCurrentRequest ()
82+ .getAllExecutedCommands ().iterator ().next ();
83+
84+ HystrixThreadPoolProperties properties = getThreadPoolProperties (command );
85+
86+ assertEquals (123 , properties .maxQueueSize ().get ().intValue ());
87+ }
88+
89+ @ Test
90+ public void testCommandOverridesDefaultThreadPollProperties () {
91+ service .commandOverridesDefaultThreadPoolProperties ();
92+ HystrixInvokableInfo <?> command = HystrixRequestLog .getCurrentRequest ()
93+ .getAllExecutedCommands ().iterator ().next ();
94+
95+ HystrixThreadPoolProperties properties = getThreadPoolProperties (command );
96+
97+ assertEquals (321 , properties .maxQueueSize ().get ().intValue ());
98+ }
99+
100+ @ DefaultProperties (groupKey = "DefaultGroupKey" , threadPoolKey = "DefaultThreadPoolKey" ,
101+ commandProperties = {
102+ @ HystrixProperty (name = EXECUTION_ISOLATION_THREAD_TIMEOUT_IN_MILLISECONDS , value = "456" )
103+ },
104+ threadPoolProperties = {
105+ @ HystrixProperty (name = "maxQueueSize" , value = "123" )
106+ }
107+ )
60108 public static class Service {
61109
62110 @ HystrixCommand
63- public Object commandInheritsGroupKey () {
111+ public Object commandInheritsDefaultProperties () {
64112 return null ;
65113 }
66114
@@ -69,13 +117,22 @@ public Object commandOverridesGroupKey() {
69117 return null ;
70118 }
71119
72- @ HystrixCommand
73- public Object commandInheritsThreadPoolKey () {
120+ @ HystrixCommand ( threadPoolKey = "SpecificThreadPoolKey" )
121+ public Object commandOverridesThreadPoolKey () {
74122 return null ;
75123 }
76124
77- @ HystrixCommand (threadPoolKey = "SpecificThreadPoolKey" )
78- public Object commandOverridesThreadPoolKey () {
125+ @ HystrixCommand (commandProperties = {
126+ @ HystrixProperty (name = EXECUTION_ISOLATION_THREAD_TIMEOUT_IN_MILLISECONDS , value = "654" )
127+ })
128+ public Object commandOverridesDefaultCommandProperties () {
129+ return null ;
130+ }
131+
132+ @ HystrixCommand (threadPoolProperties = {
133+ @ HystrixProperty (name = "maxQueueSize" , value = "321" )
134+ })
135+ public Object commandOverridesDefaultThreadPoolProperties () {
79136 return null ;
80137 }
81138 }
0 commit comments