I recently upgraded from jMock 2.5.1 to 2.6.0, and it seems that some of its dependencies have changed, as a result of which some of my previous tests failed.
In one of my tests, there is the following expectation, which is used to generally configure several tests:
oneOf(service).event(with(any(Long.class)));
In my test case, event is event with both null and valid Long values. This was perfectly acceptable in jMock 2.5.1, but after the upgrade, I got the following exception:
java.lang.AssertionError: unexpected invocation: service.event(null) expectations: expected once, never invoked: service.event(an instance of java.lang.Long) what happened before this: locator.locateService() service.getService() at org.jmock.api.ExpectationError.unexpected(ExpectationError.java:23) at org.jmock.internal.InvocationDispatcher.dispatch(InvocationDispatcher.java:85) at org.jmock.Mockery.dispatch(Mockery.java:231) at org.jmock.Mockery.access$100(Mockery.java:29) at org.jmock.Mockery$MockObject.invoke(Mockery.java:271) at org.jmock.internal.InvocationDiverter.invoke(InvocationDiverter.java:27) at org.jmock.internal.FakeObjectMethods.invoke(FakeObjectMethods.java:38) at org.jmock.lib.concurrent.Synchroniser.synchroniseInvocation(Synchroniser.java:82) at org.jmock.lib.concurrent.Synchroniser.access$000(Synchroniser.java:23) at org.jmock.lib.concurrent.Synchroniser$1.invoke(Synchroniser.java:74) at org.jmock.lib.JavaReflectionImposteriser$1.invoke(JavaReflectionImposteriser.java:33) at com.sun.proxy.$Proxy27.system(Unknown Source) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
I suspect this might be due to the new version of Hamcrest that jMock 2.6.0 uses, but I'm not sure. Is there a more suitable helper that I can use to indicate both null and non-null values ββfor this method?
source share