title: PowerMockito.doReturn returns null
body: <p>This is my class under test:</p>
  
  <pre><code>public class A {
  
  public Integer callMethod(){
    return someMethod();
  }
  
  
  private Integer someMethod(){
    //Some Code
    HttpPost httpPost = new HttpPost(oAuthMessage.URL);
    //Some Code
    HttpClient httpClient = new DefaultHttpClient();
    HttpResponse httpResponse = httpClient.execute(httpPost); ------1
    Integer code = httpResponse.getStatusLine().getStatusCode(); ---2
    return code;
  }
  </code></pre>
  
  <p>Now I want to mock the line 1 &amp; 2 &amp; return a mock HttpResponse &amp; code.</p>
  
  <p>I have tried this but failed:</p>
  
  <pre><code>@RunWith(PowerMockRunner.class)
  @PowerMockIgnore("javax.crypto.*")
  public class TestA {
  
  //Spying some things here &amp; Injecting them
  
  @Test
  public void testA() {
  
  
     DefaultHttpClient defaultHttpClientMock = PowerMockito.mock(DefaultHttpClient.class);
     HttpResponse httpResponse = PowerMockito.mock(HttpResponse.class, RETURNS_DEEP_STUBS);
     HttpClient httpClient = PowerMockito.mock(HttpClient.class);
     //HttpResponse httpResponseMock    PowerMockito.mock(HttpResponse.class);
     HttpPost httpPost = PowerMockito.mock(HttpPost.class);
     PowerMockito.whenNew(DefaultHttpClient.class).withNoArguments().thenReturn(defaultHttpClientMock);
     PowerMockito.doReturn(httpResponse).when(httpClient).execute(httpPost);      //Returns null. It never returns httpResponse.
     PowerMockito.when(httpResponse.getStatusLine().getStatusCode()).thenReturn(anyInt());
     //call the method
  }
  </code></pre>
  
  <p><code>PowerMockito.doReturn(httpResponse).when(httpClient).execute(httpPost)</code> always returns null. I want it to return the mock object of <code>HttpResponse</code>.
  I have read other posts related to this error but not sure what to do in my case. Can anyone help?</p>