18
18
19
19
import static org .assertj .core .api .Assertions .assertThat ;
20
20
21
+ import java .time .Duration ;
21
22
import java .util .Arrays ;
22
23
import java .util .Collections ;
23
24
import java .util .List ;
24
25
import java .util .stream .Stream ;
25
26
26
- import org .junit .Test ;
27
- import org .reactivestreams .Subscriber ;
27
+ import org .junit .jupiter .api .Test ;
28
28
29
29
import org .springframework .integration .IntegrationMessageHeaderAccessor ;
30
30
import org .springframework .integration .channel .DirectChannel ;
31
31
import org .springframework .integration .channel .FluxMessageChannel ;
32
32
import org .springframework .integration .channel .QueueChannel ;
33
33
import org .springframework .integration .endpoint .EventDrivenConsumer ;
34
34
import org .springframework .integration .support .MessageBuilder ;
35
- import org .springframework .integration .test .util .TestUtils ;
36
35
import org .springframework .messaging .Message ;
37
36
import org .springframework .messaging .support .GenericMessage ;
38
37
45
44
* @author Gunnar Hillert
46
45
* @author Artem Bilan
47
46
*/
48
- public class DefaultSplitterTests {
47
+ class DefaultSplitterTests {
49
48
50
49
@ Test
51
- public void splitMessageWithArrayPayload () throws Exception {
50
+ void splitMessageWithArrayPayload () {
52
51
String [] payload = new String [] { "x" , "y" , "z" };
53
52
Message <String []> message = MessageBuilder .withPayload (payload ).build ();
54
53
QueueChannel replyChannel = new QueueChannel ();
@@ -69,7 +68,7 @@ public void splitMessageWithArrayPayload() throws Exception {
69
68
}
70
69
71
70
@ Test
72
- public void splitMessageWithCollectionPayload () throws Exception {
71
+ void splitMessageWithCollectionPayload () {
73
72
List <String > payload = Arrays .asList ("x" , "y" , "z" );
74
73
Message <List <String >> message = MessageBuilder .withPayload (payload ).build ();
75
74
QueueChannel replyChannel = new QueueChannel ();
@@ -90,7 +89,7 @@ public void splitMessageWithCollectionPayload() throws Exception {
90
89
}
91
90
92
91
@ Test
93
- public void correlationIdCopiedFromMessageId () {
92
+ void correlationIdCopiedFromMessageId () {
94
93
Message <String > message = MessageBuilder .withPayload ("test" ).build ();
95
94
DirectChannel inputChannel = new DirectChannel ();
96
95
QueueChannel outputChannel = new QueueChannel (1 );
@@ -105,7 +104,7 @@ public void correlationIdCopiedFromMessageId() {
105
104
}
106
105
107
106
@ Test
108
- public void splitMessageWithEmptyCollectionPayload () throws Exception {
107
+ void splitMessageWithEmptyCollectionPayload () {
109
108
Message <List <String >> message = MessageBuilder .withPayload (Collections .<String >emptyList ()).build ();
110
109
QueueChannel replyChannel = new QueueChannel ();
111
110
DefaultMessageSplitter splitter = new DefaultMessageSplitter ();
@@ -116,7 +115,7 @@ public void splitMessageWithEmptyCollectionPayload() throws Exception {
116
115
}
117
116
118
117
@ Test
119
- public void splitStream () {
118
+ void splitStream () {
120
119
Message <?> message = new GenericMessage <>(
121
120
Stream .generate (Math ::random )
122
121
.limit (10 ));
@@ -133,7 +132,7 @@ public void splitStream() {
133
132
}
134
133
135
134
@ Test
136
- public void splitFlux () {
135
+ void splitFlux () {
137
136
Message <?> message = new GenericMessage <>(
138
137
Flux
139
138
.generate (() -> 0 ,
@@ -159,7 +158,7 @@ public void splitFlux() {
159
158
}
160
159
161
160
@ Test
162
- public void splitArrayPayloadReactive () {
161
+ void splitArrayPayloadReactive () {
163
162
Message <?> message = new GenericMessage <>(new String [] { "x" , "y" , "z" });
164
163
FluxMessageChannel replyChannel = new FluxMessageChannel ();
165
164
DefaultMessageSplitter splitter = new DefaultMessageSplitter ();
@@ -174,14 +173,13 @@ public void splitArrayPayloadReactive() {
174
173
175
174
StepVerifier .create (testFlux )
176
175
.expectNext ("x" , "y" , "z" )
177
- .then (() ->
178
- ((Subscriber <?>) TestUtils .getPropertyValue (replyChannel , "subscribers" , List .class ).get (0 ))
179
- .onComplete ())
180
- .verifyComplete ();
176
+ .expectNoEvent (Duration .ofMillis (100 ))
177
+ .thenCancel ()
178
+ .verify (Duration .ofSeconds (1 ));
181
179
}
182
180
183
181
@ Test
184
- public void splitStreamReactive () {
182
+ void splitStreamReactive () {
185
183
Message <?> message = new GenericMessage <>(Stream .of ("x" , "y" , "z" ));
186
184
FluxMessageChannel replyChannel = new FluxMessageChannel ();
187
185
DefaultMessageSplitter splitter = new DefaultMessageSplitter ();
@@ -196,14 +194,13 @@ public void splitStreamReactive() {
196
194
197
195
StepVerifier .create (testFlux )
198
196
.expectNext ("x" , "y" , "z" )
199
- .then (() ->
200
- ((Subscriber <?>) TestUtils .getPropertyValue (replyChannel , "subscribers" , List .class ).get (0 ))
201
- .onComplete ())
202
- .verifyComplete ();
197
+ .expectNoEvent (Duration .ofMillis (100 ))
198
+ .thenCancel ()
199
+ .verify (Duration .ofSeconds (1 ));
203
200
}
204
201
205
202
@ Test
206
- public void splitFluxReactive () {
203
+ void splitFluxReactive () {
207
204
Message <?> message = new GenericMessage <>(Flux .just ("x" , "y" , "z" ));
208
205
FluxMessageChannel replyChannel = new FluxMessageChannel ();
209
206
DefaultMessageSplitter splitter = new DefaultMessageSplitter ();
@@ -218,10 +215,9 @@ public void splitFluxReactive() {
218
215
219
216
StepVerifier .create (testFlux )
220
217
.expectNext ("x" , "y" , "z" )
221
- .then (() ->
222
- ((Subscriber <?>) TestUtils .getPropertyValue (replyChannel , "subscribers" , List .class ).get (0 ))
223
- .onComplete ())
224
- .verifyComplete ();
218
+ .expectNoEvent (Duration .ofMillis (100 ))
219
+ .thenCancel ()
220
+ .verify (Duration .ofSeconds (1 ));
225
221
}
226
222
227
223
}
0 commit comments