Fix deprecations from Reactor

This commit is contained in:
Artem Bilan
2020-06-22 13:32:06 -04:00
parent 498f42d480
commit 3bb445e133
10 changed files with 48 additions and 44 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,8 +50,8 @@ import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import reactor.core.Disposable;
import reactor.core.publisher.EmitterProcessor;
import reactor.core.publisher.Flux;
import reactor.core.publisher.FluxIdentityProcessor;
/**
* @author Artem Bilan
@@ -141,7 +141,7 @@ public class FluxMessageChannelTests {
flowRegistration.destroy();
assertThat(TestUtils.getPropertyValue(flux, "processor", EmitterProcessor.class).isTerminated()).isTrue();
assertThat(TestUtils.getPropertyValue(flux, "processor", FluxIdentityProcessor.class).isTerminated()).isTrue();
}
@Configuration

View File

@@ -57,9 +57,10 @@ import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.ReactiveMessageHandler;
import org.springframework.messaging.support.GenericMessage;
import reactor.core.publisher.EmitterProcessor;
import reactor.core.publisher.Flux;
import reactor.core.publisher.FluxIdentityProcessor;
import reactor.core.publisher.Mono;
import reactor.core.publisher.Processors;
import reactor.test.StepVerifier;
import reactor.util.Loggers;
@@ -298,7 +299,7 @@ public class ReactiveStreamsConsumerTests {
public void testReactiveStreamsConsumerFluxMessageChannelReactiveMessageHandler() {
FluxMessageChannel testChannel = new FluxMessageChannel();
EmitterProcessor<Message<?>> processor = EmitterProcessor.create(2, false);
FluxIdentityProcessor<Message<?>> processor = Processors.more().multicast(2, false);
ReactiveMessageHandler messageHandler =
m -> {

View File

@@ -84,7 +84,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import reactor.core.publisher.Mono;
import reactor.core.publisher.MonoProcessor;
import reactor.core.publisher.Sinks;
import reactor.test.StepVerifier;
/**
@@ -241,7 +241,8 @@ public class MessagingAnnotationsWithBeanAnnotationTests {
this.reactiveMessageHandlerChannel.send(new GenericMessage<>("test"));
StepVerifier.create(
this.contextConfiguration.messageMonoProcessor
this.contextConfiguration.messageMono
.asMono()
.map(Message::getPayload)
.cast(String.class))
.expectNext("test")
@@ -291,7 +292,7 @@ public class MessagingAnnotationsWithBeanAnnotationTests {
}
@Bean
@Router(inputChannel = "routerChannel", channelMappings = { "true=odd", "false=filter" }, suffix = "Channel")
@Router(inputChannel = "routerChannel", channelMappings = {"true=odd", "false=filter"}, suffix = "Channel")
public MessageSelector router() {
return new ExpressionEvaluatingSelector("payload % 2 == 0");
}
@@ -373,7 +374,8 @@ public class MessagingAnnotationsWithBeanAnnotationTests {
@Filter(inputChannel = "skippedChannel5")
@Profile("foo")
public MessageHandler skippedMessageHandler() {
return m -> { };
return m -> {
};
}
@Bean
@@ -427,7 +429,7 @@ public class MessagingAnnotationsWithBeanAnnotationTests {
return collector()::add;
}
MonoProcessor<Message<?>> messageMonoProcessor = MonoProcessor.create();
Sinks.StandaloneMonoSink<Message<?>> messageMono = Sinks.promise();
@Bean
MessageChannel reactiveMessageHandlerChannel() {
@@ -438,8 +440,7 @@ public class MessagingAnnotationsWithBeanAnnotationTests {
@ServiceActivator(inputChannel = "reactiveMessageHandlerChannel")
public ReactiveMessageHandler reactiveMessageHandlerService() {
return (message) -> {
messageMonoProcessor.onNext(message);
messageMonoProcessor.onComplete();
messageMono.success(message);
return Mono.empty();
};
}

View File

@@ -62,7 +62,7 @@ import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import reactor.core.publisher.Mono;
import reactor.core.publisher.MonoProcessor;
import reactor.core.publisher.Sinks;
import reactor.test.StepVerifier;
/**
@@ -88,14 +88,14 @@ public class GatewayParserTests {
Message<?> result = channel.receive(10000);
assertThat(result.getPayload()).isEqualTo("foo");
MonoProcessor<Object> defaultMethodHandler = MonoProcessor.create();
Sinks.StandaloneMonoSink<Object> defaultMethodHandler = Sinks.promise();
this.errorChannel.subscribe(message -> defaultMethodHandler.onNext(message.getPayload()));
this.errorChannel.subscribe(message -> defaultMethodHandler.success(message.getPayload()));
String defaultMethodPayload = "defaultMethodPayload";
service.defaultMethodGateway(defaultMethodPayload);
StepVerifier.create(defaultMethodHandler)
StepVerifier.create(defaultMethodHandler.asMono())
.expectNext(defaultMethodPayload)
.verifyComplete();
}
@@ -423,7 +423,7 @@ public class GatewayParserTests {
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
public <T> Future<T> submit(Callable<T> task) {
try {
Future<?> result = super.submit(task);