[JUnit + EasyMock] How to check, did mock method was call correct?

C

Czterysta Czwarty

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=\"(e-mail address removed)
\"><body>Wiadomość!</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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top