File tree Expand file tree Collapse file tree 3 files changed +19
-51
lines changed
jdbc-test/src/main/java/org/testcontainers/db
postgresql/src/test/java/org/testcontainers Expand file tree Collapse file tree 3 files changed +19
-51
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,21 @@ protected void performSelectFooBarQuery(final JdbcDatabaseContainer<?> container
6565 );
6666 }
6767
68+ protected void performSelectMaxConnectionsQuery (final JdbcDatabaseContainer <?> container ) throws SQLException {
69+ performQuery (
70+ container ,
71+ "SELECT current_setting('max_connections')" ,
72+ resultSet -> {
73+ Assertions
74+ .assertThatNoException ()
75+ .isThrownBy (() -> {
76+ String result = resultSet .getString (1 );
77+ Assertions .assertThat (result ).as ("max_connections should be overridden" ).isEqualTo ("42" );
78+ });
79+ }
80+ );
81+ }
82+
6883 protected DataSource getDataSource (final JdbcDatabaseContainer <?> container ) {
6984 HikariConfig hikariConfig = new HikariConfig ();
7085 hikariConfig .setJdbcUrl (container .getJdbcUrl ());
Original file line number Diff line number Diff line change 11package org .testcontainers .containers ;
22
3- import org .assertj .core .api .Assertions ;
43import org .junit .jupiter .api .Test ;
54import org .testcontainers .db .AbstractContainerDatabaseTest ;
65
76import java .sql .SQLException ;
87
9- import static org .assertj .core .api .Assertions .assertThat ;
10-
118class TimescaleDBContainerTest extends AbstractContainerDatabaseTest {
129
1310 @ Test
@@ -28,18 +25,7 @@ void testCommandOverride() throws SQLException {
2825 ) {
2926 postgres .start ();
3027
31- performQuery (
32- (JdbcDatabaseContainer <?>) postgres ,
33- "SELECT current_setting('max_connections')" ,
34- resultSet -> {
35- Assertions
36- .assertThatNoException ()
37- .isThrownBy (() -> {
38- String result = resultSet .getString (1 );
39- assertThat (result ).as ("max_connections should be overridden" ).isEqualTo ("42" );
40- });
41- }
42- );
28+ performSelectMaxConnectionsQuery ((JdbcDatabaseContainer <?>) postgres );
4329 }
4430 }
4531
@@ -53,18 +39,7 @@ void testUnsetCommand() throws SQLException {
5339 ) {
5440 postgres .start ();
5541
56- performQuery (
57- (JdbcDatabaseContainer <?>) postgres ,
58- "SELECT current_setting('max_connections')" ,
59- resultSet -> {
60- Assertions
61- .assertThatNoException ()
62- .isThrownBy (() -> {
63- String result = resultSet .getString (1 );
64- assertThat (result ).as ("max_connections should not be overridden" ).isNotEqualTo ("42" );
65- });
66- }
67- );
42+ performSelectMaxConnectionsQuery ((JdbcDatabaseContainer <?>) postgres );
6843 }
6944 }
7045
Original file line number Diff line number Diff line change @@ -40,18 +40,7 @@ void testCommandOverride() throws SQLException {
4040 ) {
4141 postgres .start ();
4242
43- performQuery (
44- postgres ,
45- "SELECT current_setting('max_connections')" ,
46- resultSet -> {
47- Assertions
48- .assertThatNoException ()
49- .isThrownBy (() -> {
50- String result = resultSet .getString (1 );
51- assertThat (result ).as ("max_connections should be overridden" ).isEqualTo ("42" );
52- });
53- }
54- );
43+ performSelectMaxConnectionsQuery (postgres );
5544 }
5645 }
5746
@@ -64,18 +53,7 @@ void testUnsetCommand() throws SQLException {
6453 ) {
6554 postgres .start ();
6655
67- performQuery (
68- postgres ,
69- "SELECT current_setting('max_connections')" ,
70- resultSet -> {
71- Assertions
72- .assertThatNoException ()
73- .isThrownBy (() -> {
74- String result = resultSet .getString (1 );
75- assertThat (result ).as ("max_connections should not be overridden" ).isNotEqualTo ("42" );
76- });
77- }
78- );
56+ performSelectMaxConnectionsQuery (postgres );
7957 }
8058 }
8159
You can’t perform that action at this time.
0 commit comments