EasyMock, test plugin and reflection class loading classpath issues. [message #464312] |
Thu, 01 March 2007 23:55 |
Eclipse User |
|
|
|
I have my plugin project A, and a separate test plugin project A.test.
In A.test I have a TestCase that is attempting to use EasyMock and the
Class Extension mechanism to create a mock of an existing class.
This fails with the error:
java.lang.NoClassDefFoundError: [Lnet/sf/cglib/proxy/Callback;
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:1655)
at java.lang.Class.getDeclaredMethod(Class.java:1262)
at net.sf.cglib.proxy.Enhancer.getCallbacksSetter(Enhancer.java :627)
at net.sf.cglib.proxy.Enhancer.setCallbacksHelper(Enhancer.java :615)
at net.sf.cglib.proxy.Enhancer.setThreadCallbacks(Enhancer.java :609)
at net.sf.cglib.proxy.Enhancer.registerCallbacks(Enhancer.java: 578)
at
org.easymock.classextension.internal.ClassProxyFactory.creat eProxy(ClassProxyFactory.java:99)
at org.easymock.MockControl.<init>(MockControl.java:133)
at
org.easymock.classextension.MockClassControl.<init>(MockClassControl.java:189)
at
org.easymock.classextension.MockClassControl.<init>(MockClassControl.java:194)
at
org.easymock.classextension.MockClassControl.createControl(M ockClassControl.java:36)
I believe the reason for this error is that java.lang.Class is
attempting to use reflection on the class in plugin A and due to
Eclipse's classloading mechanisms the class is not visible.
To verify this, I moved the test class into A's plugin and re-ran the
test and it works fine.
My next step was to try to hack both plugins to have an
Eclipse-BuddyPolicy: global, app, ext, boot, parent, registered
I even tried registering the Test plugin to the project plugin.
None of these work I think because it is the core runtime that needs to
have its classpath modified to see the project plugin's classes via
reflection when called from the test plugin.
I can't find any posts where anyone has tried to use EasyMock with
plugin development.
I've seen Alex's fine post
http://www.eclipsezone.com/articles/eclipse-vms/?source=arch ives about
the vm and classloader but I'm still scratching my head.
Does anyone have any thoughts?
Barrie
|
|
|
Powered by
FUDForum. Page generated in 0.04387 seconds