@Test
    public void testBookEndpoints() {

        // Create a new book
        Book book = new Book();
        book.setName("Is Java Dead?");
        book.setIsbn("111-111");

        ResponseEntity<Book> createResponse =
                restTemplate.postForEntity("/books", book, Book.class);
        assertEquals(HttpStatus.OK, createResponse.getStatusCode());
        Book savedBook = createResponse.getBody();

        assert savedBook != null;

        // Retrieve
        ResponseEntity<Book> getResponse =
                restTemplate.getForEntity("/books/" + savedBook.getId(), Book.class);
        assertEquals(HttpStatus.OK, getResponse.getStatusCode());

        Book bookFromGet = getResponse.getBody();

        assert bookFromGet != null;

        assertEquals("Is Java Dead?", bookFromGet.getName());
        assertEquals("111-111", bookFromGet.getIsbn());

        // Retrieve All
        ResponseEntity<Book[]> getAllResponse =
                restTemplate.getForEntity("/books", Book[].class);
        assertEquals(HttpStatus.OK, getAllResponse.getStatusCode());

        Book[] bookFromGetAll = getAllResponse.getBody();
        assert bookFromGetAll != null;

        assertEquals(1, bookFromGetAll.length);
    }
With Spring Boot 3.1, we use @ServiceConnection, no need @DynamicPropertySource
spring-boot-testcontainers/src/test/java/com/mkyong/book/BookControllerTest.java