我正在尝试用 Mockito 模拟 Jersey WebResource,但做不到
这是我的代码(Jersey 1.4 + Mockito 1.8.5):
import org.junit.Test;
import static org.junit.Assert.*;
import com.sun.jersey.api.client.WebResource;
import static org.mockito.Mockito.*;
public FooTest {
@Test public shouldMakeAHttpCall() {
WebResource wr = mock(WebResource.class);
doReturn(wr).when(wr).accept(anyVararg());
doReturn("some text").when(wr).get(String.class);
}
}
编译器说:
cannot find symbol: method accept(java.lang.Object)
location: class com.sun.jersey.api.client.WebResource
anyVargarg()
有问题,但是什么确切地?
This is my code (Jersey 1.4 + Mockito 1.8.5):
import org.junit.Test;
import static org.junit.Assert.*;
import com.sun.jersey.api.client.WebResource;
import static org.mockito.Mockito.*;
public FooTest {
@Test public shouldMakeAHttpCall() {
WebResource wr = mock(WebResource.class);
doReturn(wr).when(wr).accept(anyVararg());
doReturn("some text").when(wr).get(String.class);
}
}
Compiler says:
cannot find symbol: method accept(java.lang.Object)
location: class com.sun.jersey.api.client.WebResource
There is something wrong with anyVargarg()
, but what exactly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是解决方案:
This is the solution:
你有没有尝试过:
Have you tried: