Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
RootPanel.get("aaa") in Junit test throws NPE
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Владимир Петрухин  
View profile  
 More options Jun 26, 12:45 pm
From: Владимир Петрухин <mylonglongn...@gmail.com>
Date: Fri, 26 Jun 2009 09:45:29 -0700 (PDT)
Local: Fri, Jun 26 2009 12:45 pm
Subject: RootPanel.get("aaa") in Junit test throws NPE
I generate a simple project with maven gwt plugin:

mvn archetype:generate \
   -DarchetypeGroupId=org.codehaus.mojo \
   -DarchetypeArtifactId=gwt-maven-plugin \
   -DarchetypeVersion=1.1 \
   -DgroupId=myGroupId \
   -DartifactId=myArtifactId

In GwtTestSample I change:

   public void testSomething()
   {
      final Label label = new Label ( "gwt-maven-plugin Archetype ::
Project myGroupId.myArtifactId" );
      RootPanel.get("aaa").add( label );
   }

And in Application.html i add <div id="aaa"></div>

All works ok, but in JUnit test (mvn gwt:test) RootPanel.get("aaa")
throws

java.lang.NullPointerException
[INFO]  at myGroupId.client.GwtTestSample.testSomething
(GwtTestSample.java:23)
[INFO]  at myGroupId.client.__GwtTestSample_unitTestImpl.doRunTest
(transient source for myGroupId.client.__GwtTestSample_unitTestImpl:7)
[INFO]  at junit.framework.TestCase.runTest(TestCase.java:62)
[INFO]  at com.google.gwt.junit.client.GWTTestCase.runBare
(GWTTestCase.java:206)
[INFO]  at com.google.gwt.junit.client.GWTTestCase.__doRunTest
(GWTTestCase.java:137)
[INFO]  at com.google.gwt.junit.client.impl.GWTRunner.runTest
(GWTRunner.java:188)
[INFO]  at com.google.gwt.junit.client.impl.GWTRunner.doRunTest
(GWTRunner.java:163)
[INFO]  at com.google.gwt.junit.client.impl.GWTRunner.access$3
(GWTRunner.java:157)
[INFO]  at com.google.gwt.junit.client.impl.GWTRunner
$JUnitHostListener.onSuccess(GWTRunner.java:61)
[INFO]  at com.google.gwt.junit.client.impl.GWTRunner
$JUnitHostListener.onSuccess(GWTRunner.java:1)
[INFO]  at
com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceiv ed
(RequestCallbackAdapter.java:215)
[INFO]  at
com.google.gwt.http.client.Request.fireOnResponseReceivedImpl
(Request.java:264)
[INFO]  at com.google.gwt.http.client.Request.fireOnResponseReceived
(Request.java:229)
[INFO]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO]  at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
[INFO]  at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
[INFO]  at java.lang.reflect.Method.invoke(Method.java:597)
[INFO]  at com.google.gwt.dev.shell.MethodAdaptor.invoke
(MethodAdaptor.java:103)
[INFO]  at com.google.gwt.dev.shell.moz.MethodDispatch.invoke
(MethodDispatch.java:80)
[INFO]  at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration
(Native Method)
[INFO]  at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration
(OS.java:1428)
[INFO]  at org.eclipse.swt.widgets.Display.readAndDispatch
(Display.java:2840)
[INFO]  at com.google.gwt.dev.SwtHostedModeBase.processEvents
(SwtHostedModeBase.java:235)
[INFO]  at com.google.gwt.dev.HostedModeBase.pumpEventLoop
(HostedModeBase.java:558)
[INFO]  at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:
652)
[INFO]  at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:
346)
[INFO]  at com.google.gwt.junit.client.GWTTestCase.runTest
(GWTTestCase.java:219)
[INFO]  at junit.framework.TestCase.runBare(TestCase.java:134)
[INFO]  at junit.framework.TestResult$1.protect(TestResult.java:110)
[INFO]  at junit.framework.TestResult.runProtected(TestResult.java:
128)
[INFO]  at junit.framework.TestResult.run(TestResult.java:113)
[INFO]  at junit.framework.TestCase.run(TestCase.java:124)
[INFO]  at com.google.gwt.junit.client.GWTTestCase.run
(GWTTestCase.java:132)
[INFO]  at junit.framework.TestSuite.runTest(TestSuite.java:232)
[INFO]  at junit.framework.TestSuite.run(TestSuite.java:227)
[INFO]  at org.codehaus.mojo.gwt.test.MavenTestRunner.doRun
(MavenTestRunner.java:105)
[INFO]  at junit.textui.TestRunner.start(TestRunner.java:180)
[INFO]  at org.codehaus.mojo.gwt.test.MavenTestRunner.main
(MavenTestRunner.java:63)

Help.
Thanks.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
hazy1  
View profile  
 More options Jul 3, 10:58 pm
From: hazy1 <matt.egyh...@gmail.com>
Date: Fri, 3 Jul 2009 19:58:36 -0700 (PDT)
Local: Fri, Jul 3 2009 10:58 pm
Subject: Re: RootPanel.get("aaa") in Junit test throws NPE
I have the same problem.  No solution/work around that I know of.

On Jun 26, 12:45 pm, Владимир Петрухин <mylonglongn...@gmail.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
hazy1  
View profile  
 More options Jul 6, 9:22 pm
From: hazy1 <matt.egyh...@gmail.com>
Date: Mon, 6 Jul 2009 18:22:56 -0700 (PDT)
Local: Mon, Jul 6 2009 9:22 pm
Subject: Re: RootPanel.get("aaa") in Junit test throws NPE
The work around I ended up using is to parameterize the RootPanel.get
("xxx") call with a public static member.  In my JUnit test cases, I
set this public static to null prior to calling onModuleLoad.

On Jul 3, 10:58 pm, hazy1 <matt.egyh...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google