Advanced Spring Boot Test 3

    Question 1SPRING BOOT ASYNC- Code Snippet (@Scheduled fixedDelay)

    How does this method behave?

    @Scheduled(fixedDelay = 3000) public void process() { System.out.println("Task executed"); }

    Question 2SPRING BOOT AWS - CI/CD with CodePipeline

    Which AWS service automates CI/CD pipelines for Spring Boot applications?

    Question 3SPRING BOOT TESTING - Code Snippet (DynamicPropertySource)

    What is the purpose of this code?

    @DynamicPropertySource static void configure(DynamicPropertyRegistry registry) { registry.add("spring.datasource.url", postgres::getJdbcUrl); registry.add("spring.datasource.username", postgres::getUsername); registry.add("spring.datasource.password", postgres::getPassword); }

    Question 4SPRING BOOT AOP - Proxy Mechanism

    How does Spring AOP implement aspects internally by default?

    Question 5SPRING BOOT CACHING- CacheManager Bean

    Which bean typically manages cache interactions in a Redis-backed Spring Boot application?

    Question 6SPRING BOOT MICROSERVICES- Distributed Configuration

    Which Spring Cloud component provides centralized configuration management for microservices?

    Question 7SPRING BOOT ASYNC- Code Snippet (Cron Expression)

    What is the schedule for this method?

    @Scheduled(cron = "0 0 9 * * ?") public void reportTask() { System.out.println("Daily report generated"); }

    Question 8SPRING BOOT AWS - Code Snippet (Delete File in S3)

    What does this code do?

    amazonS3.deleteObject("my-bucket", "old-file.txt");

    Question 9SPRING BOOT TESTING - @TestConfiguration

    What is the purpose of `@TestConfiguration` in Spring Boot testing?

    Question 10SPRING BOOT AOP - Aspect Ordering

    If multiple aspects apply to the same join point, how can their execution order be controlled?

    Question 11SPRING BOOT CACHING- TTL in Redis Cache

    How can you configure a Time-To-Live (TTL) for cached entries in Spring Boot Redis caching?

    Question 12SPRING BOOT MICROSERVICES- Fault Tolerance

    Which library in Spring Cloud provides circuit breaker functionality for fault tolerance?

    Question 13SPRING BOOT ASYNC- Enabling Scheduling

    Which annotation is required to enable @Scheduled annotations?

    Question 14SPRING BOOT AWS - Monitoring Applications

    Which AWS service can be used to monitor Spring Boot applications deployed on EC2 or ECS?

    Question 15SPRING BOOT TESTING - Code Snippet (Repository Test)

    What is this test checking?

    @DataJpaTest class UserRepositoryTest { @Autowired private UserRepository userRepository; @Test void testFindByEmail() { User user = new User(null, "Alice", "alice@mail.com"); userRepository.save(user); Optional<User> found = userRepository.findByEmail("alice@mail.com"); assertTrue(found.isPresent()); } }

    Question 16SPRING BOOT AOP - Code Snippet (Reusing Pointcut)

    What does the following code achieve?

    @Pointcut("execution(* com.example.controller.*.*(..))") public void controllerMethods() {} @Before("controllerMethods()") public void logBeforeController() { System.out.println("Controller method invoked"); }

    Question 17SPRING BOOT CACHING- Code Snippet (RedisTemplate Usage)

    What does this code do?

    @Autowired private RedisTemplate<String, String> redisTemplate; @Test void testSetAndGet() { redisTemplate.opsForValue().set("greeting", "Hello Redis"); String value = redisTemplate.opsForValue().get("greeting"); System.out.println(value); }

    Question 18SPRING BOOT MICROSERVICES- Code Snippet (Circuit Breaker with Resilience4j)

    What does this method do?

    @CircuitBreaker(name = "userService", fallbackMethod = "fallbackUser") public User getUser(Long id) { return userClient.getUserById(id); } public User fallbackUser(Long id, Throwable ex) { return new User(id, "Unknown"); }

    Question 19SPRING BOOT ASYNC- Thread Pool for Async Tasks

    How can we define a custom thread pool for @Async methods in Spring Boot?

    Question 20SPRING BOOT AWS - CI/CD Deployment

    In a typical CI/CD pipeline for Spring Boot on AWS, which combination is correct?