@Test
  public void testMailRollsOff() {
    MailMessage firstMessage = new MailMessageImpl();
    firstMessage.appendBody("First Post!");
    mailStore.addMessage(firstMessage);

    assertEquals("First Post!", mailStore.getMessage(0).getBody());
    for (int i = 0; i < 100; i++) {
      addAMessage();
    }

    assertEquals(100, mailStore.getEmailCount());
    assertEquals("", mailStore.getMessage(0).getBody());
  }
 @Test
 public void testGettingMailFromEmptyMailStoreThrowsIndexOutOfBounds() {
   try {
     mailStore.getMessage(0);
     fail("Should have raised exception.");
   } catch (IndexOutOfBoundsException ignored) {
   }
 }
Exemple #3
0
 public void anticipateMessageCountFor(int messageCount, int ticks) {
   int tickdown = ticks;
   while (mailStore.getEmailCount() < messageCount && tickdown > 0) {
     tickdown--;
     try {
       Thread.sleep(1);
     } catch (InterruptedException e) {
       return;
     }
   }
 }
Exemple #4
0
 public int getEmailCount() {
   return mailStore.getEmailCount();
 }
Exemple #5
0
 public MailMessage getMessage(int i) {
   return mailStore.getMessage(i);
 }
Exemple #6
0
 public MailMessage[] getMessagesFor(String recipient) {
   // TODO Is there a way to implement this without any interface change?
   return mailStore instanceof RecipientMailStore
       ? ((RecipientMailStore) mailStore).getMessageFor(recipient)
       : mailStore.getMessages();
 }
Exemple #7
0
 public MailMessage[] getMessages() {
   return mailStore.getMessages();
 }
 @Test
 public void testGettingMail0FromMailStoreWithAnItemWorks() {
   addAMessage();
   assertNotNull(mailStore.getMessage(0));
 }
 @Test
 public void testAddOneMessageLeavesOneMailInMailMessagesArray() {
   addAMessage();
   assertEquals(1, mailStore.getMessages().length);
 }
 @Test
 public void testNewMailStoreHasEmptyMailList() {
   assertEquals(0, mailStore.getMessages().length);
 }
 private void addAMessage() {
   MailMessage message = new MailMessageImpl();
   mailStore.addMessage(message);
 }
 @Test
 public void testAddOneMessageLeavesOneMail() {
   addAMessage();
   assertEquals(1, mailStore.getEmailCount());
 }
 @Test
 public void testNewMailStoreHasNoMail() {
   assertEquals(0, mailStore.getEmailCount());
 }