Skip to content

Commit dc8712f

Browse files
committed
* Fix ReactiveStreamsTests
1 parent 7a493d2 commit dc8712f

File tree

1 file changed

+7
-38
lines changed

1 file changed

+7
-38
lines changed

spring-integration-core/src/test/java/org/springframework/integration/dsl/reactivestreams/ReactiveStreamsTests.java

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,17 @@
2929
import java.util.concurrent.Future;
3030
import java.util.concurrent.TimeUnit;
3131
import java.util.concurrent.atomic.AtomicBoolean;
32-
import java.util.function.Function;
3332
import java.util.stream.Collectors;
34-
import java.util.stream.IntStream;
35-
import java.util.stream.StreamSupport;
3633

3734
import org.junit.jupiter.api.Test;
3835
import org.reactivestreams.Publisher;
3936

40-
import org.springframework.aop.ThrowsAdvice;
4137
import org.springframework.beans.factory.annotation.Autowired;
4238
import org.springframework.beans.factory.annotation.Qualifier;
4339
import org.springframework.context.Lifecycle;
4440
import org.springframework.context.annotation.Bean;
4541
import org.springframework.context.annotation.Configuration;
4642
import org.springframework.integration.IntegrationMessageHeaderAccessor;
47-
import org.springframework.integration.annotation.Reactive;
48-
import org.springframework.integration.annotation.ServiceActivator;
4943
import org.springframework.integration.channel.QueueChannel;
5044
import org.springframework.integration.config.EnableIntegration;
5145
import org.springframework.integration.dsl.IntegrationFlow;
@@ -57,11 +51,9 @@
5751
import org.springframework.messaging.Message;
5852
import org.springframework.messaging.MessageChannel;
5953
import org.springframework.messaging.support.GenericMessage;
60-
import org.springframework.scheduling.annotation.Schedules;
6154
import org.springframework.test.annotation.DirtiesContext;
6255
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
6356

64-
import io.vavr.collection.Stream;
6557
import reactor.core.publisher.Flux;
6658
import reactor.core.scheduler.Schedulers;
6759

@@ -123,7 +115,7 @@ void testReactiveFlow() throws Exception {
123115
this.messageSource.start();
124116
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
125117
String[] strings = results.toArray(new String[0]);
126-
assertThat(strings).isEqualTo(new String[] { "A", "B", "C", "D", "E", "F" });
118+
assertThat(strings).isEqualTo(new String[]{ "A", "B", "C", "D", "E", "F" });
127119
this.messageSource.stop();
128120
}
129121

@@ -246,22 +238,6 @@ void fixedSubscriberChannelFlowTest() throws InterruptedException {
246238
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
247239
}
248240

249-
@Autowired
250-
MessageChannel directChannel;
251-
252-
@Test
253-
void testReactiveCustomizer() throws InterruptedException {
254-
Flux.fromStream(IntStream.range(1, 100).boxed())
255-
256-
.subscribe(value -> System.out.println(Thread.currentThread().getName() + ": " + value));
257-
258-
/*for (int i = 0; i < 100; i++) {
259-
this.directChannel.send(new GenericMessage<>(i));
260-
}
261-
*/
262-
Thread.sleep(1000);
263-
}
264-
265241
@Configuration
266242
@EnableIntegration
267243
public static class ContextConfiguration {
@@ -281,12 +257,15 @@ public Publisher<Message<String>> reactiveFlow() {
281257
}
282258

283259
@Bean
284-
public IntegrationFlow reactiveEndpointFlow() {
260+
public Publisher<Message<Integer>> pollableReactiveFlow() {
285261
return IntegrationFlows
286262
.from("inputChannel")
263+
.split(s -> s.delimiters(","))
287264
.<String, Integer>transform(Integer::parseInt,
288-
e -> e.reactive(flux -> flux.publishOn(Schedulers.parallel())))
289-
.get();
265+
e -> e.reactive(flux -> flux.publishOn(Schedulers.parallel())).id("reactiveTransformer"))
266+
.channel(MessageChannels.queue())
267+
.log()
268+
.toReactivePublisher();
290269
}
291270

292271
@Bean
@@ -305,16 +284,6 @@ public Publisher<Message<String>> fixedSubscriberChannelFlow() {
305284
.toReactivePublisher();
306285
}
307286

308-
@Bean
309-
public Function<Flux<?>, Flux<?>> publishOnCustomizer() {
310-
return flux -> flux.publishOn(Schedulers.parallel());
311-
}
312-
313-
@ServiceActivator(inputChannel = "directChannel", reactive = @Reactive("publishOnCustomizer"))
314-
public void handleReactive(String payload) {
315-
System.out.println(Thread.currentThread().getName() + ": " + payload);
316-
}
317-
318287
}
319288

320289
}

0 commit comments

Comments
 (0)