EdwinLi / powermock

Automatically exported from code.google.com/p/powermock
0 stars 0 forks source link

regression for 1.4, java.lang.IllegalArgumentException: type cannot be null #276

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.
a simple example to demonstrate the issue: type cannot be null error

P2.java
----------------------
import java.sql.Connection;

public class P2 {

  protected void establishConnection(Connection conn)
  throws Exception
{
    if (conn== null) return;

}
}

  @Test
  public void testestablishConnection3() throws Exception {
    P2 param=createMock(P2.class);
    Connection conn=null;
    Whitebox.invokeMethod(param, "establishConnection", conn);
  } 
2.
3.

What is the expected output? What do you see instead?
It should work fine, but get following message

java.lang.IllegalArgumentException: type cannot be null
        at
org.powermock.reflect.internal.WhiteboxImpl.getUnmockedType(WhiteboxImpl.java:
1780)
        at
org.powermock.reflect.internal.WhiteboxImpl.getType(WhiteboxImpl.java:
2205)
        at
org.powermock.reflect.internal.WhiteboxImpl.getTypes(WhiteboxImpl.java:
1011)
        at
org.powermock.reflect.internal.WhiteboxImpl.findMethodOrThrowException(WhiteboxI
mpl.java:
962)
        at
org.powermock.reflect.internal.WhiteboxImpl.doInvokeMethod(WhiteboxImpl.java:
890)
        at
org.powermock.reflect.internal.WhiteboxImpl.invokeMethod(WhiteboxImpl.java:
721)
        at org.powermock.reflect.Whitebox.invokeMethod(Whitebox.java:399) 

What version of the product are you using? On what operating system?
powermock 1.4 on windows XP systems. It works properly under powermock 1.3.9

Please provide any additional information below.

Original issue reported on code.google.com by chiiwen@gmail.com on 2 Sep 2010 at 6:02

GoogleCodeExporter commented 9 years ago
For dev: He probably mean to create a partial mock.

Original comment by johan.ha...@gmail.com on 8 Sep 2010 at 9:12

GoogleCodeExporter commented 9 years ago
For dev: He probably mean to create a partial mock.

Original comment by johan.ha...@gmail.com on 8 Sep 2010 at 9:12

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 12 Sep 2010 at 2:36

GoogleCodeExporter commented 9 years ago
User report: It may also happen when using argument matchers in Mockito:

PowerMockito.doReturn(queryReturnList).when(underTest, "findByNamedQuery", 
eq("AbstractPTVTicket.ticketSeatIds"), anyList());

Original comment by johan.ha...@gmail.com on 12 Sep 2010 at 2:37

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 16 Sep 2010 at 6:16

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 10 Oct 2010 at 10:16