Skip to content

Commit

Permalink
separate container configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed May 31, 2024
1 parent 206d809 commit 7f0d031
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
package com.example.custom.sequence;

import com.example.custom.sequence.common.ContainersConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.Bean;
import org.testcontainers.containers.MariaDBContainer;
import org.springframework.context.annotation.Import;

@TestConfiguration(proxyBeanMethods = false)
@Import(ContainersConfig.class)
public class TestApplication {

@Bean
@ServiceConnection
MariaDBContainer<?> mariaDbContainer() {
return new MariaDBContainer<>("mariadb:11.4");
}

public static void main(String[] args) {
SpringApplication.from(Application::main).with(TestApplication.class).run(args);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.example.custom.sequence.common;

import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.Bean;
import org.testcontainers.containers.MariaDBContainer;
import org.testcontainers.utility.DockerImageName;

@TestConfiguration(proxyBeanMethods = false)
public class ContainersConfig {

@Bean
@ServiceConnection
MariaDBContainer<?> mariaDbContainer() {
return new MariaDBContainer<>(DockerImageName.parse("mariadb").withTag("11.4"));
}
}

0 comments on commit 7f0d031

Please sign in to comment.