Exemplo n.º 1
0
 /** Utility method for creating {@link HystrixCommandMetrics} for unit tests. */
 private static HystrixCommandMetrics getMetrics(HystrixCommandProperties.Setter properties) {
   return HystrixCommandMetrics.getInstance(
       CommandKeyForUnitTest.KEY_ONE,
       CommandOwnerForUnitTest.OWNER_ONE,
       ThreadPoolKeyForUnitTest.THREAD_POOL_ONE,
       HystrixCommandPropertiesTest.asMock(properties));
 }
Exemplo n.º 2
0
 /** Utility method for creating {@link HystrixCircuitBreaker} for unit tests. */
 private static HystrixCircuitBreaker getCircuitBreaker(
     HystrixCommandKey key,
     HystrixCommandGroupKey commandGroup,
     HystrixCommandMetrics metrics,
     HystrixCommandProperties.Setter properties) {
   return new HystrixCircuitBreakerImpl(
       key, commandGroup, HystrixCommandPropertiesTest.asMock(properties), metrics);
 }
Exemplo n.º 3
0
 public Command(
     String commandKey,
     boolean shouldFail,
     boolean shouldFailWithBadRequest,
     long latencyToAdd,
     int sleepWindow,
     int requestVolumeThreshold) {
   super(
       Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("Command"))
           .andCommandKey(HystrixCommandKey.Factory.asKey(commandKey))
           .andCommandPropertiesDefaults(
               HystrixCommandPropertiesTest.getUnitTestPropertiesSetter()
                   .withExecutionTimeoutInMilliseconds(500)
                   .withCircuitBreakerRequestVolumeThreshold(requestVolumeThreshold)
                   .withCircuitBreakerSleepWindowInMilliseconds(sleepWindow)));
   this.shouldFail = shouldFail;
   this.shouldFailWithBadRequest = shouldFailWithBadRequest;
   this.latencyToAdd = latencyToAdd;
 }
Exemplo n.º 4
0
 public TestCircuitBreaker(HystrixCommandKey commandKey) {
   this.metrics =
       getMetrics(commandKey, HystrixCommandPropertiesTest.getUnitTestPropertiesSetter());
   forceShortCircuit = false;
 }