Browse Source

Upgrade to R2DBC 1.0

Includes Reactor 2022.0.0-M4, Netty 4.1.79, Jetty 11.0.11, Undertow 2.2.18, Hibernate ORM 5.6.10, Checkstyle 10.3.1

Closes gh-28787
pull/28821/head
Juergen Hoeller 2 years ago
parent
commit
7055ddb489
  1. 19
      build.gradle
  2. 2
      spring-r2dbc/spring-r2dbc.gradle
  3. 23
      spring-r2dbc/src/test/java/org/springframework/r2dbc/core/DefaultDatabaseClientUnitTests.java

19
build.gradle

@ -28,11 +28,10 @@ configure(allprojects) { project -> @@ -28,11 +28,10 @@ configure(allprojects) { project ->
dependencyManagement {
imports {
mavenBom "com.fasterxml.jackson:jackson-bom:2.13.3"
mavenBom "io.netty:netty-bom:4.1.77.Final"
mavenBom "io.projectreactor:reactor-bom:2022.0.0-SNAPSHOT"
mavenBom "io.r2dbc:r2dbc-bom:Borca-SR1"
mavenBom "io.netty:netty-bom:4.1.79.Final"
mavenBom "io.projectreactor:reactor-bom:2022.0.0-M4"
mavenBom "io.rsocket:rsocket-bom:1.1.2"
mavenBom "org.eclipse.jetty:jetty-bom:11.0.9"
mavenBom "org.eclipse.jetty:jetty-bom:11.0.11"
mavenBom "org.jetbrains.kotlin:kotlin-bom:1.7.10"
mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.2"
mavenBom "org.jetbrains.kotlinx:kotlinx-serialization-bom:1.3.3"
@ -66,6 +65,9 @@ configure(allprojects) { project -> @@ -66,6 +65,9 @@ configure(allprojects) { project ->
dependency "io.reactivex.rxjava3:rxjava:3.1.4"
dependency "io.smallrye.reactive:mutiny:1.4.0"
dependency "io.projectreactor.tools:blockhound:1.0.6.RELEASE"
dependency "io.r2dbc:r2dbc-spi:1.0.0.RELEASE"
dependency "io.r2dbc:r2dbc-spi-test:1.0.0.RELEASE"
dependency "io.r2dbc:r2dbc-h2:1.0.0.RC1"
dependency "com.fasterxml:aalto-xml:1.3.1"
dependency("com.fasterxml.woodstox:woodstox-core:6.2.8") {
@ -112,7 +114,7 @@ configure(allprojects) { project -> @@ -112,7 +114,7 @@ configure(allprojects) { project ->
dependency "org.quartz-scheduler:quartz:2.3.2"
dependency "org.ehcache:jcache:1.0.1"
dependency "org.ehcache:ehcache:3.4.0"
dependency "org.hibernate:hibernate-core-jakarta:5.6.8.Final"
dependency "org.hibernate:hibernate-core-jakarta:5.6.10.Final"
dependency "org.hibernate:hibernate-validator:7.0.4.Final"
dependency "org.webjars:webjars-locator-core:0.48"
dependency "org.webjars:underscorejs:1.8.3"
@ -128,7 +130,7 @@ configure(allprojects) { project -> @@ -128,7 +130,7 @@ configure(allprojects) { project ->
entry 'tomcat-embed-core'
entry 'tomcat-embed-websocket'
}
dependencySet(group: 'io.undertow', version: '2.2.17.Final') {
dependencySet(group: 'io.undertow', version: '2.2.18.Final') {
entry 'undertow-core'
entry 'undertow-servlet-jakarta'
entry 'undertow-websockets-jsr-jakarta'
@ -253,7 +255,6 @@ configure(allprojects) { project -> @@ -253,7 +255,6 @@ configure(allprojects) { project ->
mavenCentral()
maven { url "https://repo.spring.io/libs-spring-framework-build" }
maven { url "https://repo.spring.io/milestone" } // temporarily for context-propagation via Reactor Netty
maven { url "https://repo.spring.io/snapshot" } // Reactor
}
}
configurations.all {
@ -302,7 +303,7 @@ configure([rootProject] + javaProjects) { project -> @@ -302,7 +303,7 @@ configure([rootProject] + javaProjects) { project ->
}
checkstyle {
toolVersion = "10.3"
toolVersion = "10.3.1"
configDirectory.set(rootProject.file("src/checkstyle"))
}
@ -351,7 +352,7 @@ configure([rootProject] + javaProjects) { project -> @@ -351,7 +352,7 @@ configure([rootProject] + javaProjects) { project ->
// "https://junit.org/junit5/docs/5.8.2/api/",
"https://www.reactive-streams.org/reactive-streams-1.0.3-javadoc/",
"https://javadoc.io/static/io.rsocket/rsocket-core/1.1.1/",
"https://r2dbc.io/spec/0.9.1.RELEASE/api/",
"https://r2dbc.io/spec/1.0.0.RELEASE/api/",
// The external Javadoc link for JSR 305 must come last to ensure that types from
// JSR 250 (such as @PostConstruct) are still supported. This is due to the fact
// that JSR 250 and JSR 305 both define types in javax.annotation, which results

2
spring-r2dbc/spring-r2dbc.gradle

@ -17,7 +17,7 @@ dependencies { @@ -17,7 +17,7 @@ dependencies {
testImplementation(testFixtures(project(":spring-context")))
testImplementation("io.projectreactor:reactor-test")
testImplementation("io.r2dbc:r2dbc-h2")
testImplementation("io.r2dbc:r2dbc-spi-test:0.9.1.RELEASE") {
testImplementation("io.r2dbc:r2dbc-spi-test") {
exclude group: "org.springframework", module: "spring-jdbc"
}
}

23
spring-r2dbc/src/test/java/org/springframework/r2dbc/core/DefaultDatabaseClientUnitTests.java

@ -72,6 +72,7 @@ class DefaultDatabaseClientUnitTests { @@ -72,6 +72,7 @@ class DefaultDatabaseClientUnitTests {
private DatabaseClient.Builder databaseClientBuilder;
@BeforeEach
@SuppressWarnings({ "rawtypes", "unchecked" })
void before() {
@ -84,6 +85,7 @@ class DefaultDatabaseClientUnitTests { @@ -84,6 +85,7 @@ class DefaultDatabaseClientUnitTests {
connectionFactory).bindMarkers(BindMarkersFactory.indexed("$", 1));
}
@Test
void connectionFactoryIsExposed() {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
@ -96,7 +98,6 @@ class DefaultDatabaseClientUnitTests { @@ -96,7 +98,6 @@ class DefaultDatabaseClientUnitTests {
@Test
void shouldCloseConnectionOnlyOnce() {
DefaultDatabaseClient databaseClient = (DefaultDatabaseClient) databaseClientBuilder.build();
Flux<Object> flux = databaseClient.inConnectionMany(connection -> Flux.empty());
flux.subscribe(new CoreSubscriber<Object>() {
@ -147,7 +148,6 @@ class DefaultDatabaseClientUnitTests { @@ -147,7 +148,6 @@ class DefaultDatabaseClientUnitTests {
@SuppressWarnings("deprecation")
void executeShouldBindSettableValues() {
Statement statement = mockStatementFor("SELECT * FROM table WHERE key = $1");
DatabaseClient databaseClient = databaseClientBuilder.namedParameters(false).build();
databaseClient.sql("SELECT * FROM table WHERE key = $1").bind(0,
@ -165,7 +165,6 @@ class DefaultDatabaseClientUnitTests { @@ -165,7 +165,6 @@ class DefaultDatabaseClientUnitTests {
@Test
void executeShouldBindNamedNullValues() {
Statement statement = mockStatementFor("SELECT * FROM table WHERE key = $1");
DatabaseClient databaseClient = databaseClientBuilder.build();
@ -198,7 +197,6 @@ class DefaultDatabaseClientUnitTests { @@ -198,7 +197,6 @@ class DefaultDatabaseClientUnitTests {
@SuppressWarnings("deprecation")
void executeShouldBindValues() {
Statement statement = mockStatementFor("SELECT * FROM table WHERE key = $1");
DatabaseClient databaseClient = databaseClientBuilder.build();
databaseClient.sql("SELECT * FROM table WHERE key = $1").bind(0,
@ -214,7 +212,6 @@ class DefaultDatabaseClientUnitTests { @@ -214,7 +212,6 @@ class DefaultDatabaseClientUnitTests {
@Test
void executeShouldBindNamedValuesByIndex() {
Statement statement = mockStatementFor("SELECT * FROM table WHERE key = $1");
DatabaseClient databaseClient = databaseClientBuilder.build();
@ -227,9 +224,8 @@ class DefaultDatabaseClientUnitTests { @@ -227,9 +224,8 @@ class DefaultDatabaseClientUnitTests {
@Test
@SuppressWarnings("unchecked")
void rowsUpdatedShouldEmitSingleValue() {
Result result = mock(Result.class);
when(result.getRowsUpdated()).thenReturn(Mono.empty(), Mono.just(2), Flux.just(1, 2, 3));
when(result.getRowsUpdated()).thenReturn(Mono.empty(), Mono.just(2L), Flux.just(1L, 2L, 3L));
mockStatementFor("DROP TABLE tab;", result);
DatabaseClient databaseClient = databaseClientBuilder.build();
@ -355,9 +351,7 @@ class DefaultDatabaseClientUnitTests { @@ -355,9 +351,7 @@ class DefaultDatabaseClientUnitTests {
@Test
void shouldApplyStatementFilterFunctions() {
MockResult result = MockResult.builder().build();
Statement statement = mockStatement(result);
DatabaseClient databaseClient = databaseClientBuilder.build();
databaseClient.sql("SELECT").filter(
@ -376,9 +370,7 @@ class DefaultDatabaseClientUnitTests { @@ -376,9 +370,7 @@ class DefaultDatabaseClientUnitTests {
@Test
void shouldApplySimpleStatementFilterFunctions() {
MockResult result = mockSingleColumnEmptyResult();
Statement statement = mockStatement(result);
DatabaseClient databaseClient = databaseClientBuilder.build();
databaseClient.sql("SELECT").filter(
@ -393,6 +385,7 @@ class DefaultDatabaseClientUnitTests { @@ -393,6 +385,7 @@ class DefaultDatabaseClientUnitTests {
inOrder.verifyNoMoreInteractions();
}
private Statement mockStatement() {
return mockStatementFor(null, null);
}
@ -407,14 +400,10 @@ class DefaultDatabaseClientUnitTests { @@ -407,14 +400,10 @@ class DefaultDatabaseClientUnitTests {
private Statement mockStatementFor(@Nullable String sql, @Nullable Result result) {
Statement statement = mock(Statement.class);
when(connection.createStatement(sql == null ? anyString() : eq(sql))).thenReturn(
statement);
when(connection.createStatement(sql == null ? anyString() : eq(sql))).thenReturn(statement);
when(statement.returnGeneratedValues(anyString())).thenReturn(statement);
when(statement.returnGeneratedValues()).thenReturn(statement);
doReturn(result == null ? Mono.empty() : Flux.just(result)).when(
statement).execute();
doReturn(result == null ? Mono.empty() : Flux.just(result)).when(statement).execute();
return statement;
}

Loading…
Cancel
Save