use of com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy in project Hystrix by Netflix.
the class HystrixCommandTestWithCustomConcurrencyStrategy method testCommandDoesNotRequireContextConcurrencyStrategyProvidesItContextLeftUninitialized.
/**
* HystrixConcurrencyStrategy
** useDefaultRequestContext : true
* HystrixCommand
** useRequestCache : false
** useRequestLog : false
*
* OUTCOME: RequestLog not set up in command, static access is null
*/
@Test
public void testCommandDoesNotRequireContextConcurrencyStrategyProvidesItContextLeftUninitialized() {
HystrixConcurrencyStrategy strategy = new CustomConcurrencyStrategy(true);
HystrixPlugins.getInstance().registerConcurrencyStrategy(strategy);
//context is not set up
HystrixRequestContext.setContextOnCurrentThread(null);
HystrixCommand<Boolean> cmd = new TestCommand(false, false);
//command execution not affected by missing context
assertTrue(cmd.execute());
printRequestLog();
assertNull(HystrixRequestLog.getCurrentRequest());
assertNull(HystrixRequestLog.getCurrentRequest(strategy));
assertNull(cmd.currentRequestLog);
}
use of com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy in project Hystrix by Netflix.
the class HystrixCommandTestWithCustomConcurrencyStrategy method testCommandRequiresContextConcurrencyStrategyDoesNotProvideItContextLeftUninitialized.
/**
* HystrixConcurrencyStrategy
** useDefaultRequestContext : false
* HystrixCommand
** useRequestCache : true
** useRequestLog : true
*
* OUTCOME: RequestLog not set up in command, not available statically
*/
@Test
public void testCommandRequiresContextConcurrencyStrategyDoesNotProvideItContextLeftUninitialized() {
HystrixConcurrencyStrategy strategy = new CustomConcurrencyStrategy(false);
HystrixPlugins.getInstance().registerConcurrencyStrategy(strategy);
//context is not set up
HystrixRequestContext.setContextOnCurrentThread(null);
HystrixCommand<Boolean> cmd = new TestCommand(true, true);
//command execution not affected by missing context
assertTrue(cmd.execute());
printRequestLog();
assertNull(HystrixRequestLog.getCurrentRequest());
assertNull(HystrixRequestLog.getCurrentRequest(strategy));
assertNull(cmd.currentRequestLog);
}
use of com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy in project Hystrix by Netflix.
the class HystrixCommandTestWithCustomConcurrencyStrategy method testCommandRequiresContextConcurrencyStrategyDoesNotProvideItContextSetUpCorrectly.
/**
* HystrixConcurrencyStrategy
** useDefaultRequestContext : false
* HystrixCommand
** useRequestCache : true
** useRequestLog : true
*
* OUTCOME: RequestLog not set up in command, not available statically
*/
@Test
public void testCommandRequiresContextConcurrencyStrategyDoesNotProvideItContextSetUpCorrectly() {
HystrixConcurrencyStrategy strategy = new CustomConcurrencyStrategy(false);
HystrixPlugins.getInstance().registerConcurrencyStrategy(strategy);
//context is set up properly
HystrixRequestContext context = HystrixRequestContext.initializeContext();
HystrixCommand<Boolean> cmd = new TestCommand(true, true);
assertTrue(cmd.execute());
printRequestLog();
assertNull(HystrixRequestLog.getCurrentRequest());
assertNull(HystrixRequestLog.getCurrentRequest(strategy));
assertNull(cmd.currentRequestLog);
context.shutdown();
}
use of com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy in project Hystrix by Netflix.
the class HystrixCommandTestWithCustomConcurrencyStrategy method testCommandDoesNotRequireContextConcurrencyStrategyDoesNotProvideItContextLeftUninitialized.
/**
* HystrixConcurrencyStrategy
** useDefaultRequestContext : false
* HystrixCommand
** useRequestCache : false
** useRequestLog : false
*
* OUTCOME: RequestLog not set up in command, not available statically
*/
@Test
public void testCommandDoesNotRequireContextConcurrencyStrategyDoesNotProvideItContextLeftUninitialized() {
HystrixConcurrencyStrategy strategy = new CustomConcurrencyStrategy(false);
HystrixPlugins.getInstance().registerConcurrencyStrategy(strategy);
//context is not set up
HystrixRequestContext.setContextOnCurrentThread(null);
HystrixCommand<Boolean> cmd = new TestCommand(true, true);
//command execution unaffected by missing context
assertTrue(cmd.execute());
printRequestLog();
assertNull(HystrixRequestLog.getCurrentRequest());
assertNull(HystrixRequestLog.getCurrentRequest(strategy));
assertNull(cmd.currentRequestLog);
}
use of com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy in project Hystrix by Netflix.
the class HystrixCommandTestWithCustomConcurrencyStrategy method testCommandRequiresContextConcurrencyStrategyProvidesItContextLeftUninitialized.
/**
* HystrixConcurrencyStrategy
** useDefaultRequestContext : true
* HystrixCommand
** useRequestCache : true
** useRequestLog : true
*
* OUTCOME: RequestLog not set up properly in command, static access is null
*/
@Test
public void testCommandRequiresContextConcurrencyStrategyProvidesItContextLeftUninitialized() {
HystrixConcurrencyStrategy strategy = new CustomConcurrencyStrategy(true);
HystrixPlugins.getInstance().registerConcurrencyStrategy(strategy);
//context is not set up
HystrixRequestContext.setContextOnCurrentThread(null);
HystrixCommand<Boolean> cmd = new TestCommand(true, true);
//command execution not affected by missing context
assertTrue(cmd.execute());
printRequestLog();
assertNull(HystrixRequestLog.getCurrentRequest());
assertNull(HystrixRequestLog.getCurrentRequest(strategy));
assertNull(cmd.currentRequestLog);
}
Aggregations