INT-2666 Fix NPE in SimpleMessageStore
INT-2666 polished test Polishing
This commit is contained in:
committed by
Gary Russell
parent
b429e1ff2d
commit
760c488e41
@@ -1,17 +1,20 @@
|
||||
package org.springframework.integration.store;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* @author Iwein Fuld
|
||||
* @author Oleg Zhurakousky
|
||||
@@ -19,7 +22,7 @@ import static org.junit.Assert.assertThat;
|
||||
*/
|
||||
public class SimpleMessageGroupTests {
|
||||
|
||||
private Object key = new Object();
|
||||
private final Object key = new Object();
|
||||
|
||||
private SimpleMessageGroup group = new SimpleMessageGroup(Collections.<Message<?>> emptyList(), key);
|
||||
|
||||
@@ -53,4 +56,16 @@ public class SimpleMessageGroupTests {
|
||||
group.add(message2);
|
||||
assertThat(group.canAdd(message1), is(true));
|
||||
}
|
||||
|
||||
@Test // shoudl not fail with NPE (see INT-2666)
|
||||
public void shouldIgnoreNullValuesWhenInitializedWithCollectionContainingNulls() throws Exception{
|
||||
Message<?> m1 = mock(Message.class);
|
||||
Message<?> m2 = mock(Message.class);
|
||||
final List<Message<?>> messages = new ArrayList<Message<?>>();
|
||||
messages.add(m1);
|
||||
messages.add(null);
|
||||
messages.add(m2);
|
||||
SimpleMessageGroup grp = new SimpleMessageGroup(messages, 1);
|
||||
assertEquals(2, grp.getMessages().size());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user