use of org.springframework.cloud.client.circuitbreaker.CircuitBreaker in project spring-cloud-alibaba by alibaba.
the class SentinelCircuitBreakerTest method testRunWithFallback.
@Test
public void testRunWithFallback() {
CircuitBreaker cb = new SentinelCircuitBreakerFactory().create("testSentinelRunWithFallback");
assertThat(cb.<String>run(() -> {
throw new RuntimeException("boom");
}, t -> "fallback")).isEqualTo("fallback");
}
use of org.springframework.cloud.client.circuitbreaker.CircuitBreaker in project spring-cloud-circuitbreaker by spring-cloud.
the class Resilience4JCircuitBreakerTest method run.
@Test
public void run() {
CircuitBreaker cb = new Resilience4JCircuitBreakerFactory(CircuitBreakerRegistry.ofDefaults(), TimeLimiterRegistry.ofDefaults(), null).create("foo");
assertThat(cb.run(() -> "foobar")).isEqualTo("foobar");
}
use of org.springframework.cloud.client.circuitbreaker.CircuitBreaker in project spring-cloud-circuitbreaker by spring-cloud.
the class Resilience4JCircuitBreakerTest method runWithGroupName.
@Test
public void runWithGroupName() {
CircuitBreaker cb = new Resilience4JCircuitBreakerFactory(CircuitBreakerRegistry.ofDefaults(), TimeLimiterRegistry.ofDefaults(), null).create("foo", "groupFoo");
assertThat(cb.run(() -> "foobar")).isEqualTo("foobar");
}
use of org.springframework.cloud.client.circuitbreaker.CircuitBreaker in project spring-cloud-circuitbreaker by spring-cloud.
the class Resilience4JCircuitBreakerTest method runWithFallbackBulkheadProviderAndGroupName.
@Test
public void runWithFallbackBulkheadProviderAndGroupName() {
CircuitBreaker cb = new Resilience4JCircuitBreakerFactory(CircuitBreakerRegistry.ofDefaults(), TimeLimiterRegistry.ofDefaults(), new Resilience4jBulkheadProvider(ThreadPoolBulkheadRegistry.ofDefaults(), BulkheadRegistry.ofDefaults())).create("foo", "groupFoo");
assertThat((String) cb.run(() -> {
throw new RuntimeException("boom");
}, t -> "fallback")).isEqualTo("fallback");
}
use of org.springframework.cloud.client.circuitbreaker.CircuitBreaker in project spring-cloud-circuitbreaker by spring-cloud.
the class Resilience4JCircuitBreakerTest method runWithBulkheadProvider.
@Test
public void runWithBulkheadProvider() {
CircuitBreaker cb = new Resilience4JCircuitBreakerFactory(CircuitBreakerRegistry.ofDefaults(), TimeLimiterRegistry.ofDefaults(), new Resilience4jBulkheadProvider(ThreadPoolBulkheadRegistry.ofDefaults(), BulkheadRegistry.ofDefaults())).create("foo");
assertThat(cb.run(() -> "foobar")).isEqualTo("foobar");
}
Aggregations