-
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.
Added support for static port for Clickhouse
- Loading branch information
1 parent
d065c5b
commit 640d873
Showing
5 changed files
with
77 additions
and
15 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
38 changes: 38 additions & 0 deletions
38
.../java/com/infobip/testcontainers/spring/clickhouse/ClickhouseContainerStaticPortTest.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,38 @@ | ||
package com.infobip.testcontainers.spring.clickhouse; | ||
|
||
import static com.infobip.testcontainers.spring.clickhouse.DataSourceConfig.CLICKHOUSE_URL_PROPERTY_NAME; | ||
import static org.assertj.core.api.BDDAssertions.then; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import lombok.AllArgsConstructor; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.core.env.Environment; | ||
import org.springframework.jdbc.core.JdbcTemplate; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.context.TestConstructor; | ||
|
||
@AllArgsConstructor | ||
@ActiveProfiles("static-port") | ||
@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) | ||
@SpringBootTest(classes = Main.class) | ||
class ClickhouseContainerStaticPortTest { | ||
|
||
Environment environment; | ||
DataSource dataSource; | ||
|
||
@Test | ||
void shouldCreateContainerWithStaticPort() { | ||
//given | ||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); | ||
|
||
//when | ||
String result = jdbcTemplate.queryForObject("SELECT 1", String.class); | ||
|
||
//then | ||
then(environment.getProperty(CLICKHOUSE_URL_PROPERTY_NAME)).isEqualTo("jdbc:clickhouse://localhost:5000"); | ||
then(result).isEqualTo("1"); | ||
} | ||
|
||
} |
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
8 changes: 8 additions & 0 deletions
8
...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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
spring: | ||
datasource: | ||
clickhouse: | ||
jdbc-url: jdbc:clickhouse://<host>:5000 | ||
|
||
testcontainers: | ||
clickhouse: | ||
custom-path: "spring.datasource.clickhouse" |
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