Skip to content

Instantly share code, notes, and snippets.

@robertoduessmann
Last active October 1, 2020 20:27
Show Gist options
  • Select an option

  • Save robertoduessmann/e4d7c81bb4de001c044365c144a364d8 to your computer and use it in GitHub Desktop.

Select an option

Save robertoduessmann/e4d7c81bb4de001c044365c144a364d8 to your computer and use it in GitHub Desktop.
public class ContainersSetupIT {
public static PostgreSQLContainer postgres = new PostgreSQLContainer("postgres:12.2")
.withDatabaseName("financial");
public static KafkaContainer kafka = new KafkaContainer();
public static class Initializer implements
ApplicationContextInitializer<ConfigurableApplicationContext> {
@Override
public void initialize(ConfigurableApplicationContext context) {
postgres.start();
kafka.start();
System.setProperty("DB_URL", postgres.getContainerIpAddress());
System.setProperty("DB_PORT",
postgres.getMappedPort(PostgreSQLContainer.POSTGRESQL_PORT).toString());
System.setProperty("DB_USERNAME", postgres.getUsername());
System.setProperty("DB_PASSWORD", postgres.getPassword());
System.setProperty("KAFKA_BOOTSTRAP_SERVERS", kafka.getBootstrapServers());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment