From d7af4494fb169984bc77f656b035dda97698de85 Mon Sep 17 00:00:00 2001 From: Hai Phuc Nguyen <“3423575+haiphucnguyen@users.noreply.github.com”> Date: Fri, 13 Jun 2025 00:34:27 -0700 Subject: [PATCH 1/4] Update Update Update Update Update Update Update Update --- .../src/test/resources/logback.xml | 24 ------------------- .../ai/OllamaContainerProvider.java | 1 - 2 files changed, 25 deletions(-) delete mode 100644 examples/springboot-ollama/src/test/resources/logback.xml diff --git a/examples/springboot-ollama/src/test/resources/logback.xml b/examples/springboot-ollama/src/test/resources/logback.xml deleted file mode 100644 index 06012ac..0000000 --- a/examples/springboot-ollama/src/test/resources/logback.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/ollama/src/main/java/io/flowinquiry/testcontainers/ai/OllamaContainerProvider.java b/modules/ollama/src/main/java/io/flowinquiry/testcontainers/ai/OllamaContainerProvider.java index 3452ba9..ea3b7ad 100644 --- a/modules/ollama/src/main/java/io/flowinquiry/testcontainers/ai/OllamaContainerProvider.java +++ b/modules/ollama/src/main/java/io/flowinquiry/testcontainers/ai/OllamaContainerProvider.java @@ -79,7 +79,6 @@ public void start() { @Override public void applyTo(ConfigurableEnvironment environment) { Properties props = new Properties(); - props.put("spring.ai.ollama.base-url", container.getEndpoint()); props.put("spring.ai.ollama.init.pull-model-strategy", "when_missing"); props.put("spring.ai.ollama.chat.model", enableContainerAnnotation.model()); props.put( From 9b375ea7c8124b385b97c05d8171aa75e5810983 Mon Sep 17 00:00:00 2001 From: Hai Phuc Nguyen <“3423575+haiphucnguyen@users.noreply.github.com”> Date: Fri, 13 Jun 2025 23:04:25 -0700 Subject: [PATCH 2/4] Update --- .../flowinquiry/testcontainers/ai/OllamaContainerProvider.java | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/ollama/src/main/java/io/flowinquiry/testcontainers/ai/OllamaContainerProvider.java b/modules/ollama/src/main/java/io/flowinquiry/testcontainers/ai/OllamaContainerProvider.java index ea3b7ad..3452ba9 100644 --- a/modules/ollama/src/main/java/io/flowinquiry/testcontainers/ai/OllamaContainerProvider.java +++ b/modules/ollama/src/main/java/io/flowinquiry/testcontainers/ai/OllamaContainerProvider.java @@ -79,6 +79,7 @@ public void start() { @Override public void applyTo(ConfigurableEnvironment environment) { Properties props = new Properties(); + props.put("spring.ai.ollama.base-url", container.getEndpoint()); props.put("spring.ai.ollama.init.pull-model-strategy", "when_missing"); props.put("spring.ai.ollama.chat.model", enableContainerAnnotation.model()); props.put( From 16dbf57c0ce24e8ec73ac7fb111b283b0851ad54 Mon Sep 17 00:00:00 2001 From: Hai Phuc Nguyen <“3423575+haiphucnguyen@users.noreply.github.com”> Date: Fri, 13 Jun 2025 23:41:38 -0700 Subject: [PATCH 3/4] Update --- README.md | 5 ++-- .../src/main/resources/application.properties | 15 ---------- .../src/main/resources/application.yml | 28 +++++++++++++++++++ .../resources/application-test.properties | 13 --------- .../src/test/resources/application-test.yml | 26 +++++++++++++++++ .../src/test/resources/logback.xml | 16 ----------- .../src/main/resources/application.properties | 15 ---------- .../src/main/resources/application.yml | 28 +++++++++++++++++++ .../src/test/resources/logback.xml | 20 ------------- .../src/main/resources/application.properties | 15 ---------- .../src/main/resources/application.yml | 27 ++++++++++++++++++ .../ContainerLifecycleExtension.java | 4 +-- .../SpringAwareContainerProvider.java | 2 +- 13 files changed, 113 insertions(+), 101 deletions(-) delete mode 100644 examples/spring-postgresql/src/main/resources/application.properties create mode 100644 examples/spring-postgresql/src/main/resources/application.yml delete mode 100644 examples/spring-postgresql/src/test/resources/application-test.properties create mode 100644 examples/spring-postgresql/src/test/resources/application-test.yml delete mode 100644 examples/spring-postgresql/src/test/resources/logback.xml delete mode 100644 examples/springboot-mysql/src/main/resources/application.properties create mode 100644 examples/springboot-mysql/src/main/resources/application.yml delete mode 100644 examples/springboot-mysql/src/test/resources/logback.xml delete mode 100644 examples/springboot-postgresql/src/main/resources/application.properties create mode 100644 examples/springboot-postgresql/src/main/resources/application.yml diff --git a/README.md b/README.md index 1fe375c..2a596a6 100644 --- a/README.md +++ b/README.md @@ -257,9 +257,8 @@ Contributions are welcome! If you'd like to add support for additional databases 1. Fork the repository 2. Create a feature branch -3. Install the Git hooks to ensure code formatting (see below) -4. Add your changes -5. Submit a pull request +3. Add your changes +4. Submit a pull request ## License diff --git a/examples/spring-postgresql/src/main/resources/application.properties b/examples/spring-postgresql/src/main/resources/application.properties deleted file mode 100644 index c2e81fe..0000000 --- a/examples/spring-postgresql/src/main/resources/application.properties +++ /dev/null @@ -1,15 +0,0 @@ -# Database configuration -spring.datasource.url=jdbc:postgresql://localhost:5432/testdb -spring.datasource.username=postgres -spring.datasource.password=postgres -spring.datasource.driver-class-name=org.postgresql.Driver - -# JPA/Hibernate properties -spring.jpa.hibernate.ddl-auto=create -spring.jpa.show-sql=true -spring.jpa.properties.hibernate.format_sql=true -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect - -# Logging -logging.level.org.hibernate.SQL=DEBUG -logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE \ No newline at end of file diff --git a/examples/spring-postgresql/src/main/resources/application.yml b/examples/spring-postgresql/src/main/resources/application.yml new file mode 100644 index 0000000..f08c9e3 --- /dev/null +++ b/examples/spring-postgresql/src/main/resources/application.yml @@ -0,0 +1,28 @@ +# Database configuration +spring: + datasource: + url: jdbc:postgresql://localhost:5432/testdb + username: postgres + password: postgres + driver-class-name: org.postgresql.Driver + + # JPA/Hibernate properties + jpa: + hibernate: + ddl-auto: create + show-sql: true + properties: + hibernate: + format_sql: true + dialect: org.hibernate.dialect.PostgreSQLDialect + +# Logging +logging: + level: + org: + hibernate: + SQL: DEBUG + type: + descriptor: + sql: + BasicBinder: TRACE \ No newline at end of file diff --git a/examples/spring-postgresql/src/test/resources/application-test.properties b/examples/spring-postgresql/src/test/resources/application-test.properties deleted file mode 100644 index a3f778e..0000000 --- a/examples/spring-postgresql/src/test/resources/application-test.properties +++ /dev/null @@ -1,13 +0,0 @@ -# Test-specific database configuration -# These will be overridden by the testcontainers configuration -spring.datasource.driver-class-name=org.postgresql.Driver - -# JPA/Hibernate properties for tests -spring.jpa.hibernate.ddl-auto=create-drop -spring.jpa.show-sql=true -spring.jpa.properties.hibernate.format_sql=true -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect - -# Logging for tests -logging.level.org.hibernate.SQL=DEBUG -logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE \ No newline at end of file diff --git a/examples/spring-postgresql/src/test/resources/application-test.yml b/examples/spring-postgresql/src/test/resources/application-test.yml new file mode 100644 index 0000000..7760a19 --- /dev/null +++ b/examples/spring-postgresql/src/test/resources/application-test.yml @@ -0,0 +1,26 @@ +# Test-specific database configuration +# These will be overridden by the testcontainers configuration +spring: + datasource: + driver-class-name: org.postgresql.Driver + + # JPA/Hibernate properties for tests + jpa: + hibernate: + ddl-auto: create-drop + show-sql: true + properties: + hibernate: + format_sql: true + dialect: org.hibernate.dialect.PostgreSQLDialect + +# Logging for tests +logging: + level: + org: + hibernate: + SQL: DEBUG + type: + descriptor: + sql: + BasicBinder: TRACE \ No newline at end of file diff --git a/examples/spring-postgresql/src/test/resources/logback.xml b/examples/spring-postgresql/src/test/resources/logback.xml deleted file mode 100644 index caf3d28..0000000 --- a/examples/spring-postgresql/src/test/resources/logback.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/springboot-mysql/src/main/resources/application.properties b/examples/springboot-mysql/src/main/resources/application.properties deleted file mode 100644 index 446403f..0000000 --- a/examples/springboot-mysql/src/main/resources/application.properties +++ /dev/null @@ -1,15 +0,0 @@ -# Database configuration -spring.datasource.url=jdbc:mysql://localhost:3306/testdb -spring.datasource.username=root -spring.datasource.password=root -spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver - -# JPA/Hibernate properties -spring.jpa.hibernate.ddl-auto=create -spring.jpa.show-sql=true -spring.jpa.properties.hibernate.format_sql=true -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect - -# Logging -logging.level.org.hibernate.SQL=DEBUG -logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE \ No newline at end of file diff --git a/examples/springboot-mysql/src/main/resources/application.yml b/examples/springboot-mysql/src/main/resources/application.yml new file mode 100644 index 0000000..aa2a5f0 --- /dev/null +++ b/examples/springboot-mysql/src/main/resources/application.yml @@ -0,0 +1,28 @@ +# Database configuration +spring: + datasource: + url: jdbc:mysql://localhost:3306/testdb + username: root + password: root + driver-class-name: com.mysql.cj.jdbc.Driver + + # JPA/Hibernate properties + jpa: + hibernate: + ddl-auto: create + show-sql: true + properties: + hibernate: + format_sql: true + dialect: org.hibernate.dialect.MySQLDialect + +# Logging +logging: + level: + org: + hibernate: + SQL: DEBUG + type: + descriptor: + sql: + BasicBinder: TRACE \ No newline at end of file diff --git a/examples/springboot-mysql/src/test/resources/logback.xml b/examples/springboot-mysql/src/test/resources/logback.xml deleted file mode 100644 index 02c0336..0000000 --- a/examples/springboot-mysql/src/test/resources/logback.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/springboot-postgresql/src/main/resources/application.properties b/examples/springboot-postgresql/src/main/resources/application.properties deleted file mode 100644 index c2e81fe..0000000 --- a/examples/springboot-postgresql/src/main/resources/application.properties +++ /dev/null @@ -1,15 +0,0 @@ -# Database configuration -spring.datasource.url=jdbc:postgresql://localhost:5432/testdb -spring.datasource.username=postgres -spring.datasource.password=postgres -spring.datasource.driver-class-name=org.postgresql.Driver - -# JPA/Hibernate properties -spring.jpa.hibernate.ddl-auto=create -spring.jpa.show-sql=true -spring.jpa.properties.hibernate.format_sql=true -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect - -# Logging -logging.level.org.hibernate.SQL=DEBUG -logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE \ No newline at end of file diff --git a/examples/springboot-postgresql/src/main/resources/application.yml b/examples/springboot-postgresql/src/main/resources/application.yml new file mode 100644 index 0000000..2653746 --- /dev/null +++ b/examples/springboot-postgresql/src/main/resources/application.yml @@ -0,0 +1,27 @@ +# Database configuration +spring: + datasource: + url: jdbc:postgresql://localhost:5432/testdb + username: postgres + password: postgres + driver-class-name: org.postgresql.Driver + # JPA/Hibernate properties + jpa: + hibernate: + ddl-auto: create + show-sql: true + properties: + hibernate: + format_sql: true + dialect: org.hibernate.dialect.PostgreSQLDialect + +# Logging +logging: + level: + org: + hibernate: + SQL: DEBUG + type: + descriptor: + sql: + BasicBinder: TRACE \ No newline at end of file diff --git a/spring-testcontainers/src/main/java/io/flowinquiry/testcontainers/ContainerLifecycleExtension.java b/spring-testcontainers/src/main/java/io/flowinquiry/testcontainers/ContainerLifecycleExtension.java index 16d610b..854bdbd 100644 --- a/spring-testcontainers/src/main/java/io/flowinquiry/testcontainers/ContainerLifecycleExtension.java +++ b/spring-testcontainers/src/main/java/io/flowinquiry/testcontainers/ContainerLifecycleExtension.java @@ -16,10 +16,8 @@ public abstract class ContainerLifecycleExtension implements BeforeAllCallback, AfterAllCallback { - /** Logger for this class. */ private static final Logger log = LoggerFactory.getLogger(ContainerLifecycleExtension.class); - /** The container provider that manages the actual container instance. */ private SpringAwareContainerProvider> provider; @@ -56,7 +54,7 @@ public void beforeAll(ExtensionContext context) { this.provider = ContainerRegistry.get(testClass); } else { this.provider = initProvider(enableContainerAnnotation); - log.debug("Starting JDBC container {} for test class: {}", provider, testClass.getName()); + log.debug("Starting container {} for test class: {}", provider, testClass.getName()); provider.start(); ContainerRegistry.set(testClass, provider); } diff --git a/spring-testcontainers/src/main/java/io/flowinquiry/testcontainers/SpringAwareContainerProvider.java b/spring-testcontainers/src/main/java/io/flowinquiry/testcontainers/SpringAwareContainerProvider.java index aa368be..ed49c61 100644 --- a/spring-testcontainers/src/main/java/io/flowinquiry/testcontainers/SpringAwareContainerProvider.java +++ b/spring-testcontainers/src/main/java/io/flowinquiry/testcontainers/SpringAwareContainerProvider.java @@ -15,7 +15,7 @@ * well as applying container configuration to Spring environment. * *

Implementations of this class should provide specific container creation logic and environment - * configuration for different container types (e.g., PostgreSQL, MySQL, Ollama). + * configuration for different container types (e.g., PostgreSQL, MySQL, Ollama, etc). * * @param The specific type of GenericContainer being managed */ From a243c82bd7f06ee97e2f54cd85dd5c3b822ef1b0 Mon Sep 17 00:00:00 2001 From: Hai Phuc Nguyen <“3423575+haiphucnguyen@users.noreply.github.com”> Date: Sat, 14 Jun 2025 00:02:23 -0700 Subject: [PATCH 4/4] Update --- .../src/main/resources/application.properties | 15 ++++++++++ .../src/main/resources/application.yml | 28 ------------------- .../src/test/resources/application-test.yml | 26 ----------------- 3 files changed, 15 insertions(+), 54 deletions(-) create mode 100644 examples/spring-postgresql/src/main/resources/application.properties delete mode 100644 examples/spring-postgresql/src/main/resources/application.yml delete mode 100644 examples/spring-postgresql/src/test/resources/application-test.yml diff --git a/examples/spring-postgresql/src/main/resources/application.properties b/examples/spring-postgresql/src/main/resources/application.properties new file mode 100644 index 0000000..c2e81fe --- /dev/null +++ b/examples/spring-postgresql/src/main/resources/application.properties @@ -0,0 +1,15 @@ +# Database configuration +spring.datasource.url=jdbc:postgresql://localhost:5432/testdb +spring.datasource.username=postgres +spring.datasource.password=postgres +spring.datasource.driver-class-name=org.postgresql.Driver + +# JPA/Hibernate properties +spring.jpa.hibernate.ddl-auto=create +spring.jpa.show-sql=true +spring.jpa.properties.hibernate.format_sql=true +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect + +# Logging +logging.level.org.hibernate.SQL=DEBUG +logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE \ No newline at end of file diff --git a/examples/spring-postgresql/src/main/resources/application.yml b/examples/spring-postgresql/src/main/resources/application.yml deleted file mode 100644 index f08c9e3..0000000 --- a/examples/spring-postgresql/src/main/resources/application.yml +++ /dev/null @@ -1,28 +0,0 @@ -# Database configuration -spring: - datasource: - url: jdbc:postgresql://localhost:5432/testdb - username: postgres - password: postgres - driver-class-name: org.postgresql.Driver - - # JPA/Hibernate properties - jpa: - hibernate: - ddl-auto: create - show-sql: true - properties: - hibernate: - format_sql: true - dialect: org.hibernate.dialect.PostgreSQLDialect - -# Logging -logging: - level: - org: - hibernate: - SQL: DEBUG - type: - descriptor: - sql: - BasicBinder: TRACE \ No newline at end of file diff --git a/examples/spring-postgresql/src/test/resources/application-test.yml b/examples/spring-postgresql/src/test/resources/application-test.yml deleted file mode 100644 index 7760a19..0000000 --- a/examples/spring-postgresql/src/test/resources/application-test.yml +++ /dev/null @@ -1,26 +0,0 @@ -# Test-specific database configuration -# These will be overridden by the testcontainers configuration -spring: - datasource: - driver-class-name: org.postgresql.Driver - - # JPA/Hibernate properties for tests - jpa: - hibernate: - ddl-auto: create-drop - show-sql: true - properties: - hibernate: - format_sql: true - dialect: org.hibernate.dialect.PostgreSQLDialect - -# Logging for tests -logging: - level: - org: - hibernate: - SQL: DEBUG - type: - descriptor: - sql: - BasicBinder: TRACE \ No newline at end of file