Skip to content

Commit 5be5c71

Browse files
Add module-info.java, and make tests module compatible.
1 parent 47ad6a8 commit 5be5c71

13 files changed

+104
-216
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<artifactId>maven-javadoc-plugin</artifactId>
7878
<version>3.2.0</version>
7979
<configuration>
80-
<header>Oracle R2DBC ${version}</header>
80+
<header>Oracle R2DBC ${project.version}</header>
8181
<footer>
8282
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
8383
</footer>

src/main/java/module-info.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
3+
4+
This software is dual-licensed to you under the Universal Permissive License
5+
(UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License
6+
2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose
7+
either license.
8+
9+
Licensed under the Apache License, Version 2.0 (the "License");
10+
you may not use this file except in compliance with the License.
11+
You may obtain a copy of the License at
12+
13+
https://www.apache.org/licenses/LICENSE-2.0
14+
15+
Unless required by applicable law or agreed to in writing, software
16+
distributed under the License is distributed on an "AS IS" BASIS,
17+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
See the License for the specific language governing permissions and
19+
limitations under the License.
20+
*/
21+
/**
22+
* Implements the R2DBC SPI for Oracle Database.
23+
*
24+
* @provides io.r2dbc.spi.ConnectionFactoryProvider
25+
* @since 0.1.1
26+
*/
27+
module oracle.r2dbc {
28+
29+
provides io.r2dbc.spi.ConnectionFactoryProvider
30+
with oracle.r2dbc.impl.OracleConnectionFactoryProviderImpl;
31+
32+
requires java.sql;
33+
34+
requires ojdbc11;
35+
requires org.reactivestreams;
36+
requires reactor.core;
37+
requires r2dbc.spi;
38+
}

src/main/java/oracle/r2dbc/impl/OracleConnectionImpl.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
import reactor.core.publisher.Mono;
3333

3434
import static java.sql.Connection.TRANSACTION_READ_COMMITTED;
35-
import static java.sql.Connection.TRANSACTION_READ_UNCOMMITTED;
36-
import static java.sql.Connection.TRANSACTION_REPEATABLE_READ;
3735
import static java.sql.Connection.TRANSACTION_SERIALIZABLE;
3836
import static oracle.r2dbc.impl.OracleR2dbcExceptions.requireNonNull;
3937
import static oracle.r2dbc.impl.OracleR2dbcExceptions.getOrHandleSQLException;

src/main/java/oracle/r2dbc/impl/OracleReactiveJdbcAdapter.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
import io.r2dbc.spi.Option;
2626
import io.r2dbc.spi.R2dbcException;
2727
import io.r2dbc.spi.R2dbcTimeoutException;
28-
import io.r2dbc.spi.Result;
29-
import io.r2dbc.spi.Row;
3028
import oracle.jdbc.OracleBlob;
3129
import oracle.jdbc.OracleClob;
3230
import oracle.jdbc.OracleConnection;
@@ -49,17 +47,12 @@
4947
import java.sql.Connection;
5048
import java.sql.PreparedStatement;
5149
import java.sql.ResultSet;
52-
import java.sql.RowId;
5350
import java.sql.SQLException;
54-
import java.sql.Statement;
55-
import java.sql.Types;
5651
import java.sql.Wrapper;
5752
import java.time.Duration;
58-
import java.util.Map;
5953
import java.util.Objects;
6054
import java.util.Set;
6155
import java.util.concurrent.CompletableFuture;
62-
import java.util.concurrent.ConcurrentHashMap;
6356
import java.util.concurrent.Flow;
6457
import java.util.concurrent.atomic.AtomicBoolean;
6558
import java.util.concurrent.locks.ReentrantLock;
@@ -426,10 +419,11 @@ static OracleReactiveJdbcAdapter getInstance() {
426419
@Override
427420
public DataSource createDataSource(ConnectionFactoryOptions options) {
428421

429-
oracle.jdbc.pool.OracleDataSource oracleDataSource =
422+
OracleDataSource oracleDataSource =
430423
getOrHandleSQLException(oracle.jdbc.pool.OracleDataSource::new);
431424

432-
oracleDataSource.setURL(composeJdbcUrl(options));
425+
runOrHandleSQLException(() ->
426+
oracleDataSource.setURL(composeJdbcUrl(options)));
433427
configureStandardOptions(oracleDataSource, options);
434428
configureExtendedOptions(oracleDataSource, options);
435429
configureJdbcDefaults(oracleDataSource);

src/main/java/oracle/r2dbc/impl/OracleResultImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import java.sql.PreparedStatement;
2525
import java.sql.ResultSet;
26-
import java.sql.SQLException;
2726
import java.util.concurrent.atomic.AtomicBoolean;
2827
import java.util.function.BiFunction;
2928

src/main/java/oracle/r2dbc/impl/OracleRowImpl.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,10 @@
2525
import io.r2dbc.spi.Clob;
2626
import io.r2dbc.spi.R2dbcException;
2727
import io.r2dbc.spi.Row;
28-
import oracle.jdbc.OracleType;
2928

30-
import java.io.IOException;
3129
import java.nio.ByteBuffer;
32-
import java.sql.JDBCType;
3330
import java.sql.ResultSet;
34-
import java.sql.SQLType;
3531
import java.sql.Types;
36-
import java.util.Objects;
3732

3833
import static oracle.r2dbc.impl.OracleR2dbcExceptions.requireNonNull;
3934

src/main/java/oracle/r2dbc/impl/OracleStatementImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import io.r2dbc.spi.R2dbcException;
2525
import io.r2dbc.spi.Result;
2626
import io.r2dbc.spi.Statement;
27-
import oracle.r2dbc.impl.OracleR2dbcExceptions.ThrowingRunnable;
2827
import org.reactivestreams.Publisher;
2928
import reactor.core.publisher.Flux;
3029
import reactor.core.publisher.Mono;
@@ -547,6 +546,7 @@ private Publisher<Result> createResultPublisher(
547546
* signal.
548547
* </p>
549548
* @param jdbcStatement A JDBC statement
549+
* @param bindValues A set of bind values
550550
* @return A publisher that emits the {@code Result} of executing the JDBC
551551
* statement.
552552
*/
@@ -625,7 +625,7 @@ private Publisher<Result> executeBatch(
625625
* {@link PreparedStatement#addBatch()},
626626
*
627627
* @param jdbcStatement A JDBC statement
628-
* @param batch A batch of bind values
628+
* @param bindValues A set of bind values
629629
* @return A publisher that emits the {@code Results} of executing the
630630
* JDBC statement for each set of bind values in the {@code batch}
631631
*/

src/main/java/oracle/r2dbc/impl/ReactiveJdbcAdapter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import java.sql.DriverManager;
3838
import java.sql.PreparedStatement;
3939
import java.sql.ResultSet;
40-
import java.sql.ResultSetMetaData;
4140
import java.sql.SQLException;
4241
import java.util.function.Function;
4342

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

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@
2626

2727
import io.r2dbc.spi.*;
2828
import io.r2dbc.spi.test.TestKit;
29-
import oracle.r2dbc.util.OracleTestKitSupport;
29+
import oracle.jdbc.datasource.OracleDataSource;
3030
import org.junit.jupiter.api.Disabled;
3131
import org.junit.jupiter.api.Test;
3232
import org.springframework.jdbc.core.JdbcOperations;
33+
import org.springframework.jdbc.core.JdbcTemplate;
3334
import org.springframework.jdbc.core.support.AbstractLobCreatingPreparedStatementCallback;
3435
import org.springframework.jdbc.support.lob.DefaultLobHandler;
3536
import org.springframework.jdbc.support.lob.LobCreator;
@@ -46,7 +47,17 @@
4647
import java.util.Collection;
4748
import 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>
@@ -73,13 +84,38 @@
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
/*

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import reactor.core.publisher.Mono;
3131
import reactor.core.publisher.Signal;
3232

33-
import java.util.Arrays;
3433
import java.util.List;
3534
import java.util.function.BiFunction;
3635

@@ -42,22 +41,21 @@
4241
import static oracle.r2dbc.util.Awaits.awaitMany;
4342
import static oracle.r2dbc.util.Awaits.awaitNone;
4443
import static oracle.r2dbc.util.Awaits.awaitOne;
45-
import static oracle.r2dbc.util.Awaits.awaitUpdate;
4644
import static org.junit.jupiter.api.Assertions.*;
4745

4846
/**
4947
* Verifies that
5048
* {@link OracleResultImpl} implements behavior that is specified in it's
5149
* class and method level javadocs.
5250
*/
53-
class OracleResultImplTest {
51+
public class OracleResultImplTest {
5452

5553
/**
5654
* Verifies the implementation of
5755
* {@link OracleResultImpl#getRowsUpdated()}
5856
*/
5957
@Test
60-
void testGetRowsUpdated() {
58+
public void testGetRowsUpdated() {
6159
Connection connection =
6260
Mono.from(sharedConnection()).block(connectTimeout());
6361
try {
@@ -178,7 +176,7 @@ void testGetRowsUpdated() {
178176
* {@link OracleResultImpl#map(BiFunction)}
179177
*/
180178
@Test
181-
void testMap() {
179+
public void testMap() {
182180
Connection connection =
183181
Mono.from(sharedConnection()).block(connectTimeout());
184182
try {

0 commit comments

Comments
 (0)