gordonad / powermock

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

expectNew(..).andThrow(..) no longer works with checked exceptions. #18

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
For some reason it seems like the NewInvocationControl has been reverted
and doesn't support checked exceptions anymore. 

NewInvocationControl should probably contain the method 
public T createInstance() *throws Exception*;

Otherwise we'll run into:
java.lang.IllegalArgumentException: last method called on mock cannot throw
java.io.IOException
    at org.easymock.internal.MocksControl.andThrow(MocksControl.java:110)
    atse.myapp.TargetPersistenceManagerTest.testTargetConnect_failsToCreateFileName(TargetPersistenceManagerTest.java:418)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
    at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
    at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
    at
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadi
e.java:87)
    at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.in
vokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:162)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.ru
nMethods(PowerMockJUnit44RunnerDelegateImpl.java:119)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.
run(PowerMockJUnit44RunnerDelegateImpl.java:112)
    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.ru
n(PowerMockJUnit44RunnerDelegateImpl.java:110)
    at
org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run
(JUnit4TestSuiteChunkerImpl.java:74)
    at
org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.
run(AbstractCommonPowerMockRunner.java:43)
    at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReferen
ce.java:45)
    at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner
.java:460)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner
.java:673)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java
:386)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.jav
a:196)

It doesn't seem like the ExpectNewDemoTest#testNewWithCheckedException test
case tests for checked exceptions at all!!!

Original issue reported on code.google.com by johan.ha...@gmail.com on 1 Oct 2008 at 8:34

GoogleCodeExporter commented 9 years ago
Fixed so that expectNew(..).andThrow(..) supports checked exceptions

Original comment by johan.ha...@gmail.com on 1 Oct 2008 at 5:14