Added MessageStoringInterceptor (INT-264).

This commit is contained in:
Mark Fisher
2008-06-24 15:26:24 +00:00
parent 490a3d9951
commit e24fe02cf0
5 changed files with 138 additions and 0 deletions

View File

@@ -20,6 +20,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.util.List;
import org.junit.Test;
/**
@@ -79,4 +81,33 @@ public class SimpleMessageStoreTests {
assertEquals(message4, store.get(4));
}
@Test
public void testListWhenEmpty() {
SimpleMessageStore store = new SimpleMessageStore(3);
List<Message<?>> list = store.list();
assertNotNull(list);
assertEquals(0, list.size());
}
@Test
public void testListWhenUnderCapacity() {
SimpleMessageStore store = new SimpleMessageStore(3);
store.put(1, new StringMessage("foo"));
store.put(2, new StringMessage("bar"));
List<Message<?>> list = store.list();
assertEquals(2, list.size());
}
@Test
public void testListAfterExceedingCapacity() {
SimpleMessageStore store = new SimpleMessageStore(2);
store.put(1, new StringMessage("foo"));
store.put(2, new StringMessage("bar"));
store.put(3, new StringMessage("baz"));
List<Message<?>> list = store.list();
assertEquals(2, list.size());
assertEquals("bar", list.get(0).getPayload());
assertEquals("baz", list.get(1).getPayload());
}
}