google-code-export / gwt-test-utils

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

NullPointerException in GwtReflectionUtils.getPrivateFieldValue #131

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Ran the same test that was passing with 0.35, now running with 0.36-snapshot 
update for 20120322 and it breaks here.

What is the expected output? What do you see instead?
Test to be passed

What version of the product are you using? On what operating system?
0.36-snapshot update for 20120322

Please provide any additional information below.

java.lang.NullPointerException
    at com.octo.gwt.test.utils.GwtReflectionUtils.getPrivateFieldValue(GwtReflectionUtils.java:298)
    at com.octo.gwt.test.internal.utils.JavaScriptObjects.getJsoProperties(JavaScriptObjects.java:319)
    at com.octo.gwt.test.internal.utils.JavaScriptObjects.getJsoProperties(JavaScriptObjects.java:337)
    at com.octo.gwt.test.internal.utils.JavaScriptObjects.getObject(JavaScriptObjects.java:165)
    at com.octo.gwt.test.internal.patchers.dom.NodePatcher.getChildNodeList(NodePatcher.java:304)
    at com.octo.gwt.test.internal.patchers.dom.NodePatcher.removeChild(NodePatcher.java:221)
    at com.google.gwt.dom.client.Node.removeChild(Node.java)
    at com.octo.gwt.test.internal.patchers.dom.NodePatcher.insertAtIndex(NodePatcher.java:173)
    at com.octo.gwt.test.internal.patchers.dom.NodePatcher.appendChild(NodePatcher.java:25)
    at com.google.gwt.dom.client.Node.appendChild(Node.java)
    at com.google.gwt.user.client.DOM.appendChild(DOM.java:70)
    at com.google.gwt.user.client.ui.ComplexPanel.add(ComplexPanel.java:94)
    at com.google.gwt.user.client.ui.AbsolutePanel.add(AbsolutePanel.java:97)
    at com.extjs.gxt.ui.client.widget.ModalPanel.show(ModalPanel.java:138)
    at com.extjs.gxt.ui.client.widget.Window.setActive(Window.java:672)
    at com.extjs.gxt.ui.client.widget.WindowManager.setActiveWin(WindowManager.java:219)
    at com.extjs.gxt.ui.client.widget.WindowManager.activateLast(WindowManager.java:191)
    at com.extjs.gxt.ui.client.widget.WindowManager.orderWindows(WindowManager.java:208)
    at com.extjs.gxt.ui.client.widget.WindowManager.bringToFront(WindowManager.java:103)
    at com.extjs.gxt.ui.client.widget.Window.toFront(Window.java:940)
    at com.extjs.gxt.ui.client.widget.Window.afterShow(Window.java:1029)
    at com.extjs.gxt.ui.client.widget.Window.show(Window.java:924)
    at com.somecompany.someclass.somemethod...
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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.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.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)

Original issue reported on code.google.com by bejua...@gmail.com on 22 Mar 2012 at 6:07

GoogleCodeExporter commented 9 years ago
The reason the jars were changed was because of the defect #127, may be some of 
the bugs from the branch never made it.

Original comment by bejua...@gmail.com on 22 Mar 2012 at 6:10

GoogleCodeExporter commented 9 years ago
One funny thing is every alternate test is failing, may be its related to a 
naming problem where its caching an entry or I am missing some statement that 
needs to be executed after each test forcibly like

GwtCreateHandlerManager.get().afterTest();

to make sure I am removing all the create handlers everytime etc.

Original comment by bejua...@gmail.com on 22 Mar 2012 at 6:24

GoogleCodeExporter commented 9 years ago
I can't explain this, there is a test on 
com.extjs.gxt.ui.client.widget.Window.show() method which works on the lastest 
snapshot I've deployed.

Don't worry of alternate tests failure, the only relevant one is the first you 
get. I'll try to remove other tests failure "noise".

I also just deploy another snasphot, maybe you could give it a try, and if the 
error remains, a simple unit test which fails would really help me here..

Original comment by gael.laz...@gmail.com on 22 Mar 2012 at 7:13

GoogleCodeExporter commented 9 years ago
I think its failing for the variable "view", may be this variable is used 
internally. Its working for other variables like "eventBus", "placeController" 
and any other obscure names for that matter. For a generic name like "view" its 
failing. May be this helps.

PlaceController pc = GwtReflectionUtils.getPrivateFieldValue(presenter, 
"placeController");
assertTrue(pc == null);
EventBus eb = GwtReflectionUtils.getPrivateFieldValue(presenter, "eventBus");
assertTrue(eb == null);
>>>> ContactPresenter.View contactView = 
GwtReflectionUtils.getPrivateFieldValue(presenter, "view"); <<<<
assertTrue(contactView != null);

Its failing on the line quoted with arrows above.

Original comment by bejua...@gmail.com on 23 Mar 2012 at 1:18

GoogleCodeExporter commented 9 years ago
The point at which it breaks during running with a variable named "view" is in 
GwtReflectionUtils

=========================================================================
    if (result.size() > 1) {
      throw new ReflectionException("Unable to choose field, '" + clazz
          + "', fieldName '" + fieldName + "'");
    }
=========================================================================

Its finding more than one field with this name which should not be the case
and it breaks. 

Original comment by bejua...@gmail.com on 23 Mar 2012 at 2:31

GoogleCodeExporter commented 9 years ago
com.octo.gwt.test.exceptions.ReflectionException: Unable to choose field, 
'class com.somecompany.ContactPresenter', fieldName 'view'

    at com.octo.gwt.test.utils.GwtReflectionUtils.getUniqueFieldByName(GwtReflectionUtils.java:550)
    at com.octo.gwt.test.utils.GwtReflectionUtils.getPrivateFieldValue(GwtReflectionUtils.java:298)
    at com.somecompany.ContactPresenterTest.testAfterStart(ContactPresenterTest.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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.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)

Original comment by bejua...@gmail.com on 23 Mar 2012 at 2:35

GoogleCodeExporter commented 9 years ago
Gael,

As you said, the alternate tests failing seems to be random noise, but could 
you please suggest me a way to get rid of the null pointer exceptions. I tried 
patching
the following functions from the initial null pointer exception stack trace and 
I am getting more errors...

at com.extjs.gxt.ui.client.widget.ModalPanel.show(ModalPanel.java:138)

at 
com.octo.gwt.test.internal.utils.JavaScriptObjects.getJsoProperties(JavaScriptOb
jects.java:319)

at com.extjs.gxt.ui.client.widget.Window.show(Window.java:924)

What is the best way to see this alternate tests not passing since it seems to 
be a caching issue on the tool side.

Thanks
Sudhir

Original comment by bejua...@gmail.com on 27 Mar 2012 at 9:35

GoogleCodeExporter commented 9 years ago
Regarding the gwt reflection utils not able to find the unique field, we are 
able to overcome this issue by changing the variable names on our side.

com.octo.gwt.test.exceptions.ReflectionException: Unable to choose field, 
'class com.somecompany.ContactPresenter', fieldName 'view'

    at com.octo.gwt.test.utils.GwtReflectionUtils.getUniqueFieldByName(GwtReflectionUtils.java:550)
    at com.octo.gwt.test.utils.GwtReflectionUtils.getPrivateFieldValue(GwtReflectionUtils.java:298)
    at com.somecompany.ContactPresenterTest.testAfterStart(ContactPresenterTest.java:46)

Thanks
Sudhir

Original comment by bejua...@gmail.com on 27 Mar 2012 at 9:36

GoogleCodeExporter commented 9 years ago
Gael,

Could u please take a look at this null pointer issue and see if it could
be fixed thanks.

I am not much concerned about the unique field issue as we could fix it on
our side.

Thanks.
Sudhir

Original comment by bejua...@gmail.com on 28 Mar 2012 at 1:42

GoogleCodeExporter commented 9 years ago
I think I finally got it : the DOM was cleaning before some GXT operations.

I just deployed a new 0.37-SNAPSHOT, but not on forge.octo.com anymore, but on 
sonatype OSS maven repository.

In your pom.xml, you have to replace the <id>snapshot-forge.octo.com</id> 
repository with :

 <repositories>
    <repository>
      <id>sonatype-snapshots</id>
      <url>http://oss.sonatype.org/content/repositories/snapshots</url>
      <snapshots><enabled>true</enabled></snapshots>
      <releases><enabled>false</enabled></releases>
    </repository>
  <repositories>

Could you please give it a try ?

Original comment by gael.laz...@gmail.com on 28 Mar 2012 at 9:36

GoogleCodeExporter commented 9 years ago
We have a firewall so our maven does not pull these automatically unless they 
are re-routed. Could you please give us the location of the jars so that we 
could download from that location from the browser.

Thanks

Original comment by bejua...@gmail.com on 29 Mar 2012 at 3:02

GoogleCodeExporter commented 9 years ago
you can download the lastest snasphots from here : 
https://oss.sonatype.org/content/repositories/snapshots/com/googlecode/gwt-test-
utils/

Original comment by gael.laz...@gmail.com on 29 Mar 2012 at 8:37

GoogleCodeExporter commented 9 years ago
Did you just change the package names of all your classes in your jar files to 
be com.googlecode instead of com.octo. This impacts quite a bit of test code in 
our repository. Is there a way around this or is this going to be permanent 
from now on.?

Original comment by bejua...@gmail.com on 2 Apr 2012 at 4:42

GoogleCodeExporter commented 9 years ago
Yes, all packages were renamed to com.googlecode since gwt-test-utils has moved 
to maven central repository for the lastest release. It is going to be 
permanent so don't worry, you can proceed to a find-and-replace in all your 
test classes.

So, is the NullPointerException fixed ?

Original comment by gael.laz...@gmail.com on 2 Apr 2012 at 6:44

GoogleCodeExporter commented 9 years ago
I confirmed that this NullPointerException defect was fixed by this snapshot.

Thanks Gael
Sudhir

Original comment by bejua...@gmail.com on 2 Apr 2012 at 7:33

GoogleCodeExporter commented 9 years ago
Great !

Original comment by gael.laz...@gmail.com on 2 Apr 2012 at 9:37