1 19 20 package org.apache.james.mailboxmanager.wrapper; 21 22 import org.apache.james.mailboxmanager.GeneralMessageSet; 23 import org.apache.james.mailboxmanager.MailboxManagerException; 24 import org.apache.james.mailboxmanager.MessageResult; 25 import org.apache.james.mailboxmanager.impl.MessageResultImpl; 26 import org.apache.james.mailboxmanager.mailbox.GeneralMailbox; 27 import org.jmock.Mock; 28 import org.jmock.MockObjectTestCase; 29 import org.jmock.core.Constraint; 30 import org.jmock.core.constraint.IsEqual; 31 import org.jmock.core.constraint.IsInstanceOf; 32 import org.jmock.core.constraint.IsSame; 33 34 public class SessionMailboxWrapperTest extends MockObjectTestCase { 35 36 public void testAddsAndRemovesListener() throws MailboxManagerException { 37 38 SessionMailboxWrapper sessionMailboxWrapper = new SessionMailboxWrapper(); 39 40 Mock generalMailboxMock = mock(GeneralMailbox.class); 41 Constraint[] listenerArgs={new IsSame(sessionMailboxWrapper.getListenerObject()),new IsEqual(new Integer (MessageResult.UID))}; 42 43 generalMailboxMock.expects(once()).method("addListener").with(listenerArgs); 44 45 Constraint[] getMessagesArgs={new IsInstanceOf(GeneralMessageSet.class),new IsInstanceOf(Integer .class)}; 46 47 MessageResult[] result={new MessageResultImpl()}; 48 49 generalMailboxMock.expects(once()).method("getMessages").with(getMessagesArgs).after("addListener").will(returnValue(result)); 50 generalMailboxMock.expects(once()).method("removeListener").with(listenerArgs[0]).after("getMessages"); 51 52 sessionMailboxWrapper.setMailbox((GeneralMailbox) generalMailboxMock 53 .proxy()); 54 sessionMailboxWrapper.init(); 55 sessionMailboxWrapper.close(); 56 } 57 58 } 59 | Popular Tags |