google / gwtmockito

Better GWT unit testing
https://google.github.io/gwtmockito
Apache License 2.0
157 stars 51 forks source link

ClassCastException when trying to use AutoBeanCodex #22

Closed strootman closed 7 years ago

strootman commented 10 years ago

I've posted a SO post describing my problem, here. But to restate, I'm getting the following exception when trying to decode some autobeans. java.lang.ClassCastException: com.google.web.bindery.autobean.shared.AutoBean$$EnhancerByMockitoWithCGLIB$$78caf05b cannot be cast to com.google.web.bindery.autobean.shared.impl.AbstractAutoBean at com.google.web.bindery.autobean.shared.impl.AutoBeanCodexImpl.doDecode(AutoBeanCodexImpl.java:549) at com.google.web.bindery.autobean.shared.AutoBeanCodex.decode(AutoBeanCodex.java:39) at ...

I'd like to have actual autobean instances that can be encoded/decoded by the autobean codex. This would allow my to test that my methods which are translating JSON into autobeans are working appropriately.

So, how should I approach this?

ekuefler commented 10 years ago

I'm not very familiar with autobeans - would you mind posting a quick example of some simple autobean code you're trying to test and the tests you might want to write for it?

Thomas's suggestion on stackoverflow to use FakeProvider is a good one. If this works for you and it works the same way for every autobean you might want to create, we could definitely make GwtMockito do this by default so you don't have to configure the FakeProvider yourself.