Spring Cloud Quality Control & Assurance 2 — Questions and Answers
Question 1: Which Spring Cloud Contract feature allows a consumer team to define a contract before the producer API is implemented?
- Consumer-Driven Contract (CDC) (Correct answer)
- Producer-Driven Contract (PDC)
- API Gateway Contract
- Service Mesh Contract
Correct answer: Consumer-Driven Contract (CDC)
Consumer-Driven Contracts let the consumer team write the contract stub first, enabling parallel development before the producer is ready.
Question 2: What does Spring Cloud Sleuth use to correlate log entries across multiple microservices?
- Trace ID and Span ID (Correct answer)
- Session ID and Request ID
- Correlation Header and Service ID
- MDC Key and Thread ID
Correct answer: Trace ID and Span ID
Sleuth propagates a Trace ID (for the full request chain) and Span ID (for individual service hops) through HTTP headers and messaging.
Question 3: In Spring Cloud Gateway, which filter type executes BEFORE the proxied request is sent to the downstream service?
- Pre filter (Correct answer)
- Post filter
- Global filter
- Route filter
Correct answer: Pre filter
Pre filters run before the request is forwarded, making them ideal for authentication, rate-limiting, and header manipulation.
Question 4: When using Spring Cloud Bus to broadcast configuration changes, which message broker is commonly used?
- RabbitMQ or Apache Kafka (Correct answer)
- ActiveMQ or IBM MQ
- Redis Pub/Sub or ZeroMQ
- NATS or Pulsar
Correct answer: RabbitMQ or Apache Kafka
Spring Cloud Bus officially supports RabbitMQ and Kafka as message brokers for propagating configuration refresh events.
Question 5: Which assertion library is recommended for writing readable Spring Boot integration test assertions?
- AssertJ (Correct answer)
- Hamcrest
- Truth
- JUnit assertions
Correct answer: AssertJ
AssertJ provides a fluent, IDE-friendly API and is the preferred assertion library in Spring Boot's own test documentation.
Question 6: What is the purpose of @AutoConfigureMockMvc in a Spring Boot test?
- Auto-configure MockMvc without starting a full HTTP server (Correct answer)
- Mock all Spring beans automatically
- Configure a real HTTP server on a random port
- Enable Mockito mocking of MVC controllers
Correct answer: Auto-configure MockMvc without starting a full HTTP server
@AutoConfigureMockMvc sets up MockMvc for testing the full Spring MVC stack in-process without binding to an actual port.
Question 7: In Spring Cloud Config, what HTTP endpoint is used to trigger a configuration refresh on a specific service instance?
- /actuator/refresh (Correct answer)
- /config/reload
- /actuator/restart
- /spring/refresh
Correct answer: /actuator/refresh
POSTing to /actuator/refresh causes the application context to re-bind @ConfigurationProperties and @Value fields from the config server.
Which Spring Cloud Contract feature allows a consumer team to define a contract before the producer API is implemented?