@@ -145,22 +145,18 @@ void testContainerPatternResubscribe() {
145
145
container .addMessageListener (anotherListener , new PatternTopic (PATTERN ));
146
146
147
147
// Wait for async subscription tasks to setup
148
- await ().atMost (Duration .ofMillis (600 )).untilAsserted (() -> {
149
- // test no messages are sent just to patterns
150
- assertThat (template .convertAndSend (CHANNEL , payload1 )).isEqualTo (1L );
151
- assertThat (template .convertAndSend (ANOTHER_CHANNEL , payload2 )).isEqualTo (1L );
152
- });
148
+ // test no messages are sent just to patterns
149
+ template .convertAndSend (CHANNEL , payload1 );
150
+ template .convertAndSend (ANOTHER_CHANNEL , payload2 );
153
151
154
152
await ().atMost (Duration .ofSeconds (2 )).until (() -> bag2 .contains (payload1 ) && bag2 .contains (payload2 ));
155
153
156
154
// bind original listener on another channel
157
155
container .addMessageListener (adapter , new ChannelTopic (ANOTHER_CHANNEL ));
158
156
159
157
// Wait for async subscription tasks to setup
160
- await ().atMost (Duration .ofMillis (400 )).untilAsserted (() -> {
161
- assertThat (template .convertAndSend (CHANNEL , payload1 )).isEqualTo (1L );
162
- assertThat (template .convertAndSend (ANOTHER_CHANNEL , payload2 )).isEqualTo (2L );
163
- });
158
+ template .convertAndSend (CHANNEL , payload1 );
159
+ template .convertAndSend (ANOTHER_CHANNEL , payload2 );
164
160
165
161
await ().atMost (Duration .ofSeconds (2 )).until (() -> bag .contains (payload2 ));
166
162
@@ -183,17 +179,13 @@ void testContainerChannelResubscribe() {
183
179
container .addMessageListener (adapter , new ChannelTopic (ANOTHER_CHANNEL ));
184
180
container .removeMessageListener (null , new ChannelTopic (CHANNEL ));
185
181
186
- // timing: There's currently no other way to synchronize
187
- // than to hope the subscribe/unsubscribe are executed within the time.
188
- await ().atMost (Duration .ofMillis (400 )).untilAsserted (() -> {
189
- // Listener removed from channel
190
- assertThat (template .convertAndSend (CHANNEL , payload1 )).isEqualTo (0L );
191
- assertThat (template .convertAndSend (CHANNEL , payload2 )).isEqualTo (0L );
182
+ // Listener removed from channel
183
+ template .convertAndSend (CHANNEL , payload1 );
184
+ template .convertAndSend (CHANNEL , payload2 );
192
185
193
- // Listener receives messages on another channel
194
- assertThat (template .convertAndSend (ANOTHER_CHANNEL , anotherPayload1 )).isEqualTo (1L );
195
- assertThat (template .convertAndSend (ANOTHER_CHANNEL , anotherPayload2 )).isEqualTo (1L );
196
- });
186
+ // Listener receives messages on another channel
187
+ template .convertAndSend (ANOTHER_CHANNEL , anotherPayload1 );
188
+ template .convertAndSend (ANOTHER_CHANNEL , anotherPayload2 );
197
189
198
190
await ().atMost (Duration .ofSeconds (2 )).until (() -> bag .contains (anotherPayload1 ) && bag .contains (anotherPayload2 ));
199
191
}
@@ -215,12 +207,8 @@ void testInitializeContainerWithMultipleTopicsIncludingPattern() {
215
207
Arrays .asList (new Topic [] { new ChannelTopic (uniqueChannel ), new PatternTopic ("s*" ) }));
216
208
container .start ();
217
209
218
- // timing: There's currently no other way to synchronize
219
- // than to hope the subscribe/unsubscribe are executed within the time.
220
- await ().atMost (Duration .ofMillis (250 )).untilAsserted (() -> {
221
- assertThat (template .convertAndSend ("somechannel" , "HELLO" )).isEqualTo (1L );
222
- assertThat (template .convertAndSend (uniqueChannel , "WORLD" )).isEqualTo (1L );
223
- });
210
+ assertThat (template .convertAndSend ("somechannel" , "HELLO" )).isEqualTo (1L );
211
+ assertThat (template .convertAndSend (uniqueChannel , "WORLD" )).isEqualTo (1L );
224
212
225
213
await ().atMost (Duration .ofSeconds (2 )).until (() -> bag .contains ("HELLO" ) && bag .contains ("WORLD" ));
226
214
}
0 commit comments