File tree 16 files changed +98
-16
lines changed
main/java/org/testcontainers/containers
test/java/org/testcontainers/junit/db2
main/java/org/testcontainers/containers
test/java/org/testcontainers/junit/mssqlserver
main/java/org/testcontainers/containers
test/java/org/testcontainers/junit/mysql
main/java/org/testcontainers/containers
test/java/org/testcontainers/junit
main/java/org/testcontainers/containers
test/java/org/testcontainers/junit/postgresql
main/java/org/testcontainers/containers
test/java/org/testcontainers/containers
main/java/org/testcontainers/tidb
test/java/org/testcontainers/junit/tidb
main/java/org/testcontainers/containers
test/java/org/testcontainers/containers
16 files changed +98
-16
lines changed Original file line number Diff line number Diff line change 6
6
7
7
import java .time .Duration ;
8
8
import java .time .temporal .ChronoUnit ;
9
- import java .util .HashSet ;
10
9
import java .util .Set ;
11
10
12
11
public class Db2Container extends JdbcDatabaseContainer <Db2Container > {
@@ -54,9 +53,14 @@ public Db2Container(final DockerImageName dockerImageName) {
54
53
addExposedPort (DB2_PORT );
55
54
}
56
55
56
+ /**
57
+ * @return the ports on which to check if the container is ready
58
+ * @deprecated use {@link #getLivenessCheckPortNumbers()} instead
59
+ */
57
60
@ Override
61
+ @ Deprecated
58
62
protected Set <Integer > getLivenessCheckPorts () {
59
- return new HashSet <>( getMappedPort ( DB2_PORT ) );
63
+ return super . getLivenessCheckPorts ( );
60
64
}
61
65
62
66
@ Override
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ public void testSimple() throws SQLException {
21
21
22
22
int resultSetInt = resultSet .getInt (1 );
23
23
assertThat (resultSetInt ).as ("A basic SELECT query succeeds" ).isEqualTo (1 );
24
+ assertHasCorrectExposedAndLivenessCheckPorts (db2 );
24
25
}
25
26
}
26
27
@@ -37,4 +38,9 @@ public void testWithAdditionalUrlParamInJdbcUrl() {
37
38
assertThat (jdbcUrl ).contains (":sslConnection=false;" );
38
39
}
39
40
}
41
+
42
+ private void assertHasCorrectExposedAndLivenessCheckPorts (Db2Container db2 ) {
43
+ assertThat (db2 .getExposedPorts ()).containsExactly (Db2Container .DB2_PORT );
44
+ assertThat (db2 .getLivenessCheckPortNumbers ()).containsExactly (db2 .getMappedPort (Db2Container .DB2_PORT ));
45
+ }
40
46
}
Original file line number Diff line number Diff line change 1
1
package org .testcontainers .containers ;
2
2
3
- import com .google .common .collect .Sets ;
4
3
import org .testcontainers .utility .DockerImageName ;
5
4
import org .testcontainers .utility .LicenseAcceptance ;
6
5
@@ -64,7 +63,7 @@ public MSSQLServerContainer(final DockerImageName dockerImageName) {
64
63
65
64
@ Override
66
65
public Set <Integer > getLivenessCheckPortNumbers () {
67
- return Sets . newHashSet ( MS_SQL_SERVER_PORT );
66
+ return super . getLivenessCheckPortNumbers ( );
68
67
}
69
68
70
69
@ Override
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ public void testSimple() throws SQLException {
25
25
26
26
int resultSetInt = resultSet .getInt (1 );
27
27
assertThat (resultSetInt ).as ("A basic SELECT query succeeds" ).isEqualTo (1 );
28
+ assertHasCorrectExposedAndLivenessCheckPorts (mssqlServer );
28
29
}
29
30
}
30
31
@@ -64,4 +65,10 @@ public void testSetupDatabase() throws SQLException {
64
65
assertThat (resultSetInt ).as ("A basic SELECT query succeeds" ).isEqualTo (3 );
65
66
}
66
67
}
68
+
69
+ private void assertHasCorrectExposedAndLivenessCheckPorts (MSSQLServerContainer <?> mssqlServer ) {
70
+ assertThat (mssqlServer .getExposedPorts ()).containsExactly (MSSQLServerContainer .MS_SQL_SERVER_PORT );
71
+ assertThat (mssqlServer .getLivenessCheckPortNumbers ())
72
+ .containsExactly (mssqlServer .getMappedPort (MSSQLServerContainer .MS_SQL_SERVER_PORT ));
73
+ }
67
74
}
Original file line number Diff line number Diff line change 3
3
import org .jetbrains .annotations .NotNull ;
4
4
import org .testcontainers .utility .DockerImageName ;
5
5
6
- import java .util .HashSet ;
7
6
import java .util .Set ;
8
7
9
8
/**
@@ -56,10 +55,15 @@ public MySQLContainer(final DockerImageName dockerImageName) {
56
55
addExposedPort (MYSQL_PORT );
57
56
}
58
57
58
+ /**
59
+ * @return the ports on which to check if the container is ready
60
+ * @deprecated use {@link #getLivenessCheckPortNumbers()} instead
61
+ */
59
62
@ NotNull
60
63
@ Override
64
+ @ Deprecated
61
65
protected Set <Integer > getLivenessCheckPorts () {
62
- return new HashSet <>( getMappedPort ( MYSQL_PORT ) );
66
+ return super . getLivenessCheckPorts ( );
63
67
}
64
68
65
69
@ Override
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ public void testSimple() throws SQLException {
57
57
int resultSetInt = resultSet .getInt (1 );
58
58
59
59
assertThat (resultSetInt ).as ("A basic SELECT query succeeds" ).isEqualTo (1 );
60
+ assertHasCorrectExposedAndLivenessCheckPorts (mysql );
60
61
}
61
62
}
62
63
@@ -237,4 +238,9 @@ public void testWithAdditionalUrlParamInJdbcUrl() {
237
238
mysql .stop ();
238
239
}
239
240
}
241
+
242
+ private void assertHasCorrectExposedAndLivenessCheckPorts (MySQLContainer <?> mysql ) {
243
+ assertThat (mysql .getExposedPorts ()).containsExactly (MySQLContainer .MYSQL_PORT );
244
+ assertThat (mysql .getLivenessCheckPortNumbers ()).containsExactly (mysql .getMappedPort (MySQLContainer .MYSQL_PORT ));
245
+ }
240
246
}
Original file line number Diff line number Diff line change 6
6
7
7
import java .net .MalformedURLException ;
8
8
import java .net .URL ;
9
- import java .util .Collections ;
10
9
import java .util .Set ;
11
10
12
11
/**
@@ -42,10 +41,15 @@ public NginxContainer(final DockerImageName dockerImageName) {
42
41
setCommand ("nginx" , "-g" , "daemon off;" );
43
42
}
44
43
44
+ /**
45
+ * @return the ports on which to check if the container is ready
46
+ * @deprecated use {@link #getLivenessCheckPortNumbers()} instead
47
+ */
45
48
@ NotNull
46
49
@ Override
50
+ @ Deprecated
47
51
protected Set <Integer > getLivenessCheckPorts () {
48
- return Collections . singleton ( getMappedPort ( 80 ) );
52
+ return super . getLivenessCheckPorts ( );
49
53
}
50
54
51
55
public URL getBaseUrl (String scheme , int port ) throws MalformedURLException {
Original file line number Diff line number Diff line change @@ -58,6 +58,12 @@ public void testSimple() throws Exception {
58
58
.as ("An HTTP GET from the Nginx server returns the index.html from the custom content directory" )
59
59
.contains ("Hello World!" );
60
60
// }
61
+ assertHasCorrectExposedAndLivenessCheckPorts (nginx );
62
+ }
63
+
64
+ private void assertHasCorrectExposedAndLivenessCheckPorts (NginxContainer <?> nginxContainer ) throws Exception {
65
+ assertThat (nginxContainer .getExposedPorts ()).containsExactly (80 );
66
+ assertThat (nginxContainer .getLivenessCheckPortNumbers ()).containsExactly (nginxContainer .getMappedPort (80 ));
61
67
}
62
68
63
69
private static String responseFromNginx (URL baseUrl ) throws IOException {
Original file line number Diff line number Diff line change 6
6
7
7
import java .time .Duration ;
8
8
import java .time .temporal .ChronoUnit ;
9
- import java .util .Collections ;
10
9
import java .util .Set ;
11
10
12
11
/**
@@ -62,10 +61,15 @@ public PostgreSQLContainer(final DockerImageName dockerImageName) {
62
61
addExposedPort (POSTGRESQL_PORT );
63
62
}
64
63
64
+ /**
65
+ * @return the ports on which to check if the container is ready
66
+ * @deprecated use {@link #getLivenessCheckPortNumbers()} instead
67
+ */
65
68
@ NotNull
66
69
@ Override
70
+ @ Deprecated
67
71
protected Set <Integer > getLivenessCheckPorts () {
68
- return Collections . singleton ( getMappedPort ( POSTGRESQL_PORT ) );
72
+ return super . getLivenessCheckPorts ( );
69
73
}
70
74
71
75
@ Override
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ public void testSimple() throws SQLException {
26
26
ResultSet resultSet = performQuery (postgres , "SELECT 1" );
27
27
int resultSetInt = resultSet .getInt (1 );
28
28
assertThat (resultSetInt ).as ("A basic SELECT query succeeds" ).isEqualTo (1 );
29
+ assertHasCorrectExposedAndLivenessCheckPorts (postgres );
29
30
}
30
31
}
31
32
@@ -86,4 +87,10 @@ public void testWithAdditionalUrlParamInJdbcUrl() {
86
87
assertThat (jdbcUrl ).contains ("charSet=UNICODE" );
87
88
}
88
89
}
90
+
91
+ private void assertHasCorrectExposedAndLivenessCheckPorts (PostgreSQLContainer <?> postgres ) {
92
+ assertThat (postgres .getExposedPorts ()).containsExactly (PostgreSQLContainer .POSTGRESQL_PORT );
93
+ assertThat (postgres .getLivenessCheckPortNumbers ())
94
+ .containsExactly (postgres .getMappedPort (PostgreSQLContainer .POSTGRESQL_PORT ));
95
+ }
89
96
}
Original file line number Diff line number Diff line change 9
9
import java .sql .SQLException ;
10
10
import java .time .Duration ;
11
11
import java .time .temporal .ChronoUnit ;
12
- import java .util .HashSet ;
13
12
import java .util .Set ;
14
13
15
14
/**
@@ -56,10 +55,15 @@ public PrestoContainer(final DockerImageName dockerImageName) {
56
55
addExposedPort (PRESTO_PORT );
57
56
}
58
57
58
+ /**
59
+ * @return the ports on which to check if the container is ready
60
+ * @deprecated use {@link #getLivenessCheckPortNumbers()} instead
61
+ */
59
62
@ NotNull
60
63
@ Override
64
+ @ Deprecated
61
65
protected Set <Integer > getLivenessCheckPorts () {
62
- return new HashSet <>( getMappedPort ( PRESTO_PORT ) );
66
+ return super . getLivenessCheckPorts ( );
63
67
}
64
68
65
69
@ Override
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ public void testSimple() throws Exception {
32
32
assertThat (resultSet .getString ("node_version" ))
33
33
.as ("Presto version" )
34
34
.isEqualTo (PrestoContainer .DEFAULT_TAG );
35
+ assertHasCorrectExposedAndLivenessCheckPorts (prestoSql );
35
36
}
36
37
}
37
38
}
@@ -149,4 +150,10 @@ public void testTcJdbcUri() throws Exception {
149
150
.isEqualTo (Connection .TRANSACTION_READ_UNCOMMITTED );
150
151
}
151
152
}
153
+
154
+ private void assertHasCorrectExposedAndLivenessCheckPorts (PrestoContainer <?> prestoSql ) {
155
+ assertThat (prestoSql .getExposedPorts ()).containsExactly (PrestoContainer .PRESTO_PORT );
156
+ assertThat (prestoSql .getLivenessCheckPortNumbers ())
157
+ .containsExactly (prestoSql .getMappedPort (PrestoContainer .PRESTO_PORT ));
158
+ }
152
159
}
Original file line number Diff line number Diff line change 6
6
import org .testcontainers .utility .DockerImageName ;
7
7
8
8
import java .time .Duration ;
9
- import java .util .HashSet ;
10
9
import java .util .Set ;
11
10
12
11
/**
@@ -51,10 +50,15 @@ public TiDBContainer(final DockerImageName dockerImageName) {
51
50
);
52
51
}
53
52
53
+ /**
54
+ * @return the ports on which to check if the container is ready
55
+ * @deprecated use {@link #getLivenessCheckPortNumbers()} instead
56
+ */
54
57
@ NotNull
55
58
@ Override
59
+ @ Deprecated
56
60
protected Set <Integer > getLivenessCheckPorts () {
57
- return new HashSet <>( getMappedPort ( TIDB_PORT ) );
61
+ return super . getLivenessCheckPorts ( );
58
62
}
59
63
60
64
@ Override
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ public void testSimple() throws SQLException {
21
21
22
22
int resultSetInt = resultSet .getInt (1 );
23
23
assertThat (resultSetInt ).isEqualTo (1 );
24
+ assertHasCorrectExposedAndLivenessCheckPorts (tidb );
24
25
}
25
26
}
26
27
@@ -51,4 +52,13 @@ public void testWithAdditionalUrlParamInJdbcUrl() {
51
52
tidb .stop ();
52
53
}
53
54
}
55
+
56
+ private void assertHasCorrectExposedAndLivenessCheckPorts (TiDBContainer tidb ) {
57
+ Integer tidbPort = 4000 ;
58
+ Integer restApiPort = 10080 ;
59
+
60
+ assertThat (tidb .getExposedPorts ()).containsExactlyInAnyOrder (tidbPort , restApiPort );
61
+ assertThat (tidb .getLivenessCheckPortNumbers ())
62
+ .containsExactlyInAnyOrder (tidb .getMappedPort (tidbPort ), tidb .getMappedPort (restApiPort ));
63
+ }
54
64
}
Original file line number Diff line number Diff line change 7
7
8
8
import java .sql .Connection ;
9
9
import java .sql .SQLException ;
10
- import java .util .HashSet ;
11
10
import java .util .Set ;
12
11
13
12
public class TrinoContainer extends JdbcDatabaseContainer <TrinoContainer > {
@@ -37,10 +36,15 @@ public TrinoContainer(final DockerImageName dockerImageName) {
37
36
addExposedPort (TRINO_PORT );
38
37
}
39
38
39
+ /**
40
+ * @return the ports on which to check if the container is ready
41
+ * @deprecated use {@link #getLivenessCheckPortNumbers()} instead
42
+ */
40
43
@ NotNull
41
44
@ Override
45
+ @ Deprecated
42
46
protected Set <Integer > getLivenessCheckPorts () {
43
- return new HashSet <>( getMappedPort ( TRINO_PORT ) );
47
+ return super . getLivenessCheckPorts ( );
44
48
}
45
49
46
50
@ Override
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ public void testSimple() throws Exception {
24
24
assertThat (resultSet .getString ("node_version" ))
25
25
.as ("Trino version" )
26
26
.isEqualTo (TrinoContainer .DEFAULT_TAG );
27
+ assertContainerHasCorrectExposedAndLivenessCheckPorts (trino );
27
28
}
28
29
}
29
30
}
@@ -61,4 +62,9 @@ public void testInitScript() throws Exception {
61
62
}
62
63
}
63
64
}
65
+
66
+ private void assertContainerHasCorrectExposedAndLivenessCheckPorts (TrinoContainer trino ) {
67
+ assertThat (trino .getExposedPorts ()).containsExactly (8080 );
68
+ assertThat (trino .getLivenessCheckPortNumbers ()).containsExactly (trino .getMappedPort (8080 ));
69
+ }
64
70
}
You can’t perform that action at this time.
0 commit comments