2626
2727import io .r2dbc .spi .*;
2828import io .r2dbc .spi .test .TestKit ;
29- import oracle .r2dbc . util . OracleTestKitSupport ;
29+ import oracle .jdbc . datasource . OracleDataSource ;
3030import org .junit .jupiter .api .Disabled ;
3131import org .junit .jupiter .api .Test ;
3232import org .springframework .jdbc .core .JdbcOperations ;
33+ import org .springframework .jdbc .core .JdbcTemplate ;
3334import org .springframework .jdbc .core .support .AbstractLobCreatingPreparedStatementCallback ;
3435import org .springframework .jdbc .support .lob .DefaultLobHandler ;
3536import org .springframework .jdbc .support .lob .LobCreator ;
4647import java .util .Collection ;
4748import java .util .function .Function ;
4849
49- import static org .junit .jupiter .api .Assertions .assertThrows ;
50+ import static io .r2dbc .spi .ConnectionFactoryOptions .DATABASE ;
51+ import static io .r2dbc .spi .ConnectionFactoryOptions .DRIVER ;
52+ import static io .r2dbc .spi .ConnectionFactoryOptions .HOST ;
53+ import static io .r2dbc .spi .ConnectionFactoryOptions .PASSWORD ;
54+ import static io .r2dbc .spi .ConnectionFactoryOptions .PORT ;
55+ import static io .r2dbc .spi .ConnectionFactoryOptions .USER ;
56+ import static oracle .r2dbc .DatabaseConfig .host ;
57+ import static oracle .r2dbc .DatabaseConfig .password ;
58+ import static oracle .r2dbc .DatabaseConfig .port ;
59+ import static oracle .r2dbc .DatabaseConfig .serviceName ;
60+ import static oracle .r2dbc .DatabaseConfig .user ;
5061
5162/**
5263 * <p>
7384 * @author harayuanwang, Michael-A-McMahon
7485 * @since 0.1.0
7586 */
76- public class OracleTestKit
77- extends OracleTestKitSupport implements TestKit <Integer > {
87+ public class OracleTestKit implements TestKit <Integer > {
88+
89+ private final JdbcOperations jdbcOperations ;
90+ {
91+ try {
92+ OracleDataSource dataSource = new oracle .jdbc .pool .OracleDataSource ();
93+ dataSource .setURL (String .format ("jdbc:oracle:thin:@%s:%d/%s" ,
94+ host (), port (), serviceName ()));
95+ dataSource .setUser (user ());
96+ dataSource .setPassword (password ());
97+ this .jdbcOperations = new JdbcTemplate (dataSource );
98+ }
99+ catch (SQLException sqlException ) {
100+ throw new RuntimeException (sqlException );
101+ }
102+ }
78103
79- static <T > Mono <T > close (Connection connection ) {
80- return Mono .from (connection
81- .close ())
82- .then (Mono .empty ());
104+ private final ConnectionFactory connectionFactory ;
105+ {
106+ connectionFactory = ConnectionFactories .get (
107+ ConnectionFactoryOptions .builder ()
108+ .option (DRIVER , "oracle" )
109+ .option (DATABASE , serviceName ())
110+ .option (HOST , host ())
111+ .option (PORT , port ())
112+ .option (PASSWORD , password ())
113+ .option (USER , user ())
114+ .build ());
115+ }
116+
117+ public JdbcOperations getJdbcOperations () {
118+ return jdbcOperations ;
83119 }
84120
85121 @ Override
@@ -108,17 +144,6 @@ public Integer getIdentifier(int index) {
108144 return index ;
109145 }
110146
111- @ Override
112- public JdbcOperations getJdbcOperations () {
113- JdbcOperations jdbcOperations = CONFIG .getJDBCOperations ();
114-
115- if (jdbcOperations == null ) {
116- throw new IllegalStateException ("JdbcOperations not yet initialized" );
117- }
118-
119- return jdbcOperations ;
120- }
121-
122147 /**
123148 * {@inheritDoc}
124149 * <p>
@@ -402,7 +427,6 @@ protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQL
402427 .verifyComplete ();
403428 }
404429
405-
406430 @ Disabled ("Compound statements are not supported by Oracle Database" )
407431 @ Test
408432 @ Override
@@ -418,6 +442,11 @@ public void savePoint() {}
418442 @ Override
419443 public void savePointStartsTransaction () {}
420444
445+ static <T > Mono <T > close (Connection connection ) {
446+ return Mono .from (connection .close ())
447+ .then (Mono .empty ());
448+ }
449+
421450}
422451
423452/*
0 commit comments