I\'m trying to mock Apache HttpClient Interface in order to mock one of its methods mentioned below to return a stubbed JSON object in response.
HttpResponse
In your unit test class you need to mock defaultHttpClient:
@Mock
private HttpClient defaultHttpClient;
Then you tell mockito (for example in @Before method) to actually create your mocks by:
MockitoAnnotations.initMocks(YourTestClass);
Then in your test method you define what execute() method should return:
when(defaultHttpClient.execute(any()/* or wahtever you want here */)).thenReturn(stubbed JSON object);