I'm using HttpUnit to unit-test a J2EE application (Servlet + EJB). We have a Struts-like servlet layer that routes HTTP requests through a dispatcher, so all the links in the pages I'm testing look something like:
Is the query string (the text after "?" in the URL) properly encoded?
For example, and spaces in a "variable" or "value" in the string should be encoded as "+" or "%20". Other characters (such as "&", "=", "/" and more) should be encoded with their %HH equivalents.
If your code is building the query string itself, be sure to pass all variables and values that appear in the query string through the encode() method of java.net.URLEncoder before the query string is assembled by joining variables and values with "=" and variable/value pairs with "&".
Hope that helps.
Dave
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I'm using HttpUnit to unit-test a J2EE application (Servlet + EJB). We have a Struts-like servlet layer that routes HTTP requests through a dispatcher, so all the links in the pages I'm testing look something like:
http://host:port/dispatch?formName=foo&ref=bar&parm1=val1&par2=val2&SomeEvent
HttpUnit is throwing an Exception if I invoke click() on a WebLink related to this sort of link:
Error on HTTP request: 404 Not Found [http://host:port/dispatch?formName=foo&ref=bar&parm1=val1&par2=val2&SomeEvent]
Has anyone seen this before?
Thanks,
Rich
Oops - I should have been more specific. The link that's causing HttpUnit problems seems to work fine in any generic browser.
Is the query string (the text after "?" in the URL) properly encoded?
For example, and spaces in a "variable" or "value" in the string should be encoded as "+" or "%20". Other characters (such as "&", "=", "/" and more) should be encoded with their %HH equivalents.
If your code is building the query string itself, be sure to pass all variables and values that appear in the query string through the encode() method of java.net.URLEncoder before the query string is assembled by joining variables and values with "=" and variable/value pairs with "&".
Hope that helps.
Dave