Skip to content

Commit ad2d023

Browse files
DB 19 test compatiblity and README updates
1 parent 3dec13d commit ad2d023

7 files changed

+68
-40
lines changed

README.md

+18-13
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ Project Reactor, RxJava, and Akka Streams.
2525
[Reactive Streams Specification v1.0.3](https://github.com/reactive-streams/reactive-streams-jvm/blob/v1.0.3/README.md)
2626

2727
# About This Version
28-
The 1.2.0 release Oracle R2DBC implements version 1.0.0.RELEASE of the R2DBC SPI.
28+
The 1.3.0 release Oracle R2DBC implements version 1.0.0.RELEASE of the R2DBC SPI.
2929

3030
New features in this release:
31-
- [Pipelined Operations](https://github.com/oracle/oracle-r2dbc/pull/145)
32-
- [Vector Data Type](https://github.com/oracle/oracle-r2dbc/pull/146)
33-
- [Options for Fetch Size and Proxy Authentication](https://github.com/oracle/oracle-r2dbc/pull/155)
31+
- [Pipelining](#pipelining)
32+
- [Vector Data Type](#vector)
33+
- [Fetch Size and Proxy Authentication Options](https://github.com/oracle/oracle-r2dbc/pull/155)
3434

3535
Updated dependencies:
3636
- Updated Oracle JDBC from 21.11.0.0 to 23.6.0.24.10
@@ -369,23 +369,28 @@ If this option is not configured, then the common
369369
A subset of Oracle JDBC's connection properties are defined as `Option`
370370
constants in the
371371
[OracleR2dbcOptions](src/main/java/oracle/r2dbc/OracleR2dbcOptions.java) class.
372-
These connection properties may be configured as options having the same
373-
name as the Oracle JDBC connection property, and may have `CharSequence` value
374-
types.
375-
376-
For example, the following URL configures the `oracle.net.wallet_location`
377-
connection property:
372+
If an Oracle JDBC property is not defined as an `Option`, in most cases it can
373+
instead be configured by a
374+
[connection properties file](https://docs.oracle.com/en/database/oracle/oracle-database/23/jajdb/oracle/jdbc/OracleConnection.html#CONNECTION_PROPERTY_CONFIG_FILE)
375+
or a JVM system property instead.
376+
[Pull requests to add missing options](https://github.com/oracle/oracle-r2dbc/pull/124)
377+
are also a welcome addition.
378+
379+
When a connection property is defined in `OracleR2dbcOptions`, it may be
380+
configured as an R2DBC URL parameter. For example, the following URL configures
381+
the `oracle.net.wallet_location` connection property:
378382
```
379383
r2dbcs:oracle://db.host.example.com:1522/db.service.name?oracle.net.wallet_location=/path/to/wallet/
380384
```
381-
The same property can also be configured programmatically:
385+
And, the `OracleR2dbcOptions` constants can be used in programmatic
386+
configuration:
382387
```java
383388
ConnectionFactoryOptions.builder()
384389
.option(OracleR2dbcOptions.TLS_WALLET_LOCATION, "/path/to/wallet")
385390
```
386391

387-
The next sections list Oracle JDBC connection properties which are supported by
388-
Oracle R2DBC.
392+
All Oracle JDBC connection properties defined in `OracleR2dbcOptions` are listed
393+
in the next sections.
389394

390395
##### TLS/SSL Connection Properties
391396
- [oracle.net.tns_admin](https://docs.oracle.com/en/database/oracle/oracle-database/23/jajdb/oracle/jdbc/OracleConnection.html?is-external=true#CONNECTION_PROPERTY_TNS_ADMIN)

src/test/java/oracle/r2dbc/impl/OracleConnectionFactoryProviderImplTest.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import reactor.core.publisher.Flux;
3434
import reactor.core.publisher.Mono;
3535

36-
import java.util.concurrent.TimeoutException;
3736
import java.util.function.Supplier;
3837

3938
import static io.r2dbc.spi.ConnectionFactoryOptions.DATABASE;
@@ -56,7 +55,7 @@
5655
/**
5756
* Verifies that
5857
* {@link OracleConnectionFactoryProviderImpl} implements behavior that
59-
* is specified in it's class and method level javadocs.
58+
* is specified in its class and method level javadocs.
6059
*/
6160
public class OracleConnectionFactoryProviderImplTest {
6261

@@ -216,7 +215,7 @@ public void testSupplierOptionNull() {
216215
Supplier<Integer> portSupplier = DatabaseConfig::port;
217216
Supplier<String> databaseSupplier = DatabaseConfig::serviceName;
218217
Supplier<String> userSupplier = DatabaseConfig::user;
219-
TestSupplier<CharSequence> passwordSupplier = new TestSupplier(password());
218+
TestSupplier<CharSequence> passwordSupplier = new TestSupplier<>(password());
220219

221220
ConnectionFactoryOptions connectionFactoryOptions =
222221
connectionFactoryOptions()
@@ -326,7 +325,7 @@ public void testPublisherOptionNull() {
326325
Publisher<Integer> portPublisher = Mono.fromSupplier(DatabaseConfig::port);
327326
Publisher<String> databasePublisher = Mono.fromSupplier(DatabaseConfig::serviceName);
328327
Publisher<String> userPublisher = Mono.fromSupplier(DatabaseConfig::user);
329-
TestSupplier<CharSequence> passwordPublisher = new TestSupplier(password());
328+
TestSupplier<CharSequence> passwordPublisher = new TestSupplier<>(password());
330329

331330
ConnectionFactoryOptions connectionFactoryOptions =
332331
connectionFactoryOptions()

src/test/java/oracle/r2dbc/impl/OracleResultImplTest.java

+14-14
Original file line numberDiff line numberDiff line change
@@ -640,10 +640,10 @@ public void testOracleR2dbcWarning() {
640640
Connection connection = awaitOne(sharedConnection());
641641
try {
642642

643-
// Expect a warning for forcing a view that references a non-existent
643+
// Expect a warning for invalid PL/SQL
644644
// table
645-
String sql = "CREATE OR REPLACE FORCE VIEW testOracleR2dbcWarning AS" +
646-
" SELECT x FROM thisdoesnotexist";
645+
String sql = "CREATE OR REPLACE PROCEDURE testOracleR2dbcWarning AS" +
646+
" BEGIN this is not valid pl/sql; END;";
647647
Statement warningStatement = connection.createStatement(sql);
648648

649649
// Collect the segments
@@ -684,7 +684,7 @@ public void testOracleR2dbcWarning() {
684684
}
685685
finally {
686686
tryAwaitExecution(
687-
connection.createStatement("DROP VIEW testOracleR2dbcWarning"));
687+
connection.createStatement("DROP PROCEDURE testOracleR2dbcWarning"));
688688
tryAwaitNone(connection.close());
689689
}
690690
}
@@ -697,11 +697,10 @@ public void testOracleR2dbcWarningIgnored() {
697697
Connection connection = awaitOne(sharedConnection());
698698
try {
699699

700-
// Expect a warning for forcing a view that references a non-existent
701-
// table
700+
// Expect a warning for invalid PL/SQL
702701
String sql =
703-
"CREATE OR REPLACE FORCE VIEW testOracleR2dbcWarningIgnored AS" +
704-
" SELECT x FROM thisdoesnotexist";
702+
"CREATE OR REPLACE PROCEDURE testOracleR2dbcWarningIgnored AS" +
703+
" BEGIN this is not valid pl/sql; END;";
705704
Statement warningStatement = connection.createStatement(sql);
706705

707706
// Verify that an update count of 0 is returned.
@@ -719,7 +718,8 @@ public void testOracleR2dbcWarningIgnored() {
719718
}
720719
finally {
721720
tryAwaitExecution(
722-
connection.createStatement("DROP VIEW testOracleR2dbcWarningIgnored"));
721+
connection.createStatement(
722+
"DROP PROCEDURE testOracleR2dbcWarningIgnored"));
723723
tryAwaitNone(connection.close());
724724
}
725725
}
@@ -732,11 +732,10 @@ public void testOracleR2dbcWarningIgnored() {
732732
public void testOracleR2dbcWarningNotIgnored() {
733733
Connection connection = awaitOne(sharedConnection());
734734
try {
735-
// Expect a warning for forcing a view that references a non-existent
736-
// table
735+
// Expect a warning for invalid PL/SQL
737736
String sql =
738-
"CREATE OR REPLACE FORCE VIEW testOracleR2dbcWarningIgnored AS" +
739-
" SELECT x FROM thisdoesnotexist";
737+
"CREATE OR REPLACE PROCEDURE testOracleR2dbcWarningIgnored AS" +
738+
" BEGIN this is not valid pl/sql; END;";
740739
Statement warningStatement = connection.createStatement(sql);
741740
AtomicInteger segmentIndex = new AtomicInteger(0);
742741
awaitError(
@@ -754,7 +753,8 @@ public void testOracleR2dbcWarningNotIgnored() {
754753
}
755754
finally {
756755
tryAwaitExecution(
757-
connection.createStatement("DROP VIEW testOracleR2dbcWarningIgnored"));
756+
connection.createStatement(
757+
"DROP PROCEDURE testOracleR2dbcWarningIgnored"));
758758
tryAwaitNone(connection.close());
759759
}
760760
}

src/test/java/oracle/r2dbc/impl/OracleStatementImplTest.java

+15
Original file line numberDiff line numberDiff line change
@@ -2476,6 +2476,11 @@ public boolean equals(Object other) {
24762476
public String toString() {
24772477
return id + ", " + Arrays.toString(value);
24782478
}
2479+
2480+
@Override
2481+
public int hashCode() {
2482+
return Objects.hash(id, Arrays.hashCode(value));
2483+
}
24792484
}
24802485

24812486
TestRow row0 = new TestRow(0L, new int[]{1, 2, 3});
@@ -2684,6 +2689,11 @@ public boolean equals(Object other) {
26842689
public String toString() {
26852690
return id + ", " + Arrays.toString(value);
26862691
}
2692+
2693+
@Override
2694+
public int hashCode() {
2695+
return Objects.hash(id, Arrays.hashCode(value));
2696+
}
26872697
}
26882698

26892699
OracleR2dbcTypes.ArrayType arrayType =
@@ -3199,6 +3209,11 @@ public boolean equals(Object other) {
31993209
&& ((IdVector)other).id == id
32003210
&& Objects.equals(((IdVector)other).vector, vector);
32013211
}
3212+
3213+
@Override
3214+
public int hashCode() {
3215+
return Objects.hash(id, vector);
3216+
}
32023217
}
32033218

32043219
// Round 1: Use PL/SQL to return column values

src/test/java/oracle/r2dbc/test/DatabaseConfig.java

+15-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import java.sql.DriverManager;
3636
import java.sql.SQLException;
3737
import java.time.Duration;
38+
import java.util.Optional;
3839
import java.util.Properties;
3940

4041
/**
@@ -178,16 +179,27 @@ public static Publisher<? extends Connection> sharedConnection() {
178179
* @return The major version number of the test database.
179180
*/
180181
public static int databaseVersion() {
181-
try (var jdbcConnection = DriverManager.getConnection(String.format(
182-
"jdbc:oracle:thin:@%s:%s/%s", host(), port(), serviceName()),
183-
user(), password())) {
182+
try (
183+
var jdbcConnection =
184+
DriverManager.getConnection(jdbcUrl(), user(), password())) {
184185
return jdbcConnection.getMetaData().getDatabaseMajorVersion();
185186
}
186187
catch (SQLException sqlException) {
187188
throw new AssertionError(sqlException);
188189
}
189190
}
190191

192+
/**
193+
* Returns an Oracle JDBC URL for opening connections to the test database.
194+
* @return URL for the Oracle JDBC Driver. Not null.
195+
*/
196+
public static String jdbcUrl() {
197+
return String.format(
198+
"jdbc:oracle:thin:@%s%s:%d/%s",
199+
protocol() == null ? "" : protocol() + ":",
200+
host(), port(), serviceName());
201+
}
202+
191203
/**
192204
* Returns the major version number of the Oracle JDBC Driver installed as
193205
* a service provider for java.sql.Driver.

src/test/java/oracle/r2dbc/test/OracleTestKit.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import static io.r2dbc.spi.ConnectionFactoryOptions.USER;
5858
import static oracle.r2dbc.test.DatabaseConfig.connectionFactoryOptions;
5959
import static oracle.r2dbc.test.DatabaseConfig.host;
60+
import static oracle.r2dbc.test.DatabaseConfig.jdbcUrl;
6061
import static oracle.r2dbc.test.DatabaseConfig.password;
6162
import static oracle.r2dbc.test.DatabaseConfig.port;
6263
import static oracle.r2dbc.test.DatabaseConfig.protocol;
@@ -95,11 +96,7 @@ public class OracleTestKit implements TestKit<Integer> {
9596
try {
9697
OracleDataSource dataSource =
9798
new oracle.jdbc.datasource.impl.OracleDataSource();
98-
dataSource.setURL(String.format("jdbc:oracle:thin:@%s%s:%d/%s",
99-
Optional.ofNullable(protocol())
100-
.map(protocol -> protocol + ":")
101-
.orElse(""),
102-
host(), port(), serviceName()));
99+
dataSource.setURL(jdbcUrl());
103100
dataSource.setUser(user());
104101
dataSource.setPassword(password());
105102
this.jdbcOperations = new JdbcTemplate(dataSource);

src/test/java/oracle/r2dbc/util/SharedConnectionFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ private static RuntimeException openCursorNotAccessible() {
245245
return new RuntimeException(
246246
"V$OPEN_CUROSR is not accessible to the test user. " +
247247
"Grant access as SYSDBA with: " +
248-
"\"GRANT SELECT ON v_$open_cursor TO "+user()+"\", " +
248+
"\"GRANT SELECT ON v$open_cursor TO "+user()+"\", " +
249249
"or disable open cursor checks with: " +
250250
" -Doracle.r2bdc.disableCursorCloseVerification=true");
251251
}

0 commit comments

Comments
 (0)