Re: [Httpunit-develop] (no subject)
Brought to you by:
russgold
From: Russell G. <rus...@ac...> - 2001-11-22 03:41:50
|
At 1:33 PM -0800 11/21/01, Judy Dobry wrote: >Hi, > >The program below is a ServletUnit program I've written. When I run it I get the following error message: >HttpNotFoundException: Error on HTTP request:404 [http://localhost:8100/servlet/edu.ucop.pathways.TestServlet?pagecode=StudentInfo1] > >I am able to use the URL http://localhost:8100/servlet/edu.ucop.pathways.TestServlet?pagecode=StudentInfo1 from a browser without any problems. I am also able to use it when I run httpunit programs. > >Any suggestions on this problem would be appreciated. Also if anyone has a simple ServletUnit program they would be willing to pass along it would be much appreciated. Take a look at the test cases in the test directory. You will find examples of every support API in ServletUnit. Your problem is that you are registering the servlet with the path "/TestServlet" but trying to invoke it with the path "/servlet/edu.ucop.pathways.TestServlet" which is not part of the Servlet 2.2 spec, IIRC. >import com.meterware.httpunit.*; >import com.meterware.servletunit.*; [snip] > > /** > * Verifies that the content type for TestServlet is text/html > **/ > public void testWelcomePage() throws Exception { > > > ServletRunner sr = new ServletRunner(); > sr.registerServlet("TestServlet", edu.ucop.pathways.TestServlet.class.getName()); > > ServletUnitClient sc = sr.newClient(); > > WebRequest request = new GetMethodWebRequest( "http://localhost:8100/servlet/edu.ucop.pathways.TestServlet" ); if you change this to "http://localhost:8100/TestServlet" or make the appropriate change to the registerServlet call, it should work. > > request.setParameter("pagecode", "StudentInfo1"); > WebResponse response = sc.getResponse( request ); > > assertEquals( "content type", "text/html", response.getContentType() );*/ > } also note that there is now some beginning support for web.xml. The version in the repository supports exact path matching only, but no parameters or security. -- ------------------------------------------------------------------------ Russell Gold | "... society is tradition and order rus...@ac... | and reverence, not a series of cheap | bargains between selfish interests." http://www.httpunit.org | - Poul Anderson, "Iron" |