[JUnit + EasyMock] How to check, did mock method was call correct?
Hi everybody!
I'm trying to test my Apache MINA filter with JUnit and EasyMock. Can
you help me?
XMLMappingFilter() should convert XML String to Object.
I defined instance of tested class and 3 mocks:
@Before
public void setUp() throws Exception {
instance = new XMLMappingFilter();
nextFilterMock = createMock(NextFilter.class);
sessionMock = createMock(IoSession.class);
messageMock = createMock(String.class);
instance.messageReceived(nextFilterMock, sessionMock,
messageMock);
}
and try to test:
@Test
public void testMessageReceived() throws Exception {
System.out.println("messageReceived");
//2. record mock
messageMock.toString();
expectLastCall().andReturn("<message username=\"user@domain.com
\"><body>Wiadomo=C5=9B=C4=87!</body></message>");
expect(sessionMock).
//3. replay mocks
replay(nextFilterMock);
replay(sessionMock);
replay(messageMock);
//4.tes
instance.messageReceived(nextFilterMock, sessionMock,
messageMock);
//.....
}
instance.messageReceived() should call
nextFilterMock.messageReceived() with changed new parameters.
My question is: How to check with what parameters this method is
called?
In other words: How to verify, did strings are correctly converting to
objects?