Unknow 'match not found' error, and non matching results
I have an unexpected 'no match found' and we dont understand this error.
The interface I am mocking is the following. The notifyTvStatus method is invoked by another thread than the one the thread wich sets the 'expects' at the mock object.
public interface TvUpdateListener {
public void notifyTvStatus(final String ipAddress, final boolean isStandby, final short channel);
}
I wrote the following testcase:
/**
* Test the selection of multiple channels
*/
public void testChannelSelection() {
// set up
final Mock mockTvListener = mock(TvUpdateListener.class);
mockTvListener.expects(atLeastOnce()).method("notifyTvStatus").with(eq("172.16.30.183"), eq(false), eq(2));
mockTvListener.expects(atLeastOnce()).method("notifyTvStatus").with(eq("172.16.30.183"), eq(false), eq(1));
// Select channel 1
tvProxy.selectChannel(1);
}
I expect the selectChannelCommand to invoke a callback on a subscribed TvUpdateListener. The asynchronously callback is done by a different thread. When this callback arrives at the mock object we get an unexpected error:
org.jmock.core.DynamicMockError: mockTvUpdateListener: no match found
Invoked: com.philips.cebds.driver.TvUpdateListener.notifyTvStatus(<172.16.30.183>, <false>, <1>)
Allowed:
expected at least once: notifyTvStatus( eq(<172.16.30.183>), eq(<false>), eq(<2>) ), is void
expected at least once: notifyTvStatus( eq(<172.16.30.183>), eq(<false>), eq(<1>) ), is void
at org.jmock.core.AbstractDynamicMock.mockInvocation(Unknown Source)
at org.jmock.core.CoreMock.invoke(Unknown Source)
at $Proxy0.notifyTvStatus(Unknown Source)
at com.philips.cebds.driver.RespondsServer.notifyTvStatus(RespondsServer.java:395)
at com.philips.cebds.driver.RespondsServer.parseHeader040101(RespondsServer.java:497)
at com.philips.cebds.driver.RespondsServer$SocketSessionThread.run(RespondsServer.java:221)
at java.lang.Thread.run(Unknown Source)
I don't understand why the mock object detects a mismatch.
Does anybody has a solution/explanation?