Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
GWTMockito:如何模仿AutoBeanCodex?_Gwt_Mockito_Autobean - Fatal编程技术网

GWTMockito:如何模仿AutoBeanCodex?

GWTMockito:如何模仿AutoBeanCodex?,gwt,mockito,autobean,Gwt,Mockito,Autobean,我正在编写的测试使用AutoBeanCodex对AutoBeans进行编码和解码。 当我尝试测试使用AutoBeanCodex.decode(…)的方法时,会出现如下错误: java.lang.ClassCastException: com.google.web.bindery.autobean.shared.AutoBean$$EnhancerByMockitoWithCGLIB$$78caf05b cannot be cast to com.google.web.bindery.au

我正在编写的测试使用
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 ...
第一个问题是在gwtmockito测试中如何处理
AutoBeanCodex

我是否必须使用像这样的假提供程序,
GwtMockito.useProviderForType(类,FakeProvider)

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

事先(我还没有使用GwtMockito),您应该为
AutoBeanFactory.class
配置一个
FakeProvider
以委托给
AutoBeanFactorySource.create()
这样您就可以得到真正的AutoBean实例,
AutoBeanCodex
应该能够序列化和反序列化


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

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

我将尝试一下。我一定会向GwtMockito提出这个问题。谢谢向gwtmockito团队提交了一个问题。问题已解决