You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Have one Class under Test with @RooJpaActiveRecord Annotation, so that it gets
"declare @type: TestClass: @configurable;" via roo
Create a test with: @RunWith(PowerMockRunner.class)
@PrepareForTest(TestClass.class)
PowerMockito.mockStatic(TestClass.class)
Create a new object calling new TestClass()
What is the expected output?
The object gets created
What do you see instead?
java.lang.NullPointerException
at org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect.ajc$if$bb0(AnnotationBeanConfigurerAspect.aj:1)
at test.TestClass.<init>(TestClass.java:6)
at test.PowermockTest.test_aroundBody0(PowermockTest.java:23)
at test.PowermockTest.test(PowermockTest.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:68)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:316)
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:300)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:131)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.access$100(PowerMockJUnit47RunnerDelegateImpl.java:59)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner$TestExecutorStatement.evaluate(PowerMockJUnit47RunnerDelegateImpl.java:147)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.evaluateStatement(PowerMockJUnit47RunnerDelegateImpl.java:107)
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:288)
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:208)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:147)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:121)
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:123)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:121)
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.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
What version of the product are you using?
Powermock 1.6.5 (LATEST at this time):
powermock-module-junit4
powermock-api-mockito
powermock-module-junit4-rule
powermock-classloading-xstream
junit 4.12 (LATEST)
mockito-all 1.10.19 (LATEST; also tried with 2.0.2-beta)
spring-aspects-4.2.6.RELEASE (LATEST)
On what operating system?
Linux Mint 17.3
Oracle Java 1.7.0_80
Please provide any additional information below.
In MockGateway, doMethodCall: shouldMockMethod(methodName, sig) should return false
The annotation methods should not be mocked and instead proceed to call the actual method.
Right now, they return mocked values.
isAnnotationPresent returns false, getAnnotation returns null.
Because of this, the code in AnnotationBeanConfigurerAspect (spring-aspects), returns a NPE here:
public static final boolean ajc$if$bb0(Configurable c) {
return c.preConstruction();
}
The text was updated successfully, but these errors were encountered:
ssaip
pushed a commit
to ssaip/powermock
that referenced
this issue
Jun 9, 2016
What steps will reproduce the problem?
"declare @type: TestClass: @configurable;" via roo
@RunWith(PowerMockRunner.class)
@PrepareForTest(TestClass.class)
PowerMockito.mockStatic(TestClass.class)
Create a new object calling new TestClass()
(I have a ready to use example @ Stackoverflow)
What is the expected output?
The object gets created
What do you see instead?
What version of the product are you using?
Powermock 1.6.5 (LATEST at this time):
powermock-module-junit4
powermock-api-mockito
powermock-module-junit4-rule
powermock-classloading-xstream
junit 4.12 (LATEST)
mockito-all 1.10.19 (LATEST; also tried with 2.0.2-beta)
spring-aspects-4.2.6.RELEASE (LATEST)
On what operating system?
Linux Mint 17.3
Oracle Java 1.7.0_80
Please provide any additional information below.
In MockGateway, doMethodCall:
shouldMockMethod(methodName, sig)
should return falseThe annotation methods should not be mocked and instead proceed to call the actual method.
Right now, they return mocked values.
isAnnotationPresent returns false, getAnnotation returns null.
Because of this, the code in AnnotationBeanConfigurerAspect (spring-aspects), returns a NPE here:
The text was updated successfully, but these errors were encountered: