|
1 | 1 | package org.testcontainers.containers; |
2 | 2 |
|
3 | | -import com.google.common.collect.Sets; |
4 | 3 | import org.testcontainers.containers.wait.strategy.HttpWaitStrategy; |
5 | 4 | import org.testcontainers.utility.DockerImageName; |
6 | 5 |
|
7 | 6 | import java.time.Duration; |
| 7 | +import java.util.HashSet; |
8 | 8 | import java.util.Set; |
9 | 9 |
|
10 | | -public class ClickHouseContainer extends JdbcDatabaseContainer { |
| 10 | +public class ClickHouseContainer extends JdbcDatabaseContainer<ClickHouseContainer> { |
11 | 11 |
|
12 | 12 | public static final String NAME = "clickhouse"; |
13 | 13 |
|
@@ -53,23 +53,27 @@ public ClickHouseContainer(final DockerImageName dockerImageName) { |
53 | 53 | super(dockerImageName); |
54 | 54 | dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, CLICKHOUSE_IMAGE_NAME); |
55 | 55 |
|
56 | | - withExposedPorts(HTTP_PORT, NATIVE_PORT); |
57 | | - waitingFor( |
| 56 | + addExposedPorts(HTTP_PORT, NATIVE_PORT); |
| 57 | + this.waitStrategy = |
58 | 58 | new HttpWaitStrategy() |
59 | 59 | .forStatusCode(200) |
60 | | - .forResponsePredicate(responseBody -> "Ok.".equals(responseBody)) |
61 | | - .withStartupTimeout(Duration.ofMinutes(1)) |
62 | | - ); |
| 60 | + .forResponsePredicate("Ok."::equals) |
| 61 | + .withStartupTimeout(Duration.ofMinutes(1)); |
63 | 62 | } |
64 | 63 |
|
65 | 64 | @Override |
66 | 65 | public Set<Integer> getLivenessCheckPortNumbers() { |
67 | | - return Sets.newHashSet(HTTP_PORT); |
| 66 | + return new HashSet<>(getMappedPort(HTTP_PORT)); |
68 | 67 | } |
69 | 68 |
|
70 | 69 | @Override |
71 | 70 | 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 | + } |
73 | 77 | } |
74 | 78 |
|
75 | 79 | @Override |
|
0 commit comments