@@ -158,7 +158,7 @@ public void testHttpProxyDefaultSSL() {
158158
159159 @ Test
160160 public void testWithAllowSelfSigned () {
161- System . out . println ("Scenario: Testing with AllowSelfSignedCerts=1" );
161+ LOGGER . info ("Scenario: Testing with AllowSelfSignedCerts=1" );
162162
163163 // Save original system properties
164164 String originalTrustStore = System .getProperty ("javax.net.ssl.trustStore" );
@@ -191,14 +191,13 @@ public void testWithAllowSelfSigned() {
191191 url1 += "SSLTrustStoreType=JKS;" ;
192192
193193 try {
194- System . out . println ("\n \n ==== TEST 1: Connection with empty trust store ====" );
195- System . out . println ("URL: " + url1 );
196- System . out . println ("Trust store: " + System .getProperty ("javax.net.ssl.trustStore" ));
194+ LOGGER . info ("\n \n ==== TEST 1: Connection with empty trust store ====" );
195+ LOGGER . info ("URL: " + url1 );
196+ LOGGER . info ("Trust store: " + System .getProperty ("javax.net.ssl.trustStore" ));
197197 verifyConnect (url1 );
198198 fail ("Connection with empty trust store should have failed" );
199199 } catch (Exception e ) {
200- System .out .println (
201- "Connection correctly failed with empty trust store: " + e .getMessage ());
200+ LOGGER .info ("Connection correctly failed with empty trust store: " + e .getMessage ());
202201 }
203202
204203 // Test 2: Non-existent trust store - should fail with clear error
@@ -208,19 +207,19 @@ public void testWithAllowSelfSigned() {
208207 url2 += "SSLTrustStore=" + nonExistentPath + ";" ;
209208
210209 try {
211- System . out . println ("\n \n ==== TEST 2: Connection with non-existent trust store ====" );
212- System . out . println ("URL: " + url2 );
213- System . out . println ("Trust store: " + nonExistentPath );
210+ LOGGER . info ("\n \n ==== TEST 2: Connection with non-existent trust store ====" );
211+ LOGGER . info ("URL: " + url2 );
212+ LOGGER . info ("Trust store: " + nonExistentPath );
214213 verifyConnect (url2 );
215214 fail ("Connection with non-existent trust store should have failed" );
216215 } catch (SQLException e ) {
217- System . out . println (
216+ LOGGER . info (
218217 "Connection correctly failed with non-existent trust store: " + e .getMessage ());
219218 assertTrue (
220219 e .getMessage ().contains ("trust store" ),
221220 "Error message should mention trust store issues" );
222221 } catch (Exception e ) {
223- System . out . println (
222+ LOGGER . info (
224223 "Connection correctly failed with non-existent trust store: " + e .getMessage ());
225224 assertTrue (
226225 e .getMessage ().contains ("trust store" ) || e .getMessage ().contains ("truststore" ),
@@ -233,13 +232,13 @@ public void testWithAllowSelfSigned() {
233232 url3 += ";LogLevel=TRACE;" ;
234233
235234 try {
236- System . out . println ("\n \n ==== TEST 3: Connection with AllowSelfSignedCerts=1 ====" );
237- System . out . println ("URL: " + url3 );
238- System . out . println ("Trust store: " + System .getProperty ("javax.net.ssl.trustStore" ));
235+ LOGGER . info ("\n \n ==== TEST 3: Connection with AllowSelfSignedCerts=1 ====" );
236+ LOGGER . info ("URL: " + url3 );
237+ LOGGER . info ("Trust store: " + System .getProperty ("javax.net.ssl.trustStore" ));
239238 verifyConnect (url3 );
240- System . out . println ("Connection succeeded with AllowSelfSignedCerts=1 as expected" );
239+ LOGGER . info ("Connection succeeded with AllowSelfSignedCerts=1 as expected" );
241240 } catch (Exception e ) {
242- System . out . println ("Connection failed with AllowSelfSignedCerts=1: " + e .getMessage ());
241+ LOGGER . info ("Connection failed with AllowSelfSignedCerts=1: " + e .getMessage ());
243242 fail ("Connection with AllowSelfSignedCerts=1 should have succeeded: " + e .getMessage ());
244243 }
245244 }
@@ -343,16 +342,16 @@ public void testIgnoreSystemPropertyWhenUseSystemTrustStoreDisabled() {
343342
344343 @ Test
345344 public void testWithCustomTrustStore () {
346- System . out . println ("Scenario: Testing with custom trust store" );
345+ LOGGER . info ("Scenario: Testing with custom trust store" );
347346 // First verify the trust store exists and is readable
348347 if (trustStorePath == null || trustStorePath .isEmpty ()) {
349- System . out . println ("Skipping custom trust store test - no trust store path provided" );
348+ LOGGER . info ("Skipping custom trust store test - no trust store path provided" );
350349 return ;
351350 }
352351
353352 File trustStoreFile = new File (trustStorePath );
354353 if (!trustStoreFile .exists () || !trustStoreFile .canRead ()) {
355- System . out . println (
354+ LOGGER . info (
356355 "Skipping custom trust store test - trust store does not exist or is not readable: "
357356 + trustStorePath );
358357 return ;
@@ -365,15 +364,15 @@ public void testWithCustomTrustStore() {
365364 ks .load (fis , trustStorePassword .toCharArray ());
366365 int entriesCount = java .util .Collections .list (ks .aliases ()).size ();
367366
368- System . out . println ("Trust store contains " + entriesCount + " entries" );
367+ LOGGER . info ("Trust store contains " + entriesCount + " entries" );
369368 assertTrue (entriesCount > 0 , "Trust store must contain at least one certificate" );
370369
371370 // Check if at least one entry is a trusted certificate entry
372371 boolean hasTrustedCert = false ;
373372 for (String alias : java .util .Collections .list (ks .aliases ())) {
374373 if (ks .isCertificateEntry (alias )) {
375374 hasTrustedCert = true ;
376- System . out . println ("Found trusted certificate: " + alias );
375+ LOGGER . info ("Found trusted certificate: " + alias );
377376 break ;
378377 }
379378 }
@@ -390,30 +389,30 @@ public void testWithCustomTrustStore() {
390389 try {
391390 // Try connecting with custom trust store
392391 verifyConnect (url );
393- System . out . println ("Connection established using custom trust store validation" );
392+ LOGGER . info ("Connection established using custom trust store validation" );
394393 } catch (Exception e ) {
395- System . out . println (
394+ LOGGER . info (
396395 "Connection failed with custom trust store, trying with AllowSelfSignedCerts=1: "
397396 + e .getMessage ());
398397 String fallbackUrl = buildJdbcUrl (thrift , true , false , true , false , false );
399398 fallbackUrl += ";LogLevel=TRACE;" ;
400399 try {
401400 verifyConnect (fallbackUrl );
402- System . out . println ("Connection succeeded with AllowSelfSignedCerts=1 fallback" );
401+ LOGGER . info ("Connection succeeded with AllowSelfSignedCerts=1 fallback" );
403402 } catch (Exception e2 ) {
404403 fail ("Custom trust store test failed with both approaches: " + e2 .getMessage ());
405404 }
406405 }
407406 }
408407 } catch (Exception e ) {
409- System . out . println ("Custom trust store test setup failed: " + e .getMessage ());
408+ LOGGER . info ("Custom trust store test setup failed: " + e .getMessage ());
410409 // Instead of failing the test, try with AllowSelfSignedCerts=1
411410 for (boolean thrift : new boolean [] {true }) {
412411 String fallbackUrl = buildJdbcUrl (thrift , true , false , true , false , false );
413412 fallbackUrl += ";LogLevel=TRACE;" ;
414413 try {
415414 verifyConnect (fallbackUrl );
416- System . out . println ("Fallback connection succeeded with AllowSelfSignedCerts=1" );
415+ LOGGER . info ("Fallback connection succeeded with AllowSelfSignedCerts=1" );
417416 return ; // Test passes with fallback
418417 } catch (Exception e2 ) {
419418 // Now we can fail the test as both approaches failed
@@ -425,7 +424,7 @@ public void testWithCustomTrustStore() {
425424
426425 @ Test
427426 public void testWithSystemProperties () {
428- System . out . println ("Scenario: Using system properties for SSL configuration" );
427+ LOGGER . info ("Scenario: Using system properties for SSL configuration" );
429428
430429 String originalTrustStore = System .getProperty ("javax.net.ssl.trustStore" );
431430 String originalTrustStorePassword = System .getProperty ("javax.net.ssl.trustStorePassword" );
@@ -434,35 +433,34 @@ public void testWithSystemProperties() {
434433 try {
435434 // First check if trust store exists
436435 if (trustStorePath == null || !new File (trustStorePath ).exists ()) {
437- System .out .println (
438- "Skipping system properties test - trust store not found: " + trustStorePath );
436+ LOGGER .info ("Skipping system properties test - trust store not found: " + trustStorePath );
439437 return ;
440438 }
441439
442440 System .setProperty ("javax.net.ssl.trustStore" , trustStorePath );
443441 System .setProperty ("javax.net.ssl.trustStorePassword" , trustStorePassword );
444442 System .setProperty ("javax.net.ssl.trustStoreType" , "JKS" );
445443
446- System . out . println ("Trust store path: " + System .getProperty ("javax.net.ssl.trustStore" ));
447- System . out . println ("Trust store exists: " + new java .io .File (trustStorePath ).exists ());
448- System . out . println (
444+ LOGGER . info ("Trust store path: " + System .getProperty ("javax.net.ssl.trustStore" ));
445+ LOGGER . info ("Trust store exists: " + new java .io .File (trustStorePath ).exists ());
446+ LOGGER . info (
449447 "Trust store password set: "
450448 + (System .getProperty ("javax.net.ssl.trustStorePassword" ) != null ));
451- System . out . println ("Trust store type: " + System .getProperty ("javax.net.ssl.trustStoreType" ));
449+ LOGGER . info ("Trust store type: " + System .getProperty ("javax.net.ssl.trustStoreType" ));
452450
453451 // Use AllowSelfSignedCerts as fallback mechanism
454452 for (boolean thrift : new boolean [] {true , false }) {
455453 try {
456454 String url = buildJdbcUrl (thrift , false , false , false , false , false );
457455 verifyConnect (url );
458456 } catch (Exception e ) {
459- System . out . println (
457+ LOGGER . info (
460458 "Connection with system properties failed, trying with AllowSelfSignedCerts=1: "
461459 + e .getMessage ());
462460 String fallbackUrl = buildJdbcUrl (thrift , false , false , true , false , false );
463461 try {
464462 verifyConnect (fallbackUrl );
465- System . out . println ("Successfully connected with AllowSelfSignedCerts=1 fallback" );
463+ LOGGER . info ("Successfully connected with AllowSelfSignedCerts=1 fallback" );
466464 } catch (Exception e2 ) {
467465 fail (
468466 "Both system properties and AllowSelfSignedCerts approaches failed: "
@@ -493,7 +491,7 @@ public void testWithSystemProperties() {
493491
494492 @ Test
495493 public void testEmptyTrustStore () {
496- System . out . println ("Scenario: Testing with manually created empty trust store" );
494+ LOGGER . info ("Scenario: Testing with manually created empty trust store" );
497495
498496 try {
499497 // Create an empty trust store file
@@ -518,8 +516,7 @@ public void testEmptyTrustStore() {
518516 verifyConnect (url );
519517 fail ("Connection with empty trust store should have failed" );
520518 } catch (Exception e ) {
521- System .out .println (
522- "Connection correctly failed with empty trust store: " + e .getMessage ());
519+ LOGGER .info ("Connection correctly failed with empty trust store: " + e .getMessage ());
523520 // Expect an error message about no trust anchors
524521 assertTrue (
525522 e .getMessage ().contains ("no trust anchors" )
@@ -535,7 +532,7 @@ public void testEmptyTrustStore() {
535532
536533 @ Test
537534 public void testNonExistentTrustStore () {
538- System . out . println ("Scenario: Testing with non-existent trust store" );
535+ LOGGER . info ("Scenario: Testing with non-existent trust store" );
539536
540537 String nonExistentPath = "/path/to/nonexistent/truststore.jks" ;
541538 for (boolean thrift : new boolean [] {true , false }) {
@@ -547,8 +544,7 @@ public void testNonExistentTrustStore() {
547544 verifyConnect (url );
548545 fail ("Connection with non-existent trust store should have failed" );
549546 } catch (Exception e ) {
550- System .out .println (
551- "Connection correctly failed with non-existent trust store: " + e .getMessage ());
547+ LOGGER .info ("Connection correctly failed with non-existent trust store: " + e .getMessage ());
552548 assertTrue (
553549 e .getMessage ().contains ("trust store" ) || e .getMessage ().contains ("truststore" ),
554550 "Error message should mention trust store issues" );
@@ -562,7 +558,7 @@ public void testNonExistentTrustStore() {
562558 */
563559 @ Test
564560 public void testNoCustomTrustStoreWithUseSystemTrustStoreFalse () {
565- System . out . println ("Scenario: No custom trust store with UseSystemTrustStore=false" );
561+ LOGGER . info ("Scenario: No custom trust store with UseSystemTrustStore=false" );
566562
567563 // This test simply verifies that when UseSystemTrustStore=false and no custom trust store
568564 // is provided, the connection still works (falls back to JDK default trust store)
@@ -571,17 +567,15 @@ public void testNoCustomTrustStoreWithUseSystemTrustStoreFalse() {
571567 url += ";UseSystemTrustStore=0;" ; // Explicitly set to false
572568
573569 try {
574- System . out . println (
570+ LOGGER . info (
575571 "\n ==== Testing connection with UseSystemTrustStore=0 and no custom trust store ====" );
576- System . out . println ("URL: " + url );
572+ LOGGER . info ("URL: " + url );
577573 verifyConnect (url );
578- System .out .println (
579- "Connection succeeded using default trust store with UseSystemTrustStore=0" );
574+ LOGGER .info ("Connection succeeded using default trust store with UseSystemTrustStore=0" );
580575 } catch (Exception e ) {
581576 // Don't fail the test, just log the issue
582- System .out .println (
583- "Connection attempt with UseSystemTrustStore=0 failed: " + e .getMessage ());
584- System .out .println (
577+ LOGGER .info ("Connection attempt with UseSystemTrustStore=0 failed: " + e .getMessage ());
578+ LOGGER .info (
585579 "This may be expected if the default trust store doesn't have the required certificates" );
586580 }
587581 }
@@ -590,17 +584,17 @@ public void testNoCustomTrustStoreWithUseSystemTrustStoreFalse() {
590584 /** Test that verifies custom trust store takes precedence over system property trust store. */
591585 @ Test
592586 public void testCustomTrustStorePrecedence () {
593- System . out . println ("Scenario: Custom trust store takes precedence over system property" );
587+ LOGGER . info ("Scenario: Custom trust store takes precedence over system property" );
594588
595589 // Skip if we don't have a valid trust store
596590 if (trustStorePath == null || trustStorePath .isEmpty ()) {
597- System . out . println ("Skipping this test - no trust store path provided" );
591+ LOGGER . info ("Skipping this test - no trust store path provided" );
598592 return ;
599593 }
600594
601595 File trustStoreFile = new File (trustStorePath );
602596 if (!trustStoreFile .exists () || !trustStoreFile .canRead ()) {
603- System . out . println (
597+ LOGGER . info (
604598 "Skipping this test - trust store does not exist or is not readable: " + trustStorePath );
605599 return ;
606600 }
@@ -620,18 +614,15 @@ public void testCustomTrustStorePrecedence() {
620614 String url = buildJdbcUrl (thrift , false , false , false , true , true );
621615
622616 try {
623- System . out . println ("\n ==== Testing custom trust store precedence ====" );
624- System . out . println ("URL: " + url );
625- System . out . println (
617+ LOGGER . info ("\n ==== Testing custom trust store precedence ====" );
618+ LOGGER . info ("URL: " + url );
619+ LOGGER . info (
626620 "System property trust store: " + System .getProperty ("javax.net.ssl.trustStore" ));
627- System . out . println ("Custom trust store: " + trustStorePath );
621+ LOGGER . info ("Custom trust store: " + trustStorePath );
628622 verifyConnect (url );
629- System .out .println (
630- "Connection succeeded - custom trust store took precedence as expected" );
623+ LOGGER .info ("Connection succeeded - custom trust store took precedence as expected" );
631624 } catch (Exception e ) {
632- // This test only verifies the behavior if the connection would normally succeed
633- // If it fails for other reasons, that's fine
634- System .out .println (
625+ LOGGER .info (
635626 "Connection failed, but not necessarily due to trust store precedence: "
636627 + e .getMessage ());
637628 }
0 commit comments