This problem occurs with httpunit 1.7, not with 1.6.2 .
The code ic pretty simple, just submit a button:
form.setParameter(edName, user);
form.setParameter(edPwd, password);
SubmitButton sb = form.getSubmitButton(pbAn);
resp = form.submit(sb);
The same request is sent twice to the server.
Debugging webform.class:
public WebResponse submit( SubmitButton button, int x, int y ) throws IOException, SAXException {
WebResponse result=null;
if (button==null || button.doOnClickSequence(x, y)) {
result= doFormSubmit( button, x, y );
} else {
result=getCurrentFrameContents();
}
return result;
}
the request is submitted in button.doOnClickSequence *AND* in doFormSubmit.
Scripting is disabled by
HttpUnitOptions.setScriptingEnabled(false);
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I can confirm that erronous behaviour. As stated the point here is that in a normal form submit the doFormSubmit method is called twice through the WebForm.submit(SubmitButton button, int x, int y) method. Once explicitly and another a second time through the button.doOnClickSequence call in the if condition.
This problem occurs with httpunit 1.7, not with 1.6.2 .
The code ic pretty simple, just submit a button:
form.setParameter(edName, user);
form.setParameter(edPwd, password);
SubmitButton sb = form.getSubmitButton(pbAn);
resp = form.submit(sb);
The same request is sent twice to the server.
Debugging webform.class:
public WebResponse submit( SubmitButton button, int x, int y ) throws IOException, SAXException {
WebResponse result=null;
if (button==null || button.doOnClickSequence(x, y)) {
result= doFormSubmit( button, x, y );
} else {
result=getCurrentFrameContents();
}
return result;
}
the request is submitted in button.doOnClickSequence *AND* in doFormSubmit.
Scripting is disabled by
HttpUnitOptions.setScriptingEnabled(false);
I can confirm that erronous behaviour. As stated the point here is that in a normal form submit the doFormSubmit method is called twice through the WebForm.submit(SubmitButton button, int x, int y) method. Once explicitly and another a second time through the button.doOnClickSequence call in the if condition.
Here is a stacktrace upon a form submit in 1.7:
Thread [main] (Suspended)
WebForm.doFormSubmit(SubmitButton, int, int) line: 143
SubmitButton.doButtonAction(int, int) line: 69
SubmitButton(Button).doOnClickSequence(int, int) line: 91
WebForm.submit(SubmitButton, int, int) line: 107 <=== 2nd call to doFormSubmit(SubmitButton, x, y) if stack decreased
WebForm.submit(SubmitButton) line: 93
[...snip...]
You can see that the first submit is triggered during the evaluation of the if condition and another time if the condition evaluates positively.
In HttpUnit 1.6 instead of button.doOnClickSequence(x, y)) button.doOnClickEvent was used which didn't implicitly trigger a form submit.
cheers,
dominique
there already exists a bug report for that:
https://sourceforge.net/tracker/index.php?func=detail&aid=2034998&group_id=6550&atid=106550