[JAVA-27761] Upgraded spring-reactive-2 to spring boot 3 (#15293)
This commit is contained in:
parent
232730dbbb
commit
19184bdf40
@ -10,9 +10,10 @@
|
|||||||
<description>spring sample project about new features</description>
|
<description>spring sample project about new features</description>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung.spring.reactive</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>spring-reactive-modules</artifactId>
|
<artifactId>parent-boot-3</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../../parent-boot-3</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -45,8 +46,8 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.tomakehurst</groupId>
|
<groupId>org.wiremock</groupId>
|
||||||
<artifactId>wiremock-jre8</artifactId>
|
<artifactId>wiremock</artifactId>
|
||||||
<version>${wiremock.version}</version>
|
<version>${wiremock.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -64,6 +65,11 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>${commons-lang3.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -116,7 +122,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<reactor-spring.version>1.0.1.RELEASE</reactor-spring.version>
|
<reactor-spring.version>1.0.1.RELEASE</reactor-spring.version>
|
||||||
<wiremock.version>2.24.0</wiremock.version>
|
<wiremock.version>3.3.1</wiremock.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -5,10 +5,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
||||||
|
|
||||||
@SpringBootApplication(exclude = { RedisAutoConfiguration.class })
|
@SpringBootApplication(exclude = { RedisAutoConfiguration.class })
|
||||||
public class Spring5ReactiveApplication{
|
public class Spring6ReactiveApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(Spring5ReactiveApplication.class, args);
|
SpringApplication.run(Spring6ReactiveApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -22,9 +22,10 @@ public class ConsumerSSEApplication {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SecurityWebFilterChain sseConsumerSpringSecurityFilterChain(ServerHttpSecurity http) {
|
public SecurityWebFilterChain sseConsumerSpringSecurityFilterChain(ServerHttpSecurity http) {
|
||||||
http.authorizeExchange()
|
http.authorizeExchange(auth -> auth
|
||||||
.anyExchange()
|
.anyExchange().permitAll()
|
||||||
.permitAll();
|
)
|
||||||
|
.csrf(ServerHttpSecurity.CsrfSpec::disable);
|
||||||
return http.build();
|
return http.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ public class FormHandler {
|
|||||||
|
|
||||||
private AtomicLong extractData(List<DataBuffer> dataBuffers) {
|
private AtomicLong extractData(List<DataBuffer> dataBuffers) {
|
||||||
AtomicLong atomicLong = new AtomicLong(0);
|
AtomicLong atomicLong = new AtomicLong(0);
|
||||||
dataBuffers.forEach(d -> atomicLong.addAndGet(d.asByteBuffer()
|
dataBuffers.forEach(d -> atomicLong.addAndGet(d.toByteBuffer()
|
||||||
.array().length));
|
.array().length));
|
||||||
return atomicLong;
|
return atomicLong;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ public class CpuUtils {
|
|||||||
private static OperatingSystemMXBean operatingSystemMXBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
|
private static OperatingSystemMXBean operatingSystemMXBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
|
||||||
|
|
||||||
static Double getUsage() {
|
static Double getUsage() {
|
||||||
return (operatingSystemMXBean.getSystemCpuLoad() / operatingSystemMXBean.getAvailableProcessors()) * 100;
|
return (operatingSystemMXBean.getCpuLoad() / operatingSystemMXBean.getAvailableProcessors()) * 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ public class StaticContentConfig {
|
|||||||
GET("/"),
|
GET("/"),
|
||||||
request -> ok()
|
request -> ok()
|
||||||
.contentType(MediaType.TEXT_HTML)
|
.contentType(MediaType.TEXT_HTML)
|
||||||
.syncBody(html)
|
.bodyValue(html)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,10 +15,11 @@ public class FunctionalValidationsApplication {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SecurityWebFilterChain functionalValidationsSpringSecurityFilterChain(ServerHttpSecurity http) {
|
public SecurityWebFilterChain functionalValidationsSpringSecurityFilterChain(ServerHttpSecurity http) {
|
||||||
http.authorizeExchange()
|
http.authorizeExchange(auth -> auth
|
||||||
.anyExchange()
|
.anyExchange().permitAll()
|
||||||
.permitAll();
|
)
|
||||||
http.csrf().disable();
|
.csrf(ServerHttpSecurity.CsrfSpec::disable);
|
||||||
|
|
||||||
return http.build();
|
return http.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.baeldung.validations.functional.model;
|
package com.baeldung.validations.functional.model;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
@ -37,17 +37,12 @@ public class BackpressureUnitTest {
|
|||||||
public void whenRequestingChunks10_thenMessagesAreReceived() {
|
public void whenRequestingChunks10_thenMessagesAreReceived() {
|
||||||
Flux<Integer> request = Flux.range(1, 50);
|
Flux<Integer> request = Flux.range(1, 50);
|
||||||
|
|
||||||
request.subscribe(
|
request.subscribe(integer -> LOGGER.debug(String.valueOf(integer)), err -> err.printStackTrace(), () -> LOGGER.debug("All 50 items have been successfully processed!!!"), subscription -> {
|
||||||
integer -> LOGGER.debug(String.valueOf(integer)),
|
|
||||||
err -> err.printStackTrace(),
|
|
||||||
() -> LOGGER.debug("All 50 items have been successfully processed!!!"),
|
|
||||||
subscription -> {
|
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
LOGGER.debug("Requesting the next 10 elements!!!");
|
LOGGER.debug("Requesting the next 10 elements!!!");
|
||||||
subscription.request(10);
|
subscription.request(10);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
StepVerifier.create(request)
|
StepVerifier.create(request)
|
||||||
.expectSubscription()
|
.expectSubscription()
|
||||||
@ -56,17 +51,18 @@ public class BackpressureUnitTest {
|
|||||||
.thenRequest(10)
|
.thenRequest(10)
|
||||||
.expectNext(11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
|
.expectNext(11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
|
||||||
.thenRequest(10)
|
.thenRequest(10)
|
||||||
.expectNext(21, 22, 23, 24, 25, 26, 27 , 28, 29 ,30)
|
.expectNext(21, 22, 23, 24, 25, 26, 27, 28, 29, 30)
|
||||||
.thenRequest(10)
|
.thenRequest(10)
|
||||||
.expectNext(31, 32, 33, 34, 35, 36, 37 , 38, 39 ,40)
|
.expectNext(31, 32, 33, 34, 35, 36, 37, 38, 39, 40)
|
||||||
.thenRequest(10)
|
.thenRequest(10)
|
||||||
.expectNext(41, 42, 43, 44, 45, 46, 47 , 48, 49 ,50)
|
.expectNext(41, 42, 43, 44, 45, 46, 47, 48, 49, 50)
|
||||||
.verifyComplete();
|
.verifyComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenCancel_thenSubscriptionFinished() {
|
public void whenCancel_thenSubscriptionFinished() {
|
||||||
Flux<Integer> cancel = Flux.range(1, 10).log();
|
Flux<Integer> cancel = Flux.range(1, 10)
|
||||||
|
.log();
|
||||||
|
|
||||||
cancel.subscribe(new BaseSubscriber<Integer>() {
|
cancel.subscribe(new BaseSubscriber<Integer>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,11 +8,11 @@ import org.springframework.security.test.context.support.WithMockUser;
|
|||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||||
|
|
||||||
import com.baeldung.reactive.Spring5ReactiveApplication;
|
import com.baeldung.reactive.Spring6ReactiveApplication;
|
||||||
import com.baeldung.reactive.controller.PathPatternController;
|
import com.baeldung.reactive.controller.PathPatternController;
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(classes = Spring5ReactiveApplication.class)
|
@SpringBootTest(classes = Spring6ReactiveApplication.class)
|
||||||
@WithMockUser
|
@WithMockUser
|
||||||
public class PathPatternsUsingHandlerMethodIntegrationTest {
|
public class PathPatternsUsingHandlerMethodIntegrationTest {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user