Skip to content

Commit 7432038

Browse files
committed
Some tweaks for SimpleMessageGroupTests
**Cherry-pick to `5.5.x`**
1 parent 4283a55 commit 7432038

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

spring-integration-core/src/test/java/org/springframework/integration/store/SimpleMessageGroupTests.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2022 the original author or authors.
2+
* Copyright 2009-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
2222
import java.util.List;
2323
import java.util.Map;
2424

25-
import org.junit.Test;
25+
import org.junit.jupiter.api.Test;
2626

2727
import org.springframework.integration.support.MessageBuilder;
2828
import org.springframework.messaging.Message;
@@ -45,17 +45,16 @@ public class SimpleMessageGroupTests {
4545

4646
private final Object key = new Object();
4747

48-
private final SimpleMessageGroup group = new SimpleMessageGroup(new ArrayList<Message<?>>(), key);
48+
private final SimpleMessageGroup group = new SimpleMessageGroup(new ArrayList<>(), key);
4949

5050
private MessageGroup sequenceAwareGroup;
5151

52-
@SuppressWarnings("unchecked")
5352
public void prepareForSequenceAwareMessageGroup() throws Exception {
54-
Class<SimpleMessageGroup> clazz =
55-
(Class<SimpleMessageGroup>) Class.forName("org.springframework.integration.aggregator.AbstractCorrelatingMessageHandler$SequenceAwareMessageGroup");
56-
Constructor<SimpleMessageGroup> ctr = clazz.getDeclaredConstructor(MessageGroup.class);
53+
Class<?> clazz =
54+
Class.forName("org.springframework.integration.aggregator.AbstractCorrelatingMessageHandler$SequenceAwareMessageGroup");
55+
Constructor<?> ctr = clazz.getDeclaredConstructor(MessageGroup.class);
5756
ctr.setAccessible(true);
58-
this.sequenceAwareGroup = ctr.newInstance(this.group);
57+
this.sequenceAwareGroup = (MessageGroup) ctr.newInstance(this.group);
5958
}
6059

6160
@Test
@@ -83,13 +82,13 @@ public void shouldIgnoreMessagesWithZeroSequenceNumberIfSequenceAware() throws E
8382
}
8483

8584
@SuppressWarnings("unchecked")
86-
@Test // should not fail with NPE (see INT-2666)
87-
public void shouldIgnoreNullValuesWhenInitializedWithCollectionContainingNulls() throws Exception {
85+
@Test
86+
public void shouldIgnoreNullValuesWhenInitializedWithCollectionContainingNulls() {
8887
Message<?> m1 = mock(Message.class);
8988
willReturn(new MessageHeaders(mock(Map.class))).given(m1).getHeaders();
9089
Message<?> m2 = mock(Message.class);
9190
willReturn(new MessageHeaders(mock(Map.class))).given(m2).getHeaders();
92-
final List<Message<?>> messages = new ArrayList<Message<?>>();
91+
final List<Message<?>> messages = new ArrayList<>();
9392
messages.add(m1);
9493
messages.add(null);
9594
messages.add(m2);
@@ -99,7 +98,7 @@ public void shouldIgnoreNullValuesWhenInitializedWithCollectionContainingNulls()
9998

10099
@Test
101100
// This test used to take 2 min and half to run; now ~200 milliseconds.
102-
public void testPerformance_INT3846() {
101+
public void testPerformance() {
103102
Collection<Message<?>> messages = new ArrayList<>();
104103
for (int i = 0; i < 100000; i++) {
105104
messages.add(new GenericMessage<Object>("foo"));
@@ -108,10 +107,10 @@ public void testPerformance_INT3846() {
108107
StopWatch watch = new StopWatch();
109108
watch.start();
110109
for (Message<?> message : messages) {
111-
group.getMessages().contains(message);
110+
assertThat(group.getMessages().contains(message)).isTrue();
112111
}
113112
watch.stop();
114-
assertThat(watch.getTotalTimeMillis() < 5000).isTrue();
113+
assertThat(watch.getTotalTimeMillis()).isLessThan(5000);
115114
}
116115

117116
}

0 commit comments

Comments
 (0)