JUnit assertions (using GWTTestCase) keeps failing when calling
RootPanel.get(id).

Calling RootPanel.get(id) returns null, when it should not. The host
page has a div block defined with an id set.

Following is the sample code which produced these results. The tests
were ran in web mode.

FirstGWT15EclipseAppTest-web.cmd
------------------------------------------------------

@java -Dgwt.args="-web -out www-test" -Xmx256M -cp "%~dp0\src;
%~dp0\test;%~dp0\bin;F:\Program Files\eclipse\eclipse-3.3.2\plugins
\org.junit4_4.3.1\junit.jar;F:/Program Files/Google Web Toolkit/gwt-
windows-1.5.2/gwt-user.jar;F:/Program Files/Google Web Toolkit/gwt-
windows-1.5.2/gwt-dev-windows.jar" junit.textui.TestRunner
com.mycompany.client.FirstGWT15EclipseAppTest %*

Host Page: [FirstGWT15EclipseApp.html]
------------------------------------------------------------

<html>
  <head>
    <meta http-equiv="content-type" content="text/html;
charset=UTF-8">
    <title>FirstGWT15EclipseApp</title>
    <script type="text/javascript"
               language="javascript"
               src="com.mycompany.FirstGWT15EclipseApp.nocache.js">
    </script>
  </head>
  <body>
    <iframe src="javascript:''"
                id="__gwt_historyFrame"
                tabIndex='-1'
                style="position:absolute;width:0;height:0;border:0">
    </iframe>
    <div id="container"></div>
  </body>
</html>

Junit Test Class:
------------------------

public class FirstGWT15EclipseAppTest extends GWTTestCase {

  public String getModuleName() {
    return "com.mycompany.FirstGWT15EclipseApp";
  }

  public void testSimple() {
    assertTrue(true);
  }

  public void testGetRootContainer() {

      final Timer timer = new Timer() {
          @Override
          public void run() {
              assertNotNull(RootPanel.get("container"));
              FirstGWT15EclipseAppTest.this.finishTest();
          }
      };
      this.delayTestFinish(100000);
      timer.schedule(50000);
  }

}

Java Class:
----------------

public class FirstGWT15EclipseApp implements EntryPoint {

  /**
   * This is the entry point method.
   */
  public void onModuleLoad() {
    Image img = new Image("http://code.google.com/webtoolkit/
logo-185x175.png");
    Button button = new Button("Click me");

    VerticalPanel vPanel = new VerticalPanel();
    // We can add style names.
    vPanel.addStyleName("widePanel");
    vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    vPanel.add(img);
    vPanel.add(button);

    // Add image and button to the RootPanel
    RootPanel.get("container").add
(vPanel);                             // <<<< Adds panel to container
div

    // Create the dialog box
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Welcome to GWT!");
    dialogBox.setAnimationEnabled(true);
    Button closeButton = new Button("close");
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.setWidth("100%");
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    dialogVPanel.add(closeButton);

    closeButton.addClickListener(new ClickListener() {
      public void onClick(Widget sender) {
        dialogBox.hide();
      }
    });

    // Set the contents of the Widget
    dialogBox.setWidget(dialogVPanel);

    button.addClickListener(new ClickListener() {
      public void onClick(Widget sender) {
        dialogBox.center();
        dialogBox.show();
      }
    });
  }
}

Results:
===============================================================================

F:\Work Space\Workspace Experimental
\FirstGWT15EclipseApp>FirstGWT15EclipseAppTest-web.cmd
FirstGWT15EclipseAppTest-web.cmd
.Scanning for additional dependencies: jar:file:/F:/Program%20Files/
Google%20Web%20Toolkit/gwt-windows-1.5.2/gwt-user.jar!/com/google/gwt/
junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java
   Computing all possible rebind results for
'com.google.gwt.junit.client.impl.JUnitHost'
      Rebinding com.google.gwt.junit.client.impl.JUnitHost
         Invoking <generate-with
class='com.google.gwt.user.rebind.rpc.ServiceInterfaceProxyGenerator'/
>
            Generating client proxy for remote service interface
'com.google.gwt.junit.client.impl.JUnitHost'
               Analyzing 'com.google.gwt.junit.client.impl.JUnitHost'
for serializable types
                  Analyzing methods:
                     public abstract
com.google.gwt.junit.client.impl.JUnitHost.TestInfo
reportResultsAndGetNextMethod
(com.google.gwt.junit.client.impl.JUnitHost.TestInfo testInfo,
com.google.gwt.junit.client.impl.JUnitResult result) throws
com.google.gwt.junit.client.TimeoutException
                        Parameter:
com.google.gwt.junit.client.impl.JUnitResult result
 
com.google.gwt.junit.client.impl.JUnitResult
                              Verifying instantiability
 
com.google.gwt.benchmarks.client.impl.BenchmarkResults
                                    Analyzing the fields of type
'com.google.gwt.benchmarks.client.impl.BenchmarkResults' that qualify
for serialization
                                       private
java.util.List<com.google.gwt.benchmarks.client.impl.Trial> trials
 
java.util.List<com.google.gwt.benchmarks.client.impl.Trial>
                                             Verifying instantiability
 
java.util.Arrays.ArrayList<com.google.gwt.benchmarks.client.impl.Trial>
                                                   Checking parameters
of
'java.util.Arrays.ArrayList<com.google.gwt.benchmarks.client.impl.Trial>'
                                                      Checking type
argument 0 of type 'java.util.Arrays.ArrayList<E>' because it is
exposed as an array with a maximum dimension of 1 in this type or one
of its subtypes
 
com.google.gwt.benchmarks.client.impl.Trial[]
                                                            Analyzing
component type:
 
com.google.gwt.benchmarks.client.impl.Trial
 
Verifying instantiability
 
com.google.gwt.benchmarks.client.impl.Trial
 
Analyzing the fields of type
'com.google.gwt.benchmarks.client.impl.Trial' that qualify for
serialization
 
private java.util.Map<java.lang.String, java.lang.String> variables
 
java.util.Map<java.lang.String, java.lang.String>
 
Verifying instantiability
 
com.google.gwt.i18n.client.impl.ConstantMap
 
Analyzing the fields of type
'com.google.gwt.i18n.client.impl.ConstantMap' that qualify for
serialization
 
[WARN] Field 'private final
com.google.gwt.i18n.client.impl.ConstantMap.OrderedConstantSet<java.lang.String>
keys' will not be serialized because it is final
.F
Time: 13.961
There was 1 failure:
1) testGetRootContainer(com.mycompany.client.FirstGWT15EclipseAppTest)
junit.framework.AssertionFailedError: null

FAILURES!!!
Tests run: 2,  Failures: 1,  Errors: 0


Any help would be appreciated. Thanks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to