1616
1717package integration .container .tests ;
1818
19+ import static integration .container .ConnectionStringHelper .getDefaultProperties ;
1920import static org .junit .jupiter .api .Assertions .assertEquals ;
2021import static org .junit .jupiter .api .Assertions .assertFalse ;
2122import static org .junit .jupiter .api .Assertions .assertThrows ;
3940import java .sql .SQLException ;
4041import java .sql .Statement ;
4142import java .util .ArrayList ;
43+ import java .util .Arrays ;
44+ import java .util .List ;
4245import java .util .Properties ;
4346import java .util .concurrent .TimeUnit ;
4447import java .util .logging .Logger ;
5659import software .amazon .jdbc .wrapper .ConnectionWrapper ;
5760
5861@ TestMethodOrder (MethodOrderer .MethodName .class )
62+ @ ExtendWith (TestDriverProvider .class )
5963@ DisableOnTestFeature ({
6064 TestEnvironmentFeatures .PERFORMANCE ,
6165 TestEnvironmentFeatures .RUN_HIBERNATE_TESTS_ONLY ,
@@ -66,7 +70,6 @@ public class BasicConnectivityTests {
6670 private static final Logger LOGGER = Logger .getLogger (BasicConnectivityTests .class .getName ());
6771
6872 @ TestTemplate
69- @ ExtendWith (TestDriverProvider .class )
7073 public void test_DirectConnection (TestDriver testDriver ) throws SQLException {
7174 LOGGER .info (testDriver .toString ());
7275
@@ -105,7 +108,6 @@ public void test_DirectConnection(TestDriver testDriver) throws SQLException {
105108 }
106109
107110 @ TestTemplate
108- @ ExtendWith (TestDriverProvider .class )
109111 public void test_WrapperConnection (TestDriver testDriver ) throws SQLException {
110112 LOGGER .info (testDriver .toString ());
111113
@@ -144,7 +146,6 @@ public void test_WrapperConnection(TestDriver testDriver) throws SQLException {
144146 }
145147
146148 @ TestTemplate
147- @ ExtendWith (TestDriverProvider .class )
148149 @ EnableOnTestFeature (TestEnvironmentFeatures .NETWORK_OUTAGES_ENABLED )
149150 public void test_ProxiedDirectConnection (TestDriver testDriver ) throws SQLException {
150151 LOGGER .info (testDriver .toString ());
@@ -182,8 +183,23 @@ public void test_ProxiedDirectConnection(TestDriver testDriver) throws SQLExcept
182183 conn .close ();
183184 }
184185
186+ @ ParameterizedTest
187+ @ MethodSource ("testPluginParameters" )
188+ public void testBasicConnectivityTestWithPlugins (String plugin , String url ) throws SQLException {
189+ final Properties props = getDefaultProperties ();
190+ props .setProperty (PropertyDefinition .PLUGINS .name , plugin );
191+ LOGGER .finest ("Connecting to " + url );
192+
193+ try (Connection conn = DriverManager .getConnection (url , props );
194+ Statement stmt = conn .createStatement ();
195+ ResultSet rs = stmt .executeQuery ("SELECT 1" );
196+ ) {
197+ assertTrue (rs .next ());
198+ assertEquals (1 , rs .getInt (1 ));
199+ }
200+ }
201+
185202 @ TestTemplate
186- @ ExtendWith (TestDriverProvider .class )
187203 @ EnableOnTestFeature (TestEnvironmentFeatures .NETWORK_OUTAGES_ENABLED )
188204 public void test_ProxiedWrapperConnection () throws SQLException {
189205 LOGGER .info (TestEnvironment .getCurrent ().getCurrentDriver ().toString ());
@@ -221,16 +237,15 @@ public void test_ProxiedWrapperConnection() throws SQLException {
221237 }
222238
223239 @ TestTemplate
224- @ ExtendWith (TestDriverProvider .class )
225240 public void testSuccessOpenConnectionNoPort () throws SQLException {
226241 String url =
227242 DriverHelper .getWrapperDriverProtocol ()
228243 + TestEnvironment .getCurrent ()
229- .getInfo ()
230- .getDatabaseInfo ()
231- .getInstances ()
232- .get (0 )
233- .getHost ()
244+ .getInfo ()
245+ .getDatabaseInfo ()
246+ .getInstances ()
247+ .get (0 )
248+ .getHost ()
234249 + "/"
235250 + TestEnvironment .getCurrent ().getInfo ().getDatabaseInfo ().getDefaultDbName ()
236251 + DriverHelper .getDriverRequiredParameters ();
@@ -272,10 +287,10 @@ public void testFailedProperties(
272287 TestEnvironment .getCurrent ().setCurrentDriver (testDriver );
273288
274289 if (TestEnvironment .getCurrent ().getInfo ().getRequest ().getDatabaseEngine ()
275- == DatabaseEngine .MARIADB
290+ == DatabaseEngine .MARIADB
276291 && TestEnvironment .getCurrent ().getCurrentDriver () == TestDriver .MARIADB
277292 && TestEnvironment .getCurrent ().getInfo ().getRequest ().getDatabaseEngineDeployment ()
278- == DatabaseEngineDeployment .DOCKER
293+ == DatabaseEngineDeployment .DOCKER
279294 && StringUtils .isNullOrEmpty (username )) {
280295 // MariaDb driver uses "root" username if no username is provided. Since MariaDb database in
281296 // docker container
@@ -314,7 +329,7 @@ protected static String buildConnectionString(
314329 }
315330
316331 private static Stream <Arguments > testConnectionParameters () {
317- ArrayList <Arguments > results = new ArrayList <>();
332+ final List <Arguments > results = new ArrayList <>();
318333 for (TestDriver testDriver : TestEnvironment .getCurrent ().getAllowedTestDrivers ()) {
319334
320335 // missing connection prefix
@@ -365,9 +380,8 @@ private static Stream<Arguments> testConnectionParameters() {
365380 }
366381
367382 private static Stream <Arguments > testPropertiesParameters () {
368- ArrayList <Arguments > results = new ArrayList <>();
383+ final List <Arguments > results = new ArrayList <>();
369384 for (TestDriver testDriver : TestEnvironment .getCurrent ().getAllowedTestDrivers ()) {
370-
371385 // missing username
372386 results .add (
373387 Arguments .of (
@@ -418,4 +432,33 @@ private static Stream<Arguments> testPropertiesParameters() {
418432 }
419433 return results .stream ();
420434 }
435+
436+ private static Stream <Arguments > testPluginParameters () {
437+ final List <String > plugins = Arrays .asList (
438+ "executeTime" ,
439+ "connectTime"
440+ );
441+ final List <Arguments > results = new ArrayList <>();
442+ final TestInstanceInfo readerInstance = TestEnvironment .getCurrent ()
443+ .getInfo ()
444+ .getDatabaseInfo ()
445+ .getInstances ()
446+ .get (1 );
447+ final String writerInstanceUrl = ConnectionStringHelper .getWrapperUrl ();
448+ final String readerInstanceUrl = ConnectionStringHelper .getWrapperUrl (readerInstance );
449+ final String writerClusterUrl = ConnectionStringHelper .getWrapperClusterEndpointUrl ();
450+ final String readerClusterUrl = ConnectionStringHelper .getWrapperReaderClusterUrl ();
451+
452+ for (String plugin : plugins ) {
453+ // Connect via writer instance endpoint.
454+ results .add (Arguments .of (plugin , writerInstanceUrl ));
455+ // Connect via reader instance endpoint.
456+ results .add (Arguments .of (plugin , readerInstanceUrl ));
457+ // Connect via writer cluster endpoint.
458+ results .add (Arguments .of (plugin , writerClusterUrl ));
459+ // Connect via reader cluster endpoint.
460+ results .add (Arguments .of (plugin , readerClusterUrl ));
461+ }
462+ return results .stream ();
463+ }
421464}
0 commit comments