Wednesday, November 30, 2011

How can I trap for a 404 in my GWTTestCase?

Hi,

I'm using GWT 2.4. I'm trying to write a GwtTestCase that tests
clicking the submit button on my FormPanel. Currently, clicking on
the submit button results in a 404, but my test isn't failing. Here's
how I have my test set up ...

public void testClickSave() {
final FlowPanel flowPanel = new FlowPanel();
final ProductDetailsView productDetailsView = new
ProductDetailsView();
flowPanel.add( productDetailsView );
RootPanel.get().add(flowPanel);

xmlHelperService.getNode("weather.txt", new AsyncCallback<Node>() {

@Override
public void onSuccess(final Node node) {
// Pre-conditions for this test are that they are children and all
the
// children are of type="section".
assertTrue(!node.getChildren().isEmpty());
for (final Node child : node.getChildren()) {
assertEquals(NodeType.SECTION.toString(),
child.getAttributes().get(XmlToHtmlServiceImpl.TYPE_ATTR).getValue());
} // for

productDetailsView.add(node);
// Click the "Save" button.
final Button saveButton = getSaveButton(productDetailsView);
saveButton.click();

finishTest();
}

@Override
public void onFailure(Throwable caught) {
caught.printStackTrace(System.err);
fail(caught.getMessage());
finishTest();
}
});

delayTestFinish(delayFinishTime);
} // testClickSave


The call to "saveButton.click();" is where the 404 is happening. What
can I do to trap for the 404 and cause my test to fail? Thanks, -
Dave

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment