Closed GoogleCodeExporter closed 8 years ago
Well I don't think there's a solution for that yet, unless you have a
deserializer that knows better about CGLIB classes.
It's actually expected, CGLIB are generated in memory using a custom
classloader to pass over the bytecode to the JVM. In a new JVM, if the CGLIB
class is not found then or even if Mockito isn't in the class path it couldn't
even work.
At the moment I'm not sure if it's even doable using the standard serialization
API, though it might be worth investigating writeReplace / readResolve, but
you'll need Mockito in the classpath on both JVM of course.
Original comment by brice.du...@gmail.com
on 23 Oct 2012 at 8:44
Yes mockito must be on the classpath on both JVM. There are a few posts out
there like
http://tech.thecoolblogs.com/2010/12/how-to-serialize-and-de-serialize-cglib.htm
l
or http://i-proving.com/2008/02/11/the-pitfalls-of-dynamic-proxy-serialization/
discussing the deserialization of cg proxies. One possible solution is indeed
to override writeReplace / readResolve and thereby recreate the cg proxy
wrapper on deserialization.
IHMO mockito could / should do it that way, and hopefully deserialization on an
application server will work.
Original comment by ske...@gmail.com
on 23 Oct 2012 at 10:02
Cool, thx for the links :)
I'm a bit busy atm, I'm not sure I'll have time to work on this feature in near
time, but if you'd like to begin some work we'll be glad to help and integrate
it if it's working properly and follows Mockito principles.
Original comment by brice.du...@gmail.com
on 23 Oct 2012 at 11:15
Original comment by brice.du...@gmail.com
on 27 Nov 2012 at 5:08
Hi,
Just to let you know that I got something working, due to the nature of mocks
there are a few other stuff to do. Strangely enough I completely forgot your
links when working on it, and I found they followed the same approach I took,
although there was some other challenges to just make the serialization work
with mocks.
When I'll have more free time I will address the remaining issues.
Also keep in mind there could be issues that I didn't have foreseen atm. So it
might not be perfect.
Cheers,
Brice
Original comment by brice.du...@gmail.com
on 3 Dec 2012 at 9:25
Hey,
Take a look at our github, I recently merged the code that performs
serialization in a way that enable a mock to be deserialized in another
classloader / JVM
https://github.com/mockito/mockito/commit/eaea9467f546f37fbeb16b128808d791a7836e
b9
It would be awesome if you try it, report issues, performance, etc...
Cheers,
Brice
Original comment by brice.du...@gmail.com
on 8 Jan 2013 at 4:46
Issue 268 has been merged into this issue.
Original comment by brice.du...@gmail.com
on 8 Jan 2013 at 4:49
Issue 268 has been merged into this issue.
Original comment by brice.du...@gmail.com
on 8 Feb 2013 at 2:51
Original comment by szcze...@gmail.com
on 16 Aug 2014 at 2:43
Original comment by szcze...@gmail.com
on 24 Aug 2014 at 3:14
Original comment by szcze...@gmail.com
on 24 Aug 2014 at 3:50
Original issue reported on code.google.com by
ske...@gmail.com
on 23 Oct 2012 at 7:17