0

我正在编写用于AutoBeanCodex编码和解码AutoBeans的测试。当我尝试测试使用的方法时AutoBeanCodex.decode(...),我收到如下错误:

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 ...

第一个问题是如何处理AutoBeanCodex我的 gwtmockito 测试?

我是否必须使用这样的假提供者,GwtMockito.useProviderForType(Class, FakeProvider)

如果有多种处理方法AutoBeanCodex,最好的方法是什么?

4

2 回答 2

0

先验(我还没有使用过 GwtMockito),你应该配置一个FakeProviderforAutoBeanFactory.class来委托,AutoBeanFactorySource.create()这样你就可以获得真正的AutoBean 实例,它AutoBeanCodex应该能够序列化和反序列化。

您可能应该向 GwtMockito 提出问题,以便这种行为是内置的,就像 UiBinder 等人一样。

于 2014-01-15T09:42:06.170 回答
0

您还可以使用 powermock 进行静态测试。我在同一个测试中将它与 gwtmockito 一起使用

于 2015-01-20T11:10:37.820 回答