File tree Expand file tree Collapse file tree 4 files changed +21
-45
lines changed
jdbc-test/src/main/java/org/testcontainers/db
mariadb/src/test/java/org/testcontainers/mariadb
mysql/src/test/java/org/testcontainers/mysql Expand file tree Collapse file tree 4 files changed +21
-45
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,24 @@ protected void performSelectMaxConnectionsQuery(final JdbcDatabaseContainer<?> c
8080 );
8181 }
8282
83+ protected void performSelectVersionQuery (final JdbcDatabaseContainer <?> container ) throws SQLException {
84+ performQuery (
85+ container ,
86+ "SELECT VERSION()" ,
87+ resultSet -> {
88+ Assertions
89+ .assertThatNoException ()
90+ .isThrownBy (() -> {
91+ String resultSetString = resultSet .getString (1 );
92+ Assertions
93+ .assertThat (resultSetString )
94+ .as ("The database version can be set using a container rule parameter" )
95+ .startsWith ("10.3.39" );
96+ });
97+ }
98+ );
99+ }
100+
83101 protected DataSource getDataSource (final JdbcDatabaseContainer <?> container ) {
84102 HikariConfig hikariConfig = new HikariConfig ();
85103 hikariConfig .setJdbcUrl (container .getJdbcUrl ());
Original file line number Diff line number Diff line change @@ -42,20 +42,7 @@ void testSpecificVersion() throws SQLException {
4242 ) {
4343 mariadbOldVersion .start ();
4444
45- performQuery (
46- mariadbOldVersion ,
47- "SELECT VERSION()" ,
48- resultSet -> {
49- Assertions
50- .assertThatNoException ()
51- .isThrownBy (() -> {
52- String resultSetString = resultSet .getString (1 );
53- assertThat (resultSetString )
54- .as ("The database version can be set using a container rule parameter" )
55- .startsWith ("10.3.39" );
56- });
57- }
58- );
45+ performSelectOneQuery (mariadbOldVersion );
5946 }
6047 }
6148
Original file line number Diff line number Diff line change 11package org .testcontainers .mysql ;
22
3- import org .assertj .core .api .Assertions ;
43import org .junit .jupiter .params .ParameterizedTest ;
54import org .junit .jupiter .params .provider .MethodSource ;
65import org .testcontainers .MySQLTestImages ;
98
109import java .sql .SQLException ;
1110
12- import static org .assertj .core .api .Assertions .assertThat ;
13-
1411class MultiVersionMySQLTest extends AbstractContainerDatabaseTest {
1512
1613 public static DockerImageName [] params () {
@@ -27,20 +24,7 @@ public static DockerImageName[] params() {
2724 void versionCheckTest (DockerImageName dockerImageName ) throws SQLException {
2825 try (MySQLContainer mysql = new MySQLContainer (dockerImageName )) {
2926 mysql .start ();
30- performQuery (
31- mysql ,
32- "SELECT VERSION()" ,
33- resultSet -> {
34- Assertions
35- .assertThatNoException ()
36- .isThrownBy (() -> {
37- final String resultSetString = resultSet .getString (1 );
38- assertThat (resultSetString )
39- .as ("The database version can be set using a container rule parameter" )
40- .isEqualTo (dockerImageName .getVersionPart ());
41- });
42- }
43- );
27+ performSelectVersionQuery (mysql );
4428 }
4529 }
4630}
Original file line number Diff line number Diff line change @@ -57,20 +57,7 @@ void testSpecificVersion() throws SQLException {
5757 ) {
5858 mysqlOldVersion .start ();
5959
60- performQuery (
61- mysqlOldVersion ,
62- "SELECT VERSION()" ,
63- resultSet -> {
64- Assertions
65- .assertThatNoException ()
66- .isThrownBy (() -> {
67- String resultSetString = resultSet .getString (1 );
68- assertThat (resultSetString )
69- .as ("The database version can be set using a container rule parameter" )
70- .startsWith ("8.0" );
71- });
72- }
73- );
60+ performSelectVersionQuery (mysqlOldVersion );
7461 }
7562 }
7663
You can’t perform that action at this time.
0 commit comments