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
I know, I'm not waiting for result of submitting the form. How would
I change or add to
saveButton.click();
that submits the form, that would wait for the
FormPanel.SubmitCompleteEvent? Thanks, - Dave
final ProductDetailsView productDetailsView = new
ProductDetailsView();
which is client code. That is, I can't put JUnit directives in
there. Does that make sense? The form panel within there already has
a submit complete handler associated with it, so I'm not sure if I can
override that from my test case. Ultimately, I just want to see if
the form submission resulted in a non-200 response.
Thanks, - Dave