Advanced Spring Boot Test 2

    Question 1SPRING BOOT CACHING- CacheEvict Annotation

    What is the purpose of @CacheEvict?

    Question 2SPRING BOOT MICROSERVICES- Inter-Service Communication

    Which Spring Boot project is commonly used for declarative REST client communication between microservices?

    Question 3SPRING BOOT ASYNC- Async Return Types

    What return type is recommended when using @Async to track completion?

    Question 4SPRING BOOT AWS - Code Snippet (Download from S3)

    What does this code snippet achieve?

    S3Object s3Object = amazonS3.getObject("my-bucket", "file.txt"); InputStream inputStream = s3Object.getObjectContent();

    Question 5SPRING BOOT TESTING - Testcontainers Purpose

    What is the main advantage of using Testcontainers in Spring Boot tests?

    Question 6SPRING BOOT AOP - Pointcut Expressions

    Which pointcut expression matches all methods in all classes under com.app.repository package?

    Question 7SPRING BOOT CACHING- Code Snippet (@CacheEvict)

    What does this method do?

    @CacheEvict(value = "users", key = "#id") public void deleteUser(Long id) { userRepository.deleteById(id); }

    Question 8SPRING BOOT MICROSERVICES- Code Snippet (Feign Client)

    What does this interface represent?

    @FeignClient(name = "user-service") public interface UserClient { @GetMapping("/users/{id}") User getUserById(@PathVariable Long id); }

    Question 9SPRING BOOT ASYNC- @Scheduled Usage

    What is the role of @Scheduled in Spring Boot?

    Question 10SPRING BOOT AWS - AWS RDS Integration

    What is the role of AWS RDS in a Spring Boot application?

    Question 11SPRING BOOT TESTING - Code Snippet (Postgres Testcontainer)

    What does the following snippet configure?

    @Testcontainers public class UserRepositoryTest { @Container static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:15-alpine"); }

    Question 12SPRING BOOT AOP - Code Snippet (Around Advice)

    What does this @Around advice do?

    @Around("execution(* com.example.service.PaymentService.*(..))") public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable { long start = System.currentTimeMillis(); Object result = joinPoint.proceed(); long end = System.currentTimeMillis(); System.out.println("Execution time: " + (end - start) + " ms"); return result; }

    Question 13SPRING BOOT CACHING- Redis as Cache Store

    How does Spring Boot typically connect to Redis for caching?

    Question 14SPRING BOOT MICROSERVICES- API Gateway

    In Spring Boot microservices, what is the main purpose of an API Gateway (e.g., Spring Cloud Gateway)?

    Question 15SPRING BOOT ASYNC- Code Snippet (@Scheduled fixedRate)

    How often will the below method execute?

    @Scheduled(fixedRate = 5000) public void task() { System.out.println("Running task..."); }

    Question 16SPRING BOOT AWS - Code Snippet (Spring Boot with RDS)

    Given this application.properties, what is configured?

    spring.datasource.url=jdbc:mysql://mydb.abcdef.us-east-1.rds.amazonaws.com:3306/mydb spring.datasource.username=admin spring.datasource.password=secret123

    Question 17SPRING BOOT TESTING - Dynamic Properties from Testcontainers

    Which method is typically used to register Testcontainers database properties with Spring Boot during tests?

    Question 18SPRING BOOT AOP - Code Snippet (AfterThrowing)

    What is the purpose of this advice?

    @AfterThrowing( pointcut = "execution(* com.example.service.OrderService.*(..))", throwing = "ex") public void logException(Exception ex) { System.out.println("Exception caught: " + ex.getMessage()); }

    Question 19SPRING BOOT CACHING- Code Snippet (CachePut)

    What does this annotation do?

    @CachePut(value = "users", key = "#user.id") public User updateUser(User user) { return userRepository.save(user); }

    Question 20SPRING BOOT MICROSERVICES- Code Snippet (Spring Cloud Gateway)

    What does this configuration achieve?

    spring: cloud: gateway: routes: - id: order-service uri: lb://order-service predicates: - Path=/orders/**