Closed GoogleCodeExporter closed 9 years ago
Hi,
I didn't know this annotation. So yes, I'll add support for this before next
monday ;)
Original comment by gael.laz...@gmail.com
on 21 Mar 2012 at 2:53
Thanks a lot !
Original comment by juergen....@gmail.com
on 21 Mar 2012 at 3:14
Original comment by gael.laz...@gmail.com
on 22 Mar 2012 at 2:41
Hi Jürgen,
I've just deployed a new 0.36-SNAPSHOT with support for @UiChild, could you
please give it a try and post some feedback here ? Thanks !
Original comment by gael.laz...@gmail.com
on 22 Mar 2012 at 6:51
Hello Gael,
with the 0.36-SNAPSHOT we are running into another problem. Our project is a
multi-module project where only one project is a full sized gwt project that
compiles into a war. The rest are just gwt-modules.
With 0.36-SNAPSHOT the test utils must have a HTML host page, but the
gwt-modules don't have one.
Before (0.35) we have got a warning but everything runs fine. Now the
LocationPatcher can't run if the path is null.
Is there a way to work around this problem.
Thx.
Jürgen
Original comment by juergen....@gmail.com
on 23 Mar 2012 at 8:06
arg sorry, and I already have released the 0.36 because I had some big
modification to make for the 0.37 version which will come.. (gwt-test-utils
will be uploaded on Maven Central, so I have to change com.octo.gwt.test
groupId to com.googlecode and rename gwt-test-utils root package the same way).
Yes, there is a workaround I use myself in WindowLocationTest : override the
getHostPagePath(..) method in your test which calls Window.Location's methods
to provide a virtual path which doesn't have to match to a real file. For
example :
@Override
protected String getHostPagePath(String moduleFullQualifiedName) {
return "fake-path/WindowLocationTest.html";
}
I will improve the stack trace in LocationPatcher for the next snapshot, my
apology..
Original comment by gael.laz...@gmail.com
on 23 Mar 2012 at 8:36
Hello Gael,
workaround unfortunately doesn't work:
java.lang.ExceptionInInitializerError
at sun.reflect.GeneratedSerializationConstructorAccessor4.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:56)
at org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:73)
at org.mockito.internal.creation.jmock.ClassImposterizer.createProxy(ClassImposterizer.java:111)
at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:51)
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 contract.views.ContractViewTest.setup(ContractViewTest.java:52)
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.RunBefores.evaluate(RunBefores.java:27)
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: com.octo.gwt.test.exceptions.GwtTestConfigurationException: Cannot
find file 'fake-path/WindowLocationTest.html', please override
GwtTest.getHostPagePath() method by specifying the relative path from the root
directory of your java project
at com.octo.gwt.test.internal.patchers.dom.DocumentPatcher.getHostPageHTML(DocumentPatcher.java:189)
at com.octo.gwt.test.internal.patchers.dom.DocumentPatcher.parseHTMLElement(DocumentPatcher.java:258)
at com.octo.gwt.test.internal.patchers.dom.DocumentPatcher.nativeGet(DocumentPatcher.java:139)
at com.google.gwt.dom.client.Document.nativeGet(Document.java)
at com.google.gwt.dom.client.Document.get(Document.java:46)
at com.google.gwt.user.client.DOM.createDiv(DOM.java:149)
at com.extjs.gxt.ui.client.GXT.init(GXT.java:263)
at com.extjs.gxt.ui.client.widget.Component.<clinit>(Component.java:203)
... 38 more
Now the DocumentPatcher complains :-/
Regards,
Jürgen
Original comment by juergen....@gmail.com
on 23 Mar 2012 at 9:28
Ok than,
1) override it like that :
@Override
protected String getHostPagePath(String moduleFullQualifiedName) {
return "hostpage.html";
}
2) create a file 'hostpage.html" at the root of your test classpath (typically
in src/test/resources/)
3) in this file, write :
<html>
<head></head>
<body></body>
</html>
This would do the trick. I will change some code so it DocumentPatcher will not
complain anymore if the file does not exist, like for the LocationPatcher
Original comment by gael.laz...@gmail.com
on 23 Mar 2012 at 9:37
Hello Gael,
that works. Thanks a lot. With this I came to the part to test the @UiChild
functionality.
This unfortunately didn't work in our case, but I think the bug is not in the
@UiChild part of the code but in the @UiField(provided=true) part.
The getProvidedUiField method in UiBinderInstanciator IMO does only check for
the type of the provided field but not for the name supplied with the
'ui:field' tag in the XML.
Our example is:
<spin:filterPane>
<g:Widget ui:field="filterWidget"/>
</spin:filterPane>
<spin:notificationPane>
<g:Widget ui:field="notificationWidget"/>
</spin:notificationPane>
both widgets are provided.
@UiField(provided=true) Widget filterWidget;
@UiField(provided=true) Widget notificationWidget;
and added to the panes via the @UiChild annotation.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/**
* Called from UIBinder during view construction to set the filter definition pane
* @param widget .
*/
@SuppressWarnings("unchecked")
@UiChild(tagname="filterPane",limit=1)
public void addFilterpane( Widget widget ) {
assert widget instanceof FilterPane : "SpinPane: <filterPane> needs instance of SpinPane.FilterPane, got " + widget.getClass().getName() + " instead";
filterPaneContainer.add( widget );
filterPane = (FilterPane<F>)widget;
filterPane.setHost( this );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/**
* Called from UIBinder during view construction to set the user notification widget
* @param widget .
*/
@UiChild(tagname="notificationPane",limit=1)
public void addNotificationpane( Widget widget ) {
assert widget instanceof NotificationPane : "SpinPane: <notificationPane> needs instance of SpinPane.NotificationPane, got " + widget.getClass().getName() + " instead";
notificationPane = (NotificationPane)widget;
filterPane.setHost( this );
}
If I run the test both add-methods get the same widget which leads to the
notificationPane-assert above.
I think getProvidedUiField must not only check for the type but also for the
name of the ui:field tag as mentioned above.
for (Map.Entry<Field, UiField> entry : map.entrySet()) {
if (entry.getKey().getType() == clazz && entry.getValue().provided()) {
^^^^ here the first field of type Widget is found.
Object providedObject = GwtReflectionUtils.getPrivateFieldValue(owner,
entry.getKey());
Regards,
Jürgen
Original comment by juergen....@gmail.com
on 23 Mar 2012 at 1:20
Ok, I'll fix this this weekend, it will be available in the 0.37-SNAPSHOT,
where you'll have to replace each "import com.octo..." by "import
com.googlecode..."
Stay tuned ;)
Original comment by gael.laz...@gmail.com
on 23 Mar 2012 at 2:12
Hi Jürgen,
I've just deployed the new 0.37-SNAPSHOT with a fix for provided @UiField.
Could you give it a try ? Thanks !
Original comment by gael.laz...@gmail.com
on 26 Mar 2012 at 5:30
Hello Gael,
finally, after a lot of find-and-replace, it seems to work :-)
Thx a lot
Jürgen
Original comment by juergen....@gmail.com
on 26 Mar 2012 at 12:28
That's nice, many thanks for being so patient ;)
One more thing, You can now try to remove your getHostPagePath(..)
implementation and your html file.
gwt-test-utils is expected to warn you it is falling back to an empty HTML
document whenever it can retrieve your module's hostpage.
Could you please validate this ?
Original comment by gael.laz...@gmail.com
on 26 Mar 2012 at 12:45
Hello Gael,
this Problem still remains:
java.lang.ExceptionInInitializerError
at sun.reflect.GeneratedSerializationConstructorAccessor4.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:56)
at org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:73)
at org.mockito.internal.creation.jmock.ClassImposterizer.createProxy(ClassImposterizer.java:111)
at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:51)
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 contract.views.ContractViewTest.setup(ContractViewTest.java:59)
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.RunBefores.evaluate(RunBefores.java:27)
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.googlecode.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: com.googlecode.gwt.test.exceptions.GwtTestConfigurationException:
Cannot find the actual HTML host page for module
'de.heuboe.spingui.contract.Contract'. You should override
com.googlecode.gwt.test.GwtTest.getHostPagePath(String moduleFullQualifiedName)
method to specify it.
at com.googlecode.gwt.test.internal.patchers.LocationPatcher.computePath(LocationPatcher.java:91)
at com.googlecode.gwt.test.internal.patchers.LocationPatcher.getURLToUse(LocationPatcher.java:113)
at com.googlecode.gwt.test.internal.patchers.LocationPatcher.getProtocol(LocationPatcher.java:80)
at com.google.gwt.user.client.Window$Location.getProtocol(Window.java)
at com.extjs.gxt.ui.client.GXT.init(GXT.java:312)
at com.extjs.gxt.ui.client.widget.Component.<clinit>(Component.java:203)
... 38 more
Regards,
Jürgen
Original comment by juergen....@gmail.com
on 26 Mar 2012 at 1:25
Ok I'm afraid you'll still have to override the getHostPagePath(..), but the
hostpage path it would would return does not have to exist anymore.
The GXT.init(..) method is so annoying... my opinion is that it does too much
things..
Original comment by gael.laz...@gmail.com
on 26 Mar 2012 at 1:41
Hi again,
Just notice the groupId for gwt-test-utils has changed. Now it's
"com.googlecode.gwt-test-utils". The artifactId hasn't changed
Original comment by gael.laz...@gmail.com
on 26 Mar 2012 at 8:19
Hello Gael,
I already changed the groupId and I'll stick with my override solution for
getHostPagePath(). This works fine for my.
Regards,
Jürgen
Original comment by juergen....@gmail.com
on 27 Mar 2012 at 9:56
Original issue reported on code.google.com by
juergen....@gmail.com
on 21 Mar 2012 at 1:55