Spring Cloud Quality Control & Assurance 3 — Questions and Answers
Question 1: Which Spring Cloud Contract annotation marks a method as a contract test that should be generated on the producer side?
- @AutoConfigureStubRunner (Correct answer)
- @ContractTest
- @SpringCloudContractVerifier
- @ContractVerifier
Correct answer: @AutoConfigureStubRunner
@AutoConfigureStubRunner is placed on the consumer test class to auto-configure the WireMock stub runner with the producer's published stubs.
Question 2: What does the resilience4j.circuitbreaker.instances.<name>.slidingWindowType=COUNT_BASED mean?
- Circuit breaker decisions are based on a fixed number of recent calls (Correct answer)
- Decisions are based on a time window in seconds
- Failures are counted since application startup
- The window slides by one call per second
Correct answer: Circuit breaker decisions are based on a fixed number of recent calls
COUNT_BASED means Resilience4j evaluates the last N calls (defined by slidingWindowSize) to decide whether to open the circuit.
Question 3: Which Spring Boot Actuator endpoint provides a live view of all active circuit breaker states?
- /actuator/circuitbreakers (Correct answer)
- /actuator/health/circuitBreaker
- /actuator/resilience4j
- /actuator/breakers/status
Correct answer: /actuator/circuitbreakers
The /actuator/circuitbreakers endpoint (provided by resilience4j-spring-boot2) lists all circuit breaker instances and their current states.
Question 4: Which WireMock feature enables simulating delayed responses to test timeout handling in Spring Cloud microservices?
- Fixed delay configuration on stub mappings (Correct answer)
- Thread sleep in test setup
- Spring @Async annotation on stub
- Chaos Monkey latency injection
Correct answer: Fixed delay configuration on stub mappings
WireMock stub mappings support a fixedDelayMilliseconds field that instructs the mock server to delay its response by the specified duration.
Question 5: In Spring Cloud Kubernetes, which resource is watched to detect and apply configuration changes without a pod restart?
- ConfigMap (Correct answer)
- Secret
- Deployment
- ServiceAccount
Correct answer: ConfigMap
Spring Cloud Kubernetes can watch ConfigMaps and automatically trigger a context refresh when the ConfigMap data changes.
Question 6: What is the key quality assurance benefit of using Spring Boot's @DataJpaTest slice annotation?
- It loads only JPA-related components, making repository tests fast and isolated (Correct answer)
- It tests the full application stack including web layer
- It mocks all JPA repositories automatically
- It rolls back all transactions after each test method
Correct answer: It loads only JPA-related components, making repository tests fast and isolated
@DataJpaTest limits the Spring context to JPA components only, reducing startup time and isolating repository logic from unrelated beans.
Question 7: Which Spring Cloud Gateway feature can be used to enforce rate limiting as a quality-of-service control?
- RequestRateLimiter filter with Redis backend (Correct answer)
- Hystrix filter with rate limit configuration
- Ribbon load balancer rate config
- Config Server rate-limit property
Correct answer: RequestRateLimiter filter with Redis backend
The RequestRateLimiter GatewayFilter uses a Redis-backed token bucket algorithm to limit request throughput per client.
Which Spring Cloud Contract annotation marks a method as a contract test that should be generated on the producer side?