bobobear / lambdaj

Automatically exported from code.google.com/p/lambdaj
Apache License 2.0
0 stars 0 forks source link

Does not call methods on Mockito mocks #19

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have just been trying out LambdaJ 2.0, checked out from
http://lambdaj.googlecode.com/svn/trunk/ on Mac OS X 10.6.1 (Snow Leopard).

Reproducing the problem.
1. Create a few Mockito mocks of a class. Add them to some collection.
2. Call Lambdaj.forEach(..) with the collection as argument. Call some
method on the returned proxy. I.e: forEach(mocks).someMethod();
3. Use Mockito.verify(..) to check that the method was called once on each
mock.

Expects Mockito.verify(..) to succeed. Instead Mockito fails telling that
there were no interactions with the mocks.

The attached file contains a small Maven project with a testcase showing
the scenario above.

I suspect that there may be some mismatching since both Mockito and LambdaJ
uses CGLIB proxies? Maybe lambdaj is seeing a proxy and thinks it is its
own and thus uses the proxied object instead of the CGLIB proxy coming from
an external source, in this case Mockito.

Thanks for what seems to be a very nice library!

Original issue reported on code.google.com by flobakk on 15 Sep 2009 at 11:11

Attachments:

GoogleCodeExporter commented 9 years ago
The object mocked by mockito (as internally happens in lambdaj) are cglib proxy 
that
by definition are final classes that cannot be proxied again. That's why the
forEach() method (and probably the biggest part of the other lambdaj features) 
cannot
work with the mocks generated by Mockito.

Original comment by mario.fu...@gmail.com on 10 Oct 2009 at 4:42