google-code-export / gwt-test-utils

Automatically exported from code.google.com/p/gwt-test-utils
1 stars 0 forks source link

UIBinder template with Image fails #87

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a simple UIBinder file like:

<g:SimplePanel>
<g:Image/>
</g:SimplePanel>

2.  Attempt to load the panel in a test.

What is the expected output? What do you see instead?

com.octo.gwt.test.exceptions.ReflectionException: Error during instanciation of 
'com.google.gwt.user.client.ui.Image'. Constructor threw exception
    at com.octo.gwt.test.utils.GwtReflectionUtils.instantiateClass(GwtReflectionUtils.java:368)
    at com.octo.gwt.test.internal.handlers.DefaultGwtCreateHandler.create(DefaultGwtCreateHandler.java:22)
    at com.octo.gwt.test.internal.patchers.GwtPatcher.create(GwtPatcher.java:22)
    at com.google.gwt.core.client.GWT.create(GWT.java)
    at com.octo.gwt.test.uibinder.UiBinderInstanciator.getInstance(UiBinderInstanciator.java:56)
    at com.octo.gwt.test.uibinder.UiBinderTagBuilder.createUiBinderTag(UiBinderTagBuilder.java:141)
    at com.octo.gwt.test.uibinder.UiBinderTagBuilder.startTag(UiBinderTagBuilder.java:114)
    at com.octo.gwt.test.uibinder.UiXmlContentHandler.startElement(UiXmlContentHandler.java:73)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
    at org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.octo.gwt.test.uibinder.GwtUiBinderParser.createUiComponent(GwtUiBinderParser.java:46)
    at com.octo.gwt.test.uibinder.UiBinderInvocationHandler.createAndBindUi(UiBinderInvocationHandler.java:69)
    at com.octo.gwt.test.uibinder.UiBinderInvocationHandler.invoke(UiBinderInvocationHandler.java:31)
    at $Proxy14.createAndBindUi(Unknown Source)
    at ec.client.help.HelpLibraryView.<init>(HelpLibraryView.java:82)
    at ec.client.help.HelpLibraryViewJTest.testInit(HelpLibraryViewJTest.java:32)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    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: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.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.junit.runner.JUnitCore.run(JUnitCore.java:157)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:199)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.AssertionError: Element may only be set once
    at com.octo.gwt.test.internal.patchers.UIObjectPatcher.setElement(UIObjectPatcher.java:71)
    at com.google.gwt.user.client.ui.UIObject.setElement(UIObject.java)
    at com.google.gwt.user.client.ui.Image.<init>(Image.java:490)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.octo.gwt.test.utils.GwtReflectionUtils.instantiateClass(GwtReflectionUtils.java:347)
    ... 53 more

What version of the product are you using? On what operating system?

0.35-SNAPSHOT (r1209)

Please provide any additional information below.

I have been able to work around the problem by using an HTMLPanel with an 
inline <img> tag instead of the widget.

Original issue reported on code.google.com by snstan...@gmail.com on 12 Nov 2011 at 1:13

GoogleCodeExporter commented 9 years ago

Original comment by gael.laz...@gmail.com on 12 Nov 2011 at 10:48

GoogleCodeExporter commented 9 years ago

Original comment by gael.laz...@gmail.com on 12 Nov 2011 at 2:51

GoogleCodeExporter commented 9 years ago
I've fixed all AssertionError in gwt-test-utils, the problem should now be 
solved.

I have just deployed new 0.35-SNAPSHOT, 0.33.1-SNAPSHOT, 0.28.8-SNAPSHOT, 
0.25.5-SNAPSHOT and 0.22.5-SNAPSHOT. Could you please give it a try to validate 
the fix is working and give me some feedback ?

Thanks a lot !

Original comment by gael.laz...@gmail.com on 13 Nov 2011 at 12:06

GoogleCodeExporter commented 9 years ago
This is working better, however I still have a remaining issue.  I'm getting a 
resource exception when I try to reference a resource in the gwt-user.jar.  I 
have a declaration like this:

      <g:Image styleName="{m_styles.loading}" altText="Loading..."
               resource="{ec.cellTableLoading}"/>

Which depends on an imported resource bundle:

  <ui:with field="ec" type="ecinternal.client.ui.InternalResources"/>

That extends CellTable.Resources:

 public interface InternalResources
    extends CellTable.Resources {
...
}

cellTableLoading is a sprite that comes from cellTable.css.

I don't really care about the image itself in my test context, so replacing the 
missing url with a placeholder would be fine.  If I replace the widget with the 
equivalent <img> tag, the tests work as expected:

      <img class="{m_styles.loading}" alt="Loading..."
           src="{ec.cellTableLoading.getSafeUri.asString}"/>

Original comment by snstan...@gmail.com on 18 Nov 2011 at 12:55

GoogleCodeExporter commented 9 years ago

Original comment by gael.laz...@gmail.com on 18 Nov 2011 at 6:49

GoogleCodeExporter commented 9 years ago
I just deployed a new 0.35-SNAPSHOT which should solve this Image issue. Could 
you please give it a try and give me some feedback ? Thanks!

Original comment by gael.laz...@gmail.com on 29 Nov 2011 at 12:57

GoogleCodeExporter commented 9 years ago

Original comment by gael.laz...@gmail.com on 29 Nov 2011 at 2:57

GoogleCodeExporter commented 9 years ago
I'm getting the following error now:

com.octo.gwt.test.exceptions.GwtTestResourcesException: Cannot compute the 
relative URL of resource 
'jar:file:/C:/Users/stanton/.m2/repository/com/google/gwt/gwt-user/2.4.0/gwt-use
r-2.4.0.jar!/com/google/gwt/user/cellview/client/cellTableLoading.gif'
    at com.octo.gwt.test.internal.resources.ResourcePrototypeProxyBuilder.computeUrl(ResourcePrototypeProxyBuilder.java:147)
    at com.octo.gwt.test.internal.resources.ResourcePrototypeProxyBuilder.build(ResourcePrototypeProxyBuilder.java:109)
    at com.octo.gwt.test.internal.resources.ClientBundleProxyFactory$1.invoke(ClientBundleProxyFactory.java:175)
    at $Proxy16.cellTableLoading(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at com.octo.gwt.test.utils.GwtReflectionUtils.callPrivateMethod(GwtReflectionUtils.java:59)
    at com.octo.gwt.test.utils.GwtReflectionUtils.callPrivateMethod(GwtReflectionUtils.java:81)
    at com.octo.gwt.test.uibinder.UiBinderTagBuilder.extractResource(UiBinderTagBuilder.java:205)
    at com.octo.gwt.test.uibinder.UiBinderTagBuilder.treatStandardAttr(UiBinderTagBuilder.java:290)
    at com.octo.gwt.test.uibinder.UiBinderTagBuilder.parseAttributesMap(UiBinderTagBuilder.java:263)
    at com.octo.gwt.test.uibinder.UiBinderTagBuilder.createUiBinderTag(UiBinderTagBuilder.java:136)
    at com.octo.gwt.test.uibinder.UiBinderTagBuilder.startTag(UiBinderTagBuilder.java:127)
    at com.octo.gwt.test.uibinder.UiXmlContentHandler.startElement(UiXmlContentHandler.java:73)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.octo.gwt.test.uibinder.GwtUiBinderParser.createUiComponent(GwtUiBinderParser.java:46)
    at com.octo.gwt.test.uibinder.UiBinderInvocationHandler.createAndBindUi(UiBinderInvocationHandler.java:71)
    at com.octo.gwt.test.uibinder.UiBinderInvocationHandler.invoke(UiBinderInvocationHandler.java:33)
    at $Proxy15.createAndBindUi(Unknown Source)

Original comment by snstan...@gmail.com on 29 Nov 2011 at 11:14

GoogleCodeExporter commented 9 years ago
Does your InternalResources class extends any other interface than 
CellTable.Resource ? If yes, the lastest 0.35-SNAPSHOT I've just deploy solves 
the issue. Could you give it a try ?

Original comment by gael.laz...@gmail.com on 30 Nov 2011 at 12:20

GoogleCodeExporter commented 9 years ago
Looks good as of gwt-test-utils-0.35-20111201.063432-27.jar

Original comment by snstan...@gmail.com on 3 Dec 2011 at 12:41

GoogleCodeExporter commented 9 years ago
Thanks for all your feedback :)

Original comment by gael.laz...@gmail.com on 3 Dec 2011 at 11:46