Skip to content

Commit e23f378

Browse files
anavrotskibsideupeddumelendez
authored
[clickhouse] Add new JDBC driver name (#5474)
Also, fix the liveness port. Co-authored-by: Sergei Egorov <[email protected]> Co-authored-by: Eddú Meléndez <[email protected]>
1 parent 5a2d76f commit e23f378

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

modules/clickhouse/src/main/java/org/testcontainers/containers/ClickHouseContainer.java

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package org.testcontainers.containers;
22

3-
import com.google.common.collect.Sets;
43
import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
54
import org.testcontainers.utility.DockerImageName;
65

76
import java.time.Duration;
7+
import java.util.HashSet;
88
import java.util.Set;
99

10-
public class ClickHouseContainer extends JdbcDatabaseContainer {
10+
public class ClickHouseContainer extends JdbcDatabaseContainer<ClickHouseContainer> {
1111

1212
public static final String NAME = "clickhouse";
1313

@@ -53,23 +53,27 @@ public ClickHouseContainer(final DockerImageName dockerImageName) {
5353
super(dockerImageName);
5454
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, CLICKHOUSE_IMAGE_NAME);
5555

56-
withExposedPorts(HTTP_PORT, NATIVE_PORT);
57-
waitingFor(
56+
addExposedPorts(HTTP_PORT, NATIVE_PORT);
57+
this.waitStrategy =
5858
new HttpWaitStrategy()
5959
.forStatusCode(200)
60-
.forResponsePredicate(responseBody -> "Ok.".equals(responseBody))
61-
.withStartupTimeout(Duration.ofMinutes(1))
62-
);
60+
.forResponsePredicate("Ok."::equals)
61+
.withStartupTimeout(Duration.ofMinutes(1));
6362
}
6463

6564
@Override
6665
public Set<Integer> getLivenessCheckPortNumbers() {
67-
return Sets.newHashSet(HTTP_PORT);
66+
return new HashSet<>(getMappedPort(HTTP_PORT));
6867
}
6968

7069
@Override
7170
public String getDriverClassName() {
72-
return DRIVER_CLASS_NAME;
71+
try {
72+
Class.forName(DRIVER_CLASS_NAME);
73+
return DRIVER_CLASS_NAME;
74+
} catch (ClassNotFoundException e) {
75+
return "com.clickhouse.jdbc.ClickHouseDriver";
76+
}
7377
}
7478

7579
@Override

0 commit comments

Comments
 (0)