INT-2666 Fix NPE in SimpleMessageStore

INT-2666 polished test

Polishing
This commit is contained in:
Oleg Zhurakousky
2012-07-12 12:50:04 -04:00
committed by Gary Russell
parent b429e1ff2d
commit 760c488e41
2 changed files with 39 additions and 22 deletions

View File

@@ -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());
}
}