title: PowerMock: how to mock static methods which have the same name in a class?
body: <p>Today I'm working on a class with two static methods which have same name, different parameter types. When I try to mock one of the methods, I encounter this problem.</p>
  
  <p>This is the class to be mocked:</p>
  
  <pre><code>//RequestUtil.java, I want to mock the second config method
  public class RequestUtil {
      public static void config(String request, List parameters){}
      public static void config(HttpServletRequest request, List parameters){}
  }
  </code></pre>
  
  <p>This is the test class:</p>
  
  <pre><code>//RequestUtilTest.java
  @RunWith(PowerMockRunner.class)
  @PrepareForTest(RequestUtil.class)
  public class RequestUtilTest {
      //this test will throw NullPointException
      @Test
      public void testConfig() throws Exception {
          mockStatic(RequestUtil.class);
          doNothing().when(RequestUtil.class, "config", any(HttpServletRequest.class), anyList());
      }
  } 
  </code></pre>
  
  <p>Run this test, and it will throw exceptions:</p>
  
  <pre><code>java.lang.NullPointerException
      at java.lang.Class.isAssignableFrom(Native Method)
      at org.powermock.reflect.internal.WhiteboxImpl.checkIfParameterTypesAreSame(WhiteboxImpl.java:2432)
      at org.powermock.reflect.internal.WhiteboxImpl.getMethods(WhiteboxImpl.java:1934)
      at org.powermock.reflect.internal.WhiteboxImpl.getBestMethodCandidate(WhiteboxImpl.java:1025)
      at org.powermock.reflect.internal.WhiteboxImpl.findMethodOrThrowException(WhiteboxImpl.java:948)
      at org.powermock.reflect.internal.WhiteboxImpl.doInvokeMethod(WhiteboxImpl.java:882)
      at org.powermock.reflect.internal.WhiteboxImpl.invokeMethod(WhiteboxImpl.java:859)
      at org.powermock.reflect.Whitebox.invokeMethod(Whitebox.java:466)
      at org.powermock.api.mockito.internal.expectation.PowerMockitoStubberImpl.when(PowerMockitoStubberImpl.java:106)
     ...
  </code></pre>
  
  <p>This exception is caused by:</p>
  
  <pre><code>doNothing().when(RequestUtil.class, "config", any(HttpServletRequest.class), anyList());
  </code></pre>
  
  <p>However, if I mock the first config method, that means, replace this line with:</p>
  
  <pre><code>doNothing().when(RequestUtil.class, "config", anyString(), anyList());
  </code></pre>
  
  <p>everything is Ok.</p>
  
  <p>The order of the config methods in the defination of RequestUtil class has nothing to do with this issue. No matter config(HttpServletRequest, List) is the first or second config method of RequestUtil, the mock of config(HttpServletRequest, List) will be failure.</p>
  
  <p>Also, if I modify the HttpServletRequest to another "simpler" type, such as int, this issue disappears. </p>
  
  <p>It seems to be a bug of PowerMock, but I'm not sure. I searched Google and stackoverflow, but there are no post or discuss on this issue. So anyone can help me?</p>
  
  <p>Test frameworks I use:</p>
  
  <pre><code>JUnit: 4.10
  PowerMock: 1.5.4
  Mockito: 1.9.5
  </code></pre>