Reputation: 11
This is my application-it.yml file:
spring:
r2dbc:
url: r2dbc:tc:mysql:///warehouse-db?TC_IMAGE_TAG=latest
Here are my dependencies from pom.xml:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-r2dbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>io.asyncer</groupId>
<artifactId>r2dbc-mysql</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>r2dbc</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
This is my test class:
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@ActiveProfiles(profiles = "it")
@Testcontainers
@TestInstance(Lifecycle.PER_CLASS)
@Import(SchemaCreatorConfig.class)
public class WarehouseControllerIT{
@Autowired
private WebTestClient client;
@Test
void givenInvalidWarehouseDTO_whenCreateWarehouse_thenReturnBadRequest() {
WarehouseDTO dto = new WarehouseDTO();
dto.setCountry("Spain9");
dto.setState("Madrid");
dto.setCity("Madrid");
dto.setStreetNameAndNo("stree name and num");
dto.setName("es-madrid");
client.post().uri("/api/warehouse").body(Mono.just(dto),WarehouseDTO.class).exchange()
.expectStatus().isBadRequest();
}
}
I think I have configured the r2dbc url correctly and included the neccessary dependencies and I can not figure out what I am missing here since I already have included aync mysql driver. Why is it trwoing that exception?
Upvotes: 1
Views: 78