Closed GoogleCodeExporter closed 9 years ago
To allow .cast() from a com.google.gwt.dom.client.Element to a
com.google.gwt.user.client.Element (which is a subclass of the first),
gwt-test-utils has to do one very dirty thing : when loading each GWT client
class, it replace every reference of user.client.Element to a reference of
dom.client.Element.
So, you will get a "Duplicate method signature" exception in each class where
you have something like :
void f(com.google.gwt.dom.Element e) { ... }
void f(com.google.gwt.user.Element e) { ...} (<= param replaced at runtime
with a dom.client.Element)
gwt-test-utils comes with something to managed those kind of error. In your
META-INF/gwt-test-utils.properties file, you'll have to add :
com.google.gwt.query.client.Function,cancel,(Lcom/google/gwt/dom/client/Element;
)V = remove-method
com.google.gwt.query.client.Function,f,(Lcom/google/gwt/dom/client/Element;I)Lja
va/lang/Object; = remove-method
=> The targeted functions will simply be removed from the class when it would
be loaded by the custom classloader
But note that in your case, I'm not sure gwt-test-utils support gwtquery (yet).
I never used this great framework so I could not tell what other error you
might face and how many time it would took me to have something working with
gwtquery..
Original comment by gael.laz...@gmail.com
on 9 Mar 2012 at 7:51
Thank you very much!
After changing, I got the following error. I think it's common, so I post it
here.
Because Function class is frozen, then throws ClassNotFoundException.
Stacktrace as below:
java.lang.NoClassDefFoundError: com/google/gwt/query/client/Function
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getDeclaredConstructors(Class.java:1836)
at org.mockito.internal.creation.jmock.ClassImposterizer.setConstructorsAccessible(ClassImposterizer.java:58)
at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:53)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:52)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:41)
at org.mockito.Mockito.mock(Mockito.java:1014)
at org.mockito.Mockito.mock(Mockito.java:909)
at com.topcmm.test.presentation.client.FromTemplateTest.test(FromTemplateTest.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
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.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:236)
at com.octo.gwt.test.internal.runner.AbstractGwtRunner.run(AbstractGwtRunner.java:40)
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.ClassNotFoundException: caught an exception while
obtaining a class file for com.google.gwt.query.client.Function
at javassist.Loader.findClass(Loader.java:360)
at javassist.Loader.loadClass(Loader.java:312)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 38 more
Caused by: com.octo.gwt.test.exceptions.GwtTestPatchException:
java.lang.RuntimeException: com.google.gwt.query.client.Function class is frozen
at com.octo.gwt.test.internal.GwtTranslator.applyJavaClassModifier(GwtTranslator.java:49)
at com.octo.gwt.test.internal.GwtTranslator.modifiyClass(GwtTranslator.java:86)
at com.octo.gwt.test.internal.GwtTranslator.patchClass(GwtTranslator.java:99)
at com.octo.gwt.test.internal.GwtTranslator.onLoad(GwtTranslator.java:29)
at javassist.Loader.findClass(Loader.java:341)
... 40 more
Caused by: java.lang.RuntimeException: com.google.gwt.query.client.Function
class is frozen
at javassist.CtClassType.checkModify(CtClassType.java:287)
at javassist.CtClassType.removeMethod(CtClassType.java:1337)
at com.octo.gwt.test.internal.MethodRemover.modify(MethodRemover.java:52)
at com.octo.gwt.test.internal.GwtTranslator.applyJavaClassModifier(GwtTranslator.java:38)
... 44 more
Original comment by ke...@topcmm.com
on 9 Mar 2012 at 8:12
Would you please let me know do you have any plan to support gwtquery?
Thanks a lot!
Original comment by ke...@topcmm.com
on 10 Mar 2012 at 5:27
I'm afraid to say that gwtquery support will not come soon in gwt-test-utils :(
Actually, there are a lot of core GWT feature that gwt-test-utils does not
support yet, like Editors and RequestFactory for example. Those would be my
priority, just after providing day to day support (and fix) to gwt-test-utils
users.
Of course, I'm more than open to contribute with and help anyone who would be
motivated to contribute.
I think gwtquery support will not be easy to provide, since I guess this great
librairies deals a lot with GWT's DOM classes : overlay types (JavaScriptObject
subclasses)
Instances of such classes can be cross-casted, to emulated the loosely typed
nature of JavaScript. Like I explained it here
(http://code.google.com/p/gwt-test-utils/issues/detail?id=97), gw-test-utils
does not provide a very nice support for Overlays, which would be a requirement
to be able to implement support for gwtquery.
The error you submitted in the comment of
http://code.google.com/p/gwt-test-utils/wiki/HowToWriteCustomPatchers wiki page
is typically a case of gwt-test-utils current limit : you cannot call
JavaScriptObject.cast() method on every subtype (trying to cast a
JavaScriptObject instance to a JsMap instance in this case).
Like I said in the other issue's comments, I think gwt-test-utils is not mature
enough yet to deal with such "low level" code, and I'm afraid you would be
stuck to using GWTTestCase if you want to test your gwtquery based client code
:(
Original comment by gael.laz...@gmail.com
on 11 Mar 2012 at 1:19
Thank you very much for your comments!
I've figured a way to make gwt-test-utils to work with my gwtquery based
project. If you want, I can contribute the code related to gwt-test-utils.
Though, I'm only mocking GQuery objects. But for my case, it's enough.
Thanks.
Original comment by ke...@topcmm.com
on 12 Mar 2012 at 1:39
Ok that's great if mocking those object is enough for you !
Maybe you could post on the gwt-test-utils-user googlegroup the approach you've
adopted to make it work for your needs. I guess others might be interessed ;-)
Cheers
Original comment by gael.laz...@gmail.com
on 16 Mar 2012 at 5:23
Hi there,
Just a little update to tell you the lastest 0.40-SNAPSHOT now provides support
for overlay types !
The 'remove-method' value in META-INF/gwt-test-utils.properties is not
supported anymore. Please read this page carefully before update :
http://code.google.com/p/gwt-test-utils/wiki/MigrationTo040
I can now close this issue since there won't be any "Duplicate method
name&signature" anymore :-)
Could you please give the lastest snapshot a try and post some feedback ?
Original comment by gael.laz...@gmail.com
on 8 Jul 2012 at 1:23
Hi Gael,
Thanks for your update!
But would you please let me know where can I get the 0.40 snapshot package? Is
there a maven package available?
Thanks,
Kevin
Original comment by ke...@topcmm.com
on 9 Jul 2012 at 1:26
gwt-test-utils snapshots are hosted on sonatype snapshot repository, see there
:
http://code.google.com/p/gwt-test-utils/wiki/HowToUse#POM_snapshots_configuratio
n
Also note that Overlay type support won't guarantee gwtquery support in
gwt-test-utils. It just solves the "duplicate method .." error..
Original comment by gael.laz...@gmail.com
on 9 Jul 2012 at 5:47
Hi Gael,
I tried couple ways to make it work in my gwtquery heavily used project. But no
lucky, not working, lots of errors.
Sorry for giving up!
Thanks anyway.
Kevin
Original comment by ke...@topcmm.com
on 9 Jul 2012 at 6:32
Original issue reported on code.google.com by
ke...@topcmm.com
on 9 Mar 2012 at 3:12