3434import  oracle .r2dbc .OracleR2dbcOptions ;
3535import  oracle .r2dbc .test .DatabaseConfig ;
3636import  oracle .r2dbc .util .TestContextFactory ;
37- import  org .junit .jupiter .api .Assumptions ;
3837import  org .junit .jupiter .api .Test ;
3938import  reactor .core .publisher .Flux ;
4039import  reactor .core .publisher .Mono ;
4140
41+ import  javax .sql .DataSource ;
4242import  java .io .IOException ;
4343import  java .nio .channels .ServerSocketChannel ;
4444import  java .nio .channels .SocketChannel ;
4949import  java .time .Duration ;
5050import  java .time .ZonedDateTime ;
5151import  java .util .List ;
52+ import  java .util .Map ;
5253import  java .util .Objects ;
5354import  java .util .Optional ;
5455import  java .util .Properties ;
6364import  java .util .concurrent .TimeUnit ;
6465import  java .util .concurrent .TimeoutException ;
6566import  java .util .concurrent .atomic .AtomicInteger ;
67+ import  java .util .function .Function ;
6668import  java .util .stream .Collectors ;
6769
6870import  static  io .r2dbc .spi .ConnectionFactoryOptions .CONNECT_TIMEOUT ;
7880import  static  oracle .r2dbc .test .DatabaseConfig .connectTimeout ;
7981import  static  oracle .r2dbc .test .DatabaseConfig .connectionFactoryOptions ;
8082import  static  oracle .r2dbc .test .DatabaseConfig .host ;
81- import  static  oracle .r2dbc .test .DatabaseConfig .jdbcVersion ;
8283import  static  oracle .r2dbc .test .DatabaseConfig .password ;
8384import  static  oracle .r2dbc .test .DatabaseConfig .port ;
8485import  static  oracle .r2dbc .test .DatabaseConfig .protocol ;
9899import  static  org .junit .jupiter .api .Assertions .assertThrows ;
99100import  static  org .junit .jupiter .api .Assertions .assertTrue ;
100101import  static  org .junit .jupiter .api .Assertions .fail ;
102+ import  static  org .junit .jupiter .api .Assumptions .assumeTrue ;
101103
102104/** 
103105 * Verifies that 
@@ -118,23 +120,7 @@ public void testCreateDataSource() throws SQLException {
118120    // properties. The defaultProperties variable contains properties that 
119121    // are set to default values by OracleReactiveJdbcAdapter and the Oracle 
120122    // JDBC Driver 
121-     Properties  defaultProperties  = new  Properties ();
122-     defaultProperties .setProperty (
123-       OracleConnection .CONNECTION_PROPERTY_J2EE13_COMPLIANT , "true" );
124-     defaultProperties .setProperty (
125-       OracleConnection .CONNECTION_PROPERTY_IMPLICIT_STATEMENT_CACHE_SIZE , "25" );
126-     defaultProperties .setProperty (
127-       OracleConnection .CONNECTION_PROPERTY_DEFAULT_LOB_PREFETCH_SIZE ,
128-       "1048576" );
129-     defaultProperties .setProperty (
130-       OracleConnection .CONNECTION_PROPERTY_THIN_NET_USE_ZERO_COPY_IO ,
131-       "false" );
132- 
133-     if  (jdbcVersion () == 21 ) {
134-       // Oracle JDBC no longer sets this AC property by default in 23.3 
135-       defaultProperties .setProperty (
136-         OracleConnection .CONNECTION_PROPERTY_ENABLE_AC_SUPPORT , "false" );
137-     }
123+     Properties  defaultProperties  = getJdbcDefaultProperties ();
138124
139125    // Expect only default connection properties when no extended 
140126    // options are supplied 
@@ -672,7 +658,7 @@ public void testTimezoneAsRegion() {
672658   */ 
673659  @ Test 
674660  public  void  testEmptyProtocol () {
675-     Assumptions . assumeTrue (
661+     assumeTrue (
676662      DatabaseConfig .protocol () == null ,
677663      "Test requires no PROTOCOL in config.properties" );
678664
@@ -704,6 +690,100 @@ public void testEmptyProtocol() {
704690    }
705691  }
706692
693+   @ Test 
694+   public  void  testJdbcPropertyOptions () throws  SQLException  {
695+ 
696+     // Create a map where every Option of OracleR2dbcOptions is assigned to a 
697+     // value. The values are not necessarily valid, or even of the right class 
698+     // (every option is cast to Option<String>). That's OK because this test 
699+     // just wants to make sure the values are transferred to OracleDataSource, 
700+     // and it won't actually attempt to create a connection with these values. 
701+     Map <Option <String >, String > optionValues  =
702+       OracleR2dbcOptions .options ()
703+         .stream ()
704+         .map (option  -> {
705+           @ SuppressWarnings ("unchecked" )
706+           Option <String > stringOption  = (Option <String >)option ;
707+           return  stringOption ;
708+         })
709+         .collect (Collectors .toMap (
710+           Function .identity (),
711+           option  -> "VALUE OF "  + option .name ()
712+         ));
713+ 
714+     ConnectionFactoryOptions .Builder  optionsBuilder  =
715+       ConnectionFactoryOptions .builder ();
716+     optionValues .forEach (optionsBuilder ::option );
717+ 
718+     DataSource  dataSource  =
719+       OracleReactiveJdbcAdapter .getInstance ()
720+         .createDataSource (optionsBuilder .build ());
721+     assumeTrue (dataSource .isWrapperFor (OracleDataSource .class ));
722+ 
723+     Properties  actualProperties  =
724+       dataSource .unwrap (OracleDataSource .class )
725+         .getConnectionProperties ();
726+ 
727+     Properties  expectedProperties  = getJdbcDefaultProperties ();
728+     optionValues .forEach ((option , value ) ->
729+       expectedProperties .setProperty (option .name (), value ));
730+ 
731+     expectedProperties .entrySet ()
732+         .removeAll (actualProperties .entrySet ());
733+ 
734+     // Don't expect OracleDataSource.getConnectionProperties() to have entries 
735+     // for options that Oracle R2DBC doesn't set as connection properties. 
736+     expectedProperties .entrySet ()
737+         .removeIf (entry  ->
738+           entry .getKey ().toString ().startsWith ("oracle.r2dbc." ));
739+ 
740+     // Don't expect OracleDataSource.getConnectionProperties() to have entries 
741+     // for options of security sensitive values. 
742+     expectedProperties .entrySet ()
743+       .removeIf (entry  ->
744+         entry .getKey ().toString ().toLowerCase ().contains ("password" ));
745+ 
746+     assertTrue (
747+       expectedProperties .isEmpty (),
748+       "One or more properties were not set: "  + expectedProperties );
749+   }
750+ 
751+   /** 
752+    * Returns the connection properties that will be set by default when an 
753+    * {@link OracleDataSource} is created. Tests which verify the setting of 
754+    * properties can assume these default properties will be set as well. 
755+    * 
756+    * @return Properties that OracleDataSource sets by default. 
757+    */ 
758+   private  static  Properties  getJdbcDefaultProperties () throws  SQLException  {
759+ 
760+     // Start with any properties that JDBC will set by default. For example, the 
761+     // 21 driver would set CONNECTION_PROPERTY_ENABLE_AC_SUPPORT="false" by 
762+     // default. 
763+     Properties  defaultProperties  =
764+       new  oracle .jdbc .datasource .impl .OracleDataSource ()
765+         .getConnectionProperties ();
766+ 
767+     if  (defaultProperties  == null )
768+       defaultProperties  = new  Properties ();
769+ 
770+     // Set the properties that Oracle R2DBC will set by default 
771+     // Not referencing the deprecated 
772+     // OracleConnection.CONNECTION_PROPERTY_J2EE13_COMPLIANT field, just in case 
773+     // it  gets removed in a future release of Oracle JDBC. 
774+     defaultProperties .setProperty ("oracle.jdbc.J2EE13Compliant" , "true" );
775+     defaultProperties .setProperty (
776+       OracleConnection .CONNECTION_PROPERTY_IMPLICIT_STATEMENT_CACHE_SIZE , "25" );
777+     defaultProperties .setProperty (
778+       OracleConnection .CONNECTION_PROPERTY_DEFAULT_LOB_PREFETCH_SIZE ,
779+       "1048576" );
780+     defaultProperties .setProperty (
781+       OracleConnection .CONNECTION_PROPERTY_THIN_NET_USE_ZERO_COPY_IO ,
782+       "false" );
783+ 
784+     return  defaultProperties ;
785+   }
786+ 
707787  /** 
708788   * Returns an Oracle Net Descriptor having the values configured by 
709789   * {@link DatabaseConfig} 
0 commit comments