-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
267 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...ip/testcontainers/spring/clickhouse/ClickhouseContainerInitializerWithInitScriptTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.infobip.testcontainers.spring.clickhouse; | ||
|
||
import lombok.AllArgsConstructor; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.jdbc.core.JdbcTemplate; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.context.TestConstructor; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import static org.assertj.core.api.BDDAssertions.then; | ||
|
||
@AllArgsConstructor | ||
@ActiveProfiles("init-script") | ||
@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) | ||
@SpringBootTest(classes = Main.class) | ||
class ClickhouseContainerInitializerWithInitScriptTest { | ||
|
||
private DataSource dataSource; | ||
|
||
@Test | ||
void shouldCreateContainer() { | ||
//given | ||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); | ||
|
||
//when | ||
String result = jdbcTemplate.queryForObject("SELECT name FROM test_table WHERE id = 1", String.class); | ||
|
||
//then | ||
then(result).isEqualTo("Test"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...khouse-testcontainers-spring-boot-starter/src/test/resources/application-init-script.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
spring: | ||
datasource: | ||
clickhouse: | ||
jdbc-url: jdbc:clickhouse://<host>:<port> | ||
|
||
testcontainers: | ||
clickhouse: | ||
init-script: db/init-script.sql | ||
custom-path: "spring.datasource.clickhouse" |
6 changes: 3 additions & 3 deletions
6
...khouse-testcontainers-spring-boot-starter/src/test/resources/application-static-port.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
spring: | ||
datasource: | ||
clickhouse: | ||
jdbc-url: jdbc:clickhouse://<host>:5001 | ||
jdbc-url: jdbc:clickhouse://<host>:5001 | ||
|
||
testcontainers: | ||
clickhouse: | ||
custom-path: "spring.datasource.clickhouse" | ||
clickhouse: | ||
custom-path: "spring.datasource.clickhouse" |
6 changes: 3 additions & 3 deletions
6
...ip-clickhouse-testcontainers-spring-boot-starter/src/test/resources/application-test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
spring: | ||
datasource: | ||
clickhouse: | ||
jdbc-url: jdbc:clickhouse://<host>:<port> | ||
jdbc-url: jdbc:clickhouse://<host>:<port> | ||
|
||
testcontainers: | ||
clickhouse: | ||
custom-path: "spring.datasource.clickhouse" | ||
clickhouse: | ||
custom-path: "spring.datasource.clickhouse" |
8 changes: 8 additions & 0 deletions
8
infobip-clickhouse-testcontainers-spring-boot-starter/src/test/resources/db/init-script.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CREATE TABLE test_table | ||
( | ||
id Int32, | ||
name String | ||
) ENGINE = MergeTree() ORDER BY id; | ||
|
||
INSERT INTO test_table (id, name) | ||
VALUES (1, 'Test'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...nfobip/testcontainers/spring/mssql/MSSQLServerContainerInitializerWithInitScriptTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.infobip.testcontainers.spring.mssql; | ||
|
||
import lombok.AllArgsConstructor; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.jdbc.core.JdbcTemplate; | ||
import org.springframework.jdbc.datasource.SimpleDriverDataSource; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.context.TestConstructor; | ||
|
||
import java.sql.Driver; | ||
import java.sql.DriverManager; | ||
import java.sql.SQLException; | ||
|
||
import static org.assertj.core.api.BDDAssertions.then; | ||
|
||
@AllArgsConstructor | ||
@ActiveProfiles("init-script") | ||
@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) | ||
@SpringBootTest(classes = Main.class) | ||
class MSSQLServerContainerInitializerWithInitScriptTest { | ||
|
||
private final DataSourceProperties properties; | ||
|
||
@Test | ||
void shouldCreateDatabase() { | ||
// given | ||
JdbcTemplate jdbcTemplate = new JdbcTemplate(new SimpleDriverDataSource( | ||
getDriver(properties.getUrl()), | ||
properties.getUrl(), | ||
properties.getUsername(), | ||
properties.getPassword())); | ||
|
||
// when | ||
String actual = jdbcTemplate.queryForObject("SELECT TOP 1 name FROM test_table", String.class); | ||
|
||
// then | ||
then(actual).isEqualTo("Test"); | ||
} | ||
|
||
private Driver getDriver(String jdbcUrl) { | ||
try { | ||
return DriverManager.getDriver(jdbcUrl); | ||
} catch (SQLException e) { | ||
throw new IllegalArgumentException(e); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.