我认为在EasyMock v3.2(http://jira.codehaus.org/browse/EASYMOCK-113)中解决了StackOverFlowError。我在使用v3.3时遇到此错误。在编写测试用例时,是否有人有解决方案?
java.lang.StackOverflowError
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:143)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:65)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:40)
at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:94)
at org.easymock.internal.ClassProxyFactory$MockMethodInterceptor.intercept(ClassProxyFactory.java:97)
at org.springframework.security.providers.UsernamePasswordAuthenticationToken$$EnhancerByCGLIB$$7f8efe81.getAuthorities(<generated>)
at org.springframework.security.providers.AbstractAuthenticationToken.equals(AbstractAuthenticationToken.java:80)
at org.springframework.security.providers.UsernamePasswordAuthenticationToken$$EnhancerByCGLIB$$7f8efe81.CGLIB$equals$3(<generated>)
at org.springframework.security.providers.UsernamePasswordAuthenticationToken$$EnhancerByCGLIB$$7f8efe81$$FastClassByCGLIB$$ba75b65d.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.easymock.internal.ClassProxyFactory$MockMethodInterceptor.intercept(ClassProxyFactory.java:94)
at org.springframework.security.providers.UsernamePasswordAuthenticationToken$$EnhancerByCGLIB$$7f8efe81.equals(<generated>)
at org.easymock.internal.Invocation.equals(Invocation.java:99)
at org.easymock.internal.ExpectedInvocation.equals(ExpectedInvocation.java:74)
at org.easymock.internal.UnorderedBehavior.allowsExpectedInvocation(UnorderedBehavior.java:108)
at org.easymock.internal.MocksBehavior.addBehaviorListIfNecessary(MocksBehavior.java:74)
at org.easymock.internal.MocksBehavior.addExpected(MocksBehavior.java:60)
at org.easymock.internal.RecordState.times(RecordState.java:192)
at org.easymock.internal.RecordState.closeMethod(RecordState.java:234)
at org.easymock.internal.RecordState.invoke(RecordState.java:76)
at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:40)
at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:94)
at org.easymock.internal.ClassProxyFactory$MockMethodInterceptor.intercept(ClassProxyFactory.java:97)
at org.springframework.security.providers.UsernamePasswordAuthenticationToken$$EnhancerByCGLIB$$7f8efe81.getAuthorities(<generated>)
at org.springframework.security.providers.AbstractAuthenticationToken.equals(AbstractAuthenticationToken.java:80)
at org.springframework.security.providers.UsernamePasswordAuthenticationToken$$EnhancerByCGLIB$$7f8efe81.CGLIB$equals$3(<generated>)
at org.springframework.security.providers.UsernamePasswordAuthenticationToken$$EnhancerByCGLIB$$7f8efe81$$FastClassByCGLIB$$ba75b65d.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.easymock.internal.ClassProxyFactory$MockMethodInterceptor.intercept(ClassProxyFactory.java:94)
at org.springframework.security.providers.UsernamePasswordAuthenticationToken$$EnhancerByCGLIB$$7f8efe81.equals(<generated>)
at org.easymock.internal.Invocation.equals(Invocation.java:99)
at org.easymock.internal.ExpectedInvocation.equals(ExpectedInvocation.java:74)
at org.easymock.internal.UnorderedBehavior.allowsExpectedInvocation(UnorderedBehavior.java:108)
at org.easymock.internal.MocksBehavior.addBehaviorListIfNecessary(MocksBehavior.java:74)
at org.easymock.internal.MocksBehavior.addExpected(MocksBehavior.java:60)
at org.easymock.internal.RecordState.times(RecordState.java:192)
at org.easymock.internal.RecordState.closeMethod(RecordState.java:234)
at org.easymock.internal.RecordState.invoke(RecordState.java:76)
.
.
.
答案 0 :(得分:0)
发布此问题后,我在堆栈跟踪中注意到正在调用“getAuthorties()”方法。我模仿了对此方法的响应,如下所示,并消除了StackOverFlowError。
EasyMock.expect(mockNamePwdAuthToken.getAuthorities()).andReturn(
null);