title: Powermock calling the real method instead of spy one
body: <p>I am facing issue while mocking the private method with powermockito.
  Real method is getting called. 
  I am trying to test a public method which calls private method with URI type parameter and returns String. I tried all the option but it always calling the real method due to that i am getting number format error.</p>
  
  <pre><code>package p;
  import static org.junit.Assert.*;
  import java.io.ByteArrayInputStream;
  import java.io.InputStream;
  import java.io.Reader;
  import java.io.StringReader;
  import java.lang.reflect.Method;
  import java.net.URI;
  import java.util.ArrayList;
  import java.util.List;
  import org.apache.http.client.HttpClient;
  import org.apache.http.client.utils.URIBuilder;
  import org.junit.Before;
  import org.junit.Test;
  import org.mockito.MockitoAnnotations;
  import org.powermock.api.mockito.PowerMockito;
  import com.wb.classics.handler.SearchInputInfo;
  import org.powermock.api.support.membermodification.MemberMatcher.method;
  import org.mockito.Matchers.anyString;
  
  @RunWith(PowerMockRunner.class)
  @PrepareForTest(Test.class)
  public class Test {
  
  
  @Before
  public void setUp() throws Exception {
  
      MockitoAnnotations.initMocks(this);
      // Create an object of a class under test.
      privateMethodClass = new PrivateMethodClass ();
  
  }
  @Test
  public void Test() throws Exception {
  
      URI uri = null;
      URIBuilder builder = new URIBuilder();
      String MPM = "2000081";
      builder.setScheme("http").setHost("localhost").setPort(Integer.valueOf("8000")).setPath("/classic").setParameter("MPM", MPM);
      uri = builder.build();
      System.out.println("uri*********"+uri);
      String jsonstring ="jsonstring";
  
      PrivateMethodClass msspy = PowerMockito.spy(new PrivateMethodClass ());
      System.out.println("msspy***"+msspy);
  
      /*when(msspy, method(PrivateMethodClass .class,"privatemethod", URI.class))
      .withArguments(uri)
      .thenReturn(jsonstring);*/
  
      PowerMockito.doReturn(jsonstring).when(msspy,"privatemethod", uri);
  
       /*PowerMockito.doReturn(true).when(msspy, 
                 method(MarkLogicServices.class, "privatemethod", URI.class))
                  .withArguments(uri);*/
  
      String result= msspy.methodToTest(MPM);
  
      System.out.println("service****"+result);
  
  
  }
  }
  </code></pre>
  
  <p>and the class is </p>
  
  <pre><code>public PrivateMethodClass{
  
  public String methodPublic()
  {
   URI uri="";
   return methodprivate(uri);
  }
  
  
  private String methodprivate(URI uri)
   {
   return str;
  }
  }
  </code></pre>
  
  <p>pom.xml </p>
  
  <pre><code> &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;4.12&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.powermock&lt;/groupId&gt;
          &lt;artifactId&gt;powermock-api-mockito&lt;/artifactId&gt;
          &lt;version&gt;1.6.1&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.powermock&lt;/groupId&gt;
          &lt;artifactId&gt;powermock-module-junit4&lt;/artifactId&gt;
          &lt;version&gt;1.6.1&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.mockito&lt;/groupId&gt;
          &lt;artifactId&gt;mockito-all&lt;/artifactId&gt;
          &lt;version&gt;1.9.5&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>Below is the error message..</p>
  
  <pre><code>   java.lang.NumberFormatException: null
     at java.lang.Integer.parseInt(Unknown Source)
     at java.lang.Integer.valueOf(Unknown Source)
     at   com.wb.classics.handler.services.MarkLogicServices.fetchClassicByMPM(MarkLogicServices.java:132)
  at com.wb.classics.handler.services.MarkLogicServicesTest.fetchClassicByMPMTest(MarkLogicServicesTest.java:159)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  at java.lang.reflect.Method.invoke(Unknown Source)
  at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:68)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:310)
  at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:89)
  at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:97)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:294)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:127)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:282)
  at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:87)
  at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:50)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:207)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:146)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
  at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
  at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:122)
  at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:106)
  at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
  at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59)
  at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
  at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
  </code></pre>