Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caused by: java.lang.ClassCastException: com.google.gwt.dom.client.Element$$EnhancerByMockitoWithCGLIB$$57c66b4f cannot be cast to com.google.gwt.user.client.Element #43

Open
riyaz47 opened this issue Sep 23, 2014 · 2 comments

Comments

@riyaz47
Copy link

riyaz47 commented Sep 23, 2014

Hi i am facing the below exception while using Mockito 1.1.4 for creating junit test case for my GWT class, can some help me fixing it

Exception :

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.google.gwtmockito.GwtMockitoTestRunner.withBefores(GwtMockitoTestRunner.java:326)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:261)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at com.google.gwtmockito.GwtMockitoTestRunner.run(GwtMockitoTestRunner.java:307)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
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.reflect.InvocationTargetException
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.google.gwtmockito.GwtMockitoTestRunner.withBefores(GwtMockitoTestRunner.java:324)
... 16 more
Caused by: java.lang.ExceptionInInitializerError
at sun.reflect.GeneratedSerializationConstructorAccessor1.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:40)
at org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:59)
at org.mockito.internal.creation.jmock.ClassImposterizer.createProxy(ClassImposterizer.java:128)
at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:63)
at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:56)
at org.mockito.internal.creation.CglibMockMaker.createMock(CglibMockMaker.java:23)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:26)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:51)
at org.mockito.Mockito.mock(Mockito.java:1243)
at org.mockito.Mockito.mock(Mockito.java:1120)
at com.google.gwtmockito.GwtMockito.registerGwtMocks(GwtMockito.java:203)
at com.google.gwtmockito.GwtMockito.initMocks(GwtMockito.java:133)
... 21 more
Caused by: java.lang.ClassCastException: com.google.gwt.dom.client.Element$$EnhancerByMockitoWithCGLIB$$57c66b4f cannot be cast to com.google.gwt.user.client.Element
at com.extjs.gxt.ui.client.core.El.isBorderBox(El.java:156)
at com.extjs.gxt.ui.client.GXT.init(GXT.java:317)
at com.extjs.gxt.ui.client.widget.Component.(Component.java:203)
... 35 more

@ckuetbach
Copy link

I also had a classcast-issue.

May be this Annotation will help?

@RunWith(GwtMockitoTestRunner.class)
@WithClassesToStub({Element.class})
public class MyGWTTest { ...

ekuefler added a commit that referenced this issue Dec 8, 2014
…n't do

anything about so that we can at least provide an error messages to users
hinting how they can work around the problem.

Refs #4, #22, #43, #47.
@teoDev
Copy link

teoDev commented Oct 11, 2019

I have the same issue like @riyaz47 , and
@WithClassesToStub({Element.class})
Did not solve this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants