开发者

Spoofing postMethod (apache in java)?

Im fairly new to this so please dont slam me down.

I'm trying to mock a Postmethod so that I can set the status it returns开发者_如何学C. For instance I want to set my PostMethod to 200.

The reason for doing this is I am trying to mock a computer without an internet connection

Thanks in advance


What mocking library are you using? The syntax will vary.

In Mockito, for example, you might do the following:

final PostMethod mockPostMethod = Mockito.mock(PostMethod.class);
when(mockPostMethod.execute(Mockito.any(HttpState.class),
    Mockito.any(HttpConnection.class))).thenReturn(200);

And of course you could use a static import of the Mockito class to avoid the extra qualified references.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜