1515import  org .junit .jupiter .api .BeforeAll ;
1616import  org .junit .jupiter .api .Test ;
1717import  org .junit .jupiter .api .io .TempDir ;
18+ import  org .junit .jupiter .params .ParameterizedTest ;
19+ import  org .junit .jupiter .params .provider .EnumSource ;
1820import  org .slf4j .Logger ;
1921import  org .slf4j .LoggerFactory ;
2022import  org .testcontainers .containers .GenericContainer ;
@@ -44,6 +46,9 @@ public class JmxConnectionTest {
4446
4547  private  static  Network  network ;
4648
49+   // temporary folder for files that are copied to container 
50+   @ TempDir  private  Path  tempDir ;
51+ 
4752  @ BeforeAll 
4853  static  void  beforeAll () {
4954    network  = Network .newNetwork ();
@@ -63,32 +68,43 @@ void connectionError() {
6368    }
6469  }
6570
66-   @ Test 
67-   void  connectNoAuth () {
71+   @ ParameterizedTest 
72+   @ EnumSource 
73+   void  connectNoAuth (JmxScraperContainer .ConfigSource  configSource ) {
6874    connectionTest (
69-         app  -> app .withJmxPort (JMX_PORT ), scraper  -> scraper .withRmiServiceUrl (APP_HOST , JMX_PORT ));
75+         app  -> app .withJmxPort (JMX_PORT ),
76+         scraper  -> scraper .withRmiServiceUrl (APP_HOST , JMX_PORT ).withConfigSource (configSource ));
7077  }
7178
72-   @ Test 
73-   void  userPassword () {
79+   @ ParameterizedTest 
80+   @ EnumSource 
81+   void  userPassword (JmxScraperContainer .ConfigSource  configSource ) {
7482    String  login  = "user" ;
7583    String  pwd  = "t0p!Secret" ;
7684    connectionTest (
7785        app  -> app .withJmxPort (JMX_PORT ).withUserAuth (login , pwd ),
78-         scraper  -> scraper .withRmiServiceUrl (APP_HOST , JMX_PORT ).withUser (login ).withPassword (pwd ));
86+         scraper  ->
87+             scraper 
88+                 .withRmiServiceUrl (APP_HOST , JMX_PORT )
89+                 .withUser (login )
90+                 .withPassword (pwd )
91+                 .withConfigSource (configSource ));
7992  }
8093
81-   @ Test 
82-   void  serverSsl (@ TempDir  Path  tempDir ) {
83-     testServerSsl (tempDir , /* sslRmiRegistry= */  false );
94+   @ ParameterizedTest 
95+   @ EnumSource 
96+   void  serverSsl (JmxScraperContainer .ConfigSource  configSource ) {
97+     testServerSsl (/* sslRmiRegistry= */  false , configSource );
8498  }
8599
86-   @ Test 
87-   void  serverSslWithSslRmiRegistry (@ TempDir  Path  tempDir ) {
88-     testServerSsl (tempDir , /* sslRmiRegistry= */  true );
100+   @ ParameterizedTest 
101+   @ EnumSource 
102+   void  serverSslWithSslRmiRegistry (JmxScraperContainer .ConfigSource  configSource ) {
103+     testServerSsl (/* sslRmiRegistry= */  true , configSource );
89104  }
90105
91-   private  static  void  testServerSsl (Path  tempDir , boolean  sslRmiRegistry ) {
106+   private  void  testServerSsl (
107+       boolean  sslRmiRegistry , JmxScraperContainer .ConfigSource  configSource ) {
92108    // two keystores: 
93109    // server keystore with public/private key pair 
94110    // client trust store with certificate from server 
@@ -110,11 +126,13 @@ private static void testServerSsl(Path tempDir, boolean sslRmiRegistry) {
110126        scraper  ->
111127            (sslRmiRegistry  ? scraper .withSslRmiRegistry () : scraper )
112128                .withRmiServiceUrl (APP_HOST , JMX_PORT )
113-                 .withTrustStore (clientTrustStore ));
129+                 .withTrustStore (clientTrustStore )
130+                 .withConfigSource (configSource ));
114131  }
115132
116-   @ Test 
117-   void  serverSslClientSsl (@ TempDir  Path  tempDir ) {
133+   @ ParameterizedTest 
134+   @ EnumSource (value  = JmxScraperContainer .ConfigSource .class )
135+   void  serverSslClientSsl (JmxScraperContainer .ConfigSource  configSource ) {
118136    // Note: this could have been made simpler by relying on the fact that keystore could be used 
119137    // as a trust store, but having clear split provides also some extra clarity 
120138    // 
@@ -153,7 +171,8 @@ void serverSslClientSsl(@TempDir Path tempDir) {
153171            scraper 
154172                .withRmiServiceUrl (APP_HOST , JMX_PORT )
155173                .withKeyStore (clientKeyStore )
156-                 .withTrustStore (clientTrustStore ));
174+                 .withTrustStore (clientTrustStore )
175+                 .withConfigSource (configSource ));
157176  }
158177
159178  private  static  void  connectionTest (
0 commit comments