easymock 依赖于 net/sf/cglib/proxy/Enhancer 吗?
我正在尝试完成有关 easymock 的教程以首次使用它。 http://www.vogella.de/articles/EasyMock/article.html
我正在使用 - 面向 Java 开发人员的 Eclipse IDE(内部版本号:20100218-1602)
- Junit 4 插件
- easymock 3.0
按照如下所述创建项目并作为 JUNIT 测试执行后,我收到错误。
**java.lang.NoClassDefFoundError: net/sf/cglib/proxy/Enhancer**
这是什么错误?我该如何修复它?它发生在线路上
EasyMock.replay(calcMethod);
java.lang.NoClassDefFoundError: net/sf/cglib/proxy/Enhancer 位于 org.easymock.internal.ClassExtensionHelper.getControl(ClassExtensionHelper.java:57) 在 org.easymock.EasyMock.getControl(EasyMock.java:2068) 处 org.easymock.EasyMock.replay(EasyMock.java:1970) 在 收入.IncomeCalculatorTest.testCalc1(IncomeCalculatorTest.java:33)
在 sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法) 处 sun.reflect.NativeMethodAccessorImpl.invoke(来源未知)位于 sun.reflect.DelegatingMethodAccessorImpl.invoke(来源未知)位于 java.lang.reflect.Method.invoke(来源未知)位于 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) 在 org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) 在 org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) 在 org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) 在 org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) 在 org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) 在 org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73) 在 org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46) 在 org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
在 org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
在 org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
在 org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) 在 org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) 在 org.junit.runners.ParentRunner.run(ParentRunner.java:220) 处 org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46) 在 org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 引起原因:java.lang.ClassNotFoundException: net.sf.cglib.proxy.Enhancer 位于 java.net.URLClassLoader$1.run(来源不明)位于 java.security.AccessController.doPrivileged(本机方法)位于 java.net.URLClassLoader.findClass(来源未知)位于 java.lang.ClassLoader.loadClass(来源未知)位于 sun.misc.Launcher$AppClassLoader.loadClass(来源未知)位于 java.lang.ClassLoader.loadClass(未知来源) ... 28 更多
I am trying to complete a tutorial about easymock to use it for the first time.
http://www.vogella.de/articles/EasyMock/article.html
I am using
- Eclipse IDE for Java Developers ( Build id: 20100218-1602)
- Junit 4 plugin
- easymock 3.0
After creating a project as described below and executing as a JUNIT testI get the error.
**java.lang.NoClassDefFoundError: net/sf/cglib/proxy/Enhancer**
What is this error and how can I fix it? It occurs on the line
EasyMock.replay(calcMethod);
java.lang.NoClassDefFoundError: net/sf/cglib/proxy/Enhancer at
org.easymock.internal.ClassExtensionHelper.getControl(ClassExtensionHelper.java:57)
at org.easymock.EasyMock.getControl(EasyMock.java:2068) at
org.easymock.EasyMock.replay(EasyMock.java:1970) at
income.IncomeCalculatorTest.testCalc1(IncomeCalculatorTest.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
java.lang.reflect.Method.invoke(Unknown Source) at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220) at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException:
net.sf.cglib.proxy.Enhancer at
java.net.URLClassLoader$1.run(Unknown Source) at
java.security.AccessController.doPrivileged(Native Method) at
java.net.URLClassLoader.findClass(Unknown Source) at
java.lang.ClassLoader.loadClass(Unknown Source) at
sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at
java.lang.ClassLoader.loadClass(Unknown Source) ... 28 more
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,我想你需要它。
http://cglib.sourceforge.net/
它也可能位于 Easymock 下载中的某种依赖项目录中
yeah, i think you need it.
http://cglib.sourceforge.net/
its aslo probably in some sort of dependencies directory in the easymock download
来自 EasyMock 3.0 页面:
要执行类模拟,还需添加 Objenesis 和 Cglib 到您的类路径。
From EasyMock 3.0 page:
To perform class mocking, also add Objenesis and Cglib to your classpath.