Hello all,
I already tried to post this message in the HTTPUnit list, but got no
answer!
Maybe somebody here knows a solution for my problem?
I've a little problem with httpunit invoking struts actions. When I try
to call an URL like http://localhost:8080/Root/login.do
followed by a session id generated by struts, the login.do part of the
url is replaced by the number 5??!?! Thus the test fails and all I get
is an 404 ERROR.
When I try to print out the form action (lForm.getAction()) the correct
URL is shown!
See code below for details:
<snipp>
public void testHTTP()
throws MalformedURLException, IOException, SAXException {
WebConversation conversation = new WebConversation();
WebRequest request = new
GetMethodWebRequest("http://localhost:8080/MyApp/login.do");
WebResponse response = conversation.getResponse(request);
WebForm[] forms = response.getForms();
for (int i = 0; i < forms.length; i++) {
WebForm lForm = forms[i];
String[] names = lForm.getParameterNames();
Button[] lButtons = lForm.getButtons();
for (int j = 0; j < lButtons.length; j++) {
Button lButton = lButtons[j];
WebResponse lResponse = null;
if (lButton.getName().equals("submit")) {
// Shows correct part of URL
System.out.println(lForm.getAction());
try{
lResponse = lForm.submit((SubmitButton) lButton);
System.out.println(lResponse.getText());
}catch(HttpNotFoundException e) {
e.printStackTrace();
}
}
}
}
assertEquals(1, forms.length);
assertEquals(1, forms[0].getParameterNames().length);
assertEquals("name", forms[0].getParameterNames()[0]);
}
<snapp>
-- Thanks for any help
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]