Skip to content

πŸš€ Example project with configured Spring Boot, JooQ, TestContainers, MySQL container and JUnit5

Notifications You must be signed in to change notification settings

jpomykala/spring-jooq-flyway-testcontainers-junit5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

spring-jooq-flyway-testcontainers-junit5

Example project with configured Spring Boot, JooQ, TestContainers, flyway (as maven plugin) MySQL container and JUnit5 πŸš€

Used versions

<spring-boot.version>2.1.1</spring-boot.version>
<java.version>11</java.version>
<org.flyway.version>5.2.4</org.flyway.version>
<org.jooq.version>3.11.7</org.jooq.version>
<mysql-connector-java.version>8.0.11</mysql-connector-java.version>
<testcontainers.version>1.10.5</testcontainers.version>

Running

mvn clean test

Test loads first migration V1__Init.sql manually.

Main test configuration

@ContextConfiguration(initializers = AbstractTestConfiguration.Initializer.class)
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
@JooqTest
public abstract class AbstractTestConfiguration {

  @ClassRule
  public static MySQLContainer mysql = new MySQLContainer().withDatabaseName("playground");


  public static class Initializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {

    @Override
    public void initialize(@NotNull ConfigurableApplicationContext configurableApplicationContext) {
      mysql.start();
      configurableApplicationContext.getEnvironment().getSystemProperties().put("spring.datasource.url", mysql.getJdbcUrl() + "?useSSL=false");
      configurableApplicationContext.getEnvironment().getSystemProperties().put("spring.datasource.username", mysql.getUsername());
      configurableApplicationContext.getEnvironment().getSystemProperties().put("spring.datasource.password", mysql.getPassword());
    }
  }
}

About

πŸš€ Example project with configured Spring Boot, JooQ, TestContainers, MySQL container and JUnit5

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages