Files
spring-boot-demo/resilience/src/test/java/com/ankurm/resilience/ApiSurfaceTest.java
T
asmhatreandClaude Opus 5 7e1676c763 Add resilience: Spring Framework 7 @Retryable and @ConcurrencyLimit
Companion code for "Spring Framework 7's Built-in Resilience: @Retryable,
@ConcurrencyLimit, and What's Left for Resilience4j". Every retry counted
by recording real invocations: defaults, backoff and jitter, timeout,
reactive and CompletableFuture returns, the concurrency limit's BLOCK and
REJECT policies, retries around transactions, composition with
Resilience4j 2.4.0, and the annotation API across 7.0.0-7.0.9.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01C3TETMrqVUWeFkNtz3Jbo3
2026-09-11 17:12:25 +00:00

35 lines
1.3 KiB
Java

package com.ankurm.resilience;
import java.util.Arrays;
import org.junit.jupiter.api.Test;
import org.springframework.resilience.annotation.ConcurrencyLimit;
import org.springframework.resilience.annotation.EnableResilientMethods;
import org.springframework.resilience.annotation.Retryable;
import static org.assertj.core.api.Assertions.assertThat;
/** Defaults the article quotes, read from the annotations rather than from the documentation. */
class ApiSurfaceTest {
@Test
void retryableDefaults() throws Exception {
assertThat(Retryable.class.getMethod("maxRetries").getDefaultValue()).isEqualTo(3L);
assertThat(Retryable.class.getMethod("delay").getDefaultValue()).isEqualTo(1000L);
assertThat(Retryable.class.getMethod("multiplier").getDefaultValue()).isEqualTo(1.0d);
assertThat(Retryable.class.getMethod("timeout").getDefaultValue()).isEqualTo(0L);
}
@Test
void concurrencyLimitHasTwoPolicies() {
assertThat(Arrays.stream(ConcurrencyLimit.ThrottlePolicy.values()).map(Enum::name))
.containsExactly("BLOCK", "REJECT");
}
@Test
void enableResilientMethodsOrderIsLowestMinusOne() throws Exception {
assertThat(EnableResilientMethods.class.getMethod("order").getDefaultValue()).isEqualTo(Integer.MAX_VALUE - 1);
}
}