@Test public void testIntegerBuilderOverride() { HystrixCommandProperties properties = new TestPropertiesCommand(TestKey.TEST, new HystrixCommandProperties.Setter().withMetricsRollingStatisticalWindowInMilliseconds(5000), "unitTestPrefix"); // the builder override should take precedence over the default assertEquals(5000, properties.metricsRollingStatisticalWindowInMilliseconds().get().intValue()); }
@Test public void testIntegerGlobalDynamicOverrideOfCodeDefault() throws Exception { HystrixCommandProperties properties = new TestPropertiesCommand(TestKey.TEST, new HystrixCommandProperties.Setter(), "unitTestPrefix"); ConfigurationManager.getConfigInstance().setProperty("unitTestPrefix.command.default.metrics.rollingStats.timeInMilliseconds", 1234); // the global dynamic property should take precedence over the default assertEquals(1234, properties.metricsRollingStatisticalWindowInMilliseconds().get().intValue()); // cleanup ConfigurationManager.getConfigInstance().clearProperty("unitTestPrefix.command.default.metrics.rollingStats.timeInMilliseconds"); }
@Test public void testIntegerInstanceBuilderOverrideOfGlobalDynamicOverride() throws Exception { HystrixCommandProperties properties = new TestPropertiesCommand(TestKey.TEST, new HystrixCommandProperties.Setter().withMetricsRollingStatisticalWindowInMilliseconds(5000), "unitTestPrefix"); ConfigurationManager.getConfigInstance().setProperty("unitTestPrefix.command.default.rollingStats.timeInMilliseconds", 3456); // the builder injected should take precedence over the global dynamic property assertEquals(5000, properties.metricsRollingStatisticalWindowInMilliseconds().get().intValue()); // cleanup ConfigurationManager.getConfigInstance().clearProperty("unitTestPrefix.command.default.rollingStats.timeInMilliseconds"); }
protected HystrixCommandProperties(HystrixCommandKey key) { this(key, new Setter(), "hystrix"); }
public EventCommand() { super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("eventGroup")).andCommandPropertiesDefaults(new HystrixCommandProperties.Setter().withFallbackIsolationSemaphoreMaxConcurrentRequests(3))); }
public TestCommand(boolean cacheEnabled, boolean logEnabled) { super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("TEST")).andCommandPropertiesDefaults(new HystrixCommandProperties.Setter().withRequestCacheEnabled(cacheEnabled).withRequestLogEnabled(logEnabled))); }
/** * Factory method to retrieve the default Setter. */ public static Setter Setter() { return new Setter(); }
@Test public void testBooleanInstanceBuilderOverrideOfGlobalDynamicOverride2() throws Exception { HystrixCommandProperties properties = new TestPropertiesCommand(TestKey.TEST, new HystrixCommandProperties.Setter().withCircuitBreakerForceClosed(false), "unitTestPrefix"); ConfigurationManager.getConfigInstance().setProperty("unitTestPrefix.command.default.circuitBreaker.forceClosed", true); // the builder injected should take precedence over the global dynamic property assertEquals(false, properties.circuitBreakerForceClosed().get()); // cleanup ConfigurationManager.getConfigInstance().clearProperty("unitTestPrefix.command.default.circuitBreaker.forceClosed"); }
@Test public void testBooleanGlobalDynamicOverrideOfCodeDefault() throws Exception { HystrixCommandProperties properties = new TestPropertiesCommand(TestKey.TEST, new HystrixCommandProperties.Setter(), "unitTestPrefix"); ConfigurationManager.getConfigInstance().setProperty("unitTestPrefix.command.default.circuitBreaker.forceClosed", true); // the global dynamic property should take precedence over the default assertEquals(true, properties.circuitBreakerForceClosed().get()); // cleanup ConfigurationManager.getConfigInstance().clearProperty("unitTestPrefix.command.default.circuitBreaker.forceClosed"); }
@Test public void testBooleanBuilderOverride2() { HystrixCommandProperties properties = new TestPropertiesCommand(TestKey.TEST, new HystrixCommandProperties.Setter().withCircuitBreakerForceClosed(false), "unitTestPrefix"); // the builder override should take precedence over the default assertEquals(false, properties.circuitBreakerForceClosed().get()); }
@Test public void testBooleanBuilderOverride1() { HystrixCommandProperties properties = new TestPropertiesCommand(TestKey.TEST, new HystrixCommandProperties.Setter().withCircuitBreakerForceClosed(true), "unitTestPrefix"); // the builder override should take precedence over the default assertEquals(true, properties.circuitBreakerForceClosed().get()); }
protected SynchronousObservableCommand() { super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("GROUP")) .andCommandKey(HystrixCommandKey.Factory.asKey("SyncObservable")) .andCommandPropertiesDefaults(new HystrixCommandProperties.Setter().withExecutionIsolationSemaphoreMaxConcurrentRequests(1000)) ); }
@Test public void testThreadPoolOnlyHasInstanceOverride() throws Exception { HystrixCommandProperties properties = new TestPropertiesCommand(TestKey.TEST, new HystrixCommandProperties.Setter(), "unitTestPrefix"); ConfigurationManager.getConfigInstance().setProperty("unitTestPrefix.command.default.threadPoolKeyOverride", 1234); // it should be null assertEquals(null, properties.executionIsolationThreadPoolKeyOverride().get()); ConfigurationManager.getConfigInstance().setProperty("unitTestPrefix.command.TEST.threadPoolKeyOverride", "testPool"); // now it should have a value assertEquals("testPool", properties.executionIsolationThreadPoolKeyOverride().get()); // cleanup ConfigurationManager.getConfigInstance().clearProperty("unitTestPrefix.command.default.threadPoolKeyOverride"); ConfigurationManager.getConfigInstance().clearProperty("unitTestPrefix.command.TEST.threadPoolKeyOverride"); }
@Test public void testBooleanInstanceDynamicOverrideOfEverything() throws Exception { HystrixCommandProperties properties = new TestPropertiesCommand(TestKey.TEST, new HystrixCommandProperties.Setter().withCircuitBreakerForceClosed(false), "unitTestPrefix"); ConfigurationManager.getConfigInstance().setProperty("unitTestPrefix.command.default.circuitBreaker.forceClosed", false); ConfigurationManager.getConfigInstance().setProperty("unitTestPrefix.command.TEST.circuitBreaker.forceClosed", true); // the instance specific dynamic property should take precedence over everything assertEquals(true, properties.circuitBreakerForceClosed().get()); // cleanup ConfigurationManager.getConfigInstance().clearProperty("unitTestPrefix.command.default.circuitBreaker.forceClosed"); ConfigurationManager.getConfigInstance().clearProperty("unitTestPrefix.command.TEST.circuitBreaker.forceClosed"); }
protected AsynchronousObservableCommand() { super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("GROUP")) .andCommandKey(HystrixCommandKey.Factory.asKey("AsyncObservable")) .andCommandPropertiesDefaults(new HystrixCommandProperties.Setter().withExecutionIsolationSemaphoreMaxConcurrentRequests(1000)) ); }
public TestCommand(String value, boolean fail, boolean failOnFallback, boolean timeout) { super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("RequestLogTestCommand")).andCommandPropertiesDefaults(new HystrixCommandProperties.Setter().withExecutionTimeoutInMilliseconds(500))); this.value = value; this.fail = fail; this.failOnFallback = failOnFallback; this.timeout = timeout; this.useFallback = false; this.useCache = false; }
@Test public void testIntegerCodeDefault() { HystrixCommandProperties properties = new TestPropertiesCommand(TestKey.TEST, new HystrixCommandProperties.Setter(), "unitTestPrefix"); assertEquals(HystrixCommandProperties.default_metricsRollingStatisticalWindow, properties.metricsRollingStatisticalWindowInMilliseconds().get()); }
@Test public void testBooleanInstanceBuilderOverrideOfGlobalDynamicOverride1() throws Exception { HystrixCommandProperties properties = new TestPropertiesCommand(TestKey.TEST, new HystrixCommandProperties.Setter().withCircuitBreakerForceClosed(true), "unitTestPrefix"); ConfigurationManager.getConfigInstance().setProperty("unitTestPrefix.command.default.circuitBreaker.forceClosed", false); // the builder injected should take precedence over the global dynamic property assertEquals(true, properties.circuitBreakerForceClosed().get()); // cleanup ConfigurationManager.getConfigInstance().clearProperty("unitTestPrefix.command.default.circuitBreaker.forceClosed"); }
@Test public void testBooleanCodeDefault() { HystrixCommandProperties properties = new TestPropertiesCommand(TestKey.TEST, new HystrixCommandProperties.Setter(), "unitTestPrefix"); assertEquals(HystrixCommandProperties.default_circuitBreakerForceClosed, properties.circuitBreakerForceClosed().get()); }
@Test public void testIntegerInstanceDynamicOverrideOfEverything() throws Exception { HystrixCommandProperties properties = new TestPropertiesCommand(TestKey.TEST, new HystrixCommandProperties.Setter().withMetricsRollingStatisticalWindowInMilliseconds(5000), "unitTestPrefix"); ConfigurationManager.getConfigInstance().setProperty("unitTestPrefix.command.default.metrics.rollingStats.timeInMilliseconds", 1234); ConfigurationManager.getConfigInstance().setProperty("unitTestPrefix.command.TEST.metrics.rollingStats.timeInMilliseconds", 3456); // the instance specific dynamic property should take precedence over everything assertEquals(3456, properties.metricsRollingStatisticalWindowInMilliseconds().get().intValue()); // cleanup ConfigurationManager.getConfigInstance().clearProperty("unitTestPrefix.command.default.metrics.rollingStats.timeInMilliseconds"); ConfigurationManager.getConfigInstance().clearProperty("unitTestPrefix.command.TEST.metrics.rollingStats.timeInMilliseconds"); }