Dear Mostafa,

please find below a test case I just added to show what IMHO is happening.
You might want to register your servlet with the fully qualifying url. If you register "validateLogin" but use "ISB/validateLogin"
you'll get the exception you are seeing (as shown by the JUnit test case below.

You are kindly invited to post your question on stackoverflow.com with the tag httpunit to let others know about this handling issue.

Yours
  Wolfgang  

    @Test
    /**
     * Test added by WF 2012-11-12 to answer question on developers mailing list
     * @throws Exception
     */
    public void testInvalidConfig() throws Exception {
      final String resourceName = "something/interesting";

      ServletRunner sr = new ServletRunner();
      sr.registerServlet(resourceName, ConfigServlet.class.getName());
      WebClient wc = sr.newClient();
      try {
          WebResponse response = wc.getResponse("http://localhost/" + "ISB/"+ resourceName);
          fail("No Exception thrown");
      } catch (Throwable th) {
          // com.meterware.httpunit.HttpNotFoundException:
          // Error on HTTP request: 404 No servlet mapping defined [http://localhost/ISB/something/interesting]
          String expected="Error on HTTP request: 404 No servlet mapping defined [http://localhost/ISB/something/interesting]";
          assertTrue("HttpNotFoundException expected",th instanceof HttpNotFoundException);
          assertEquals("wrong exception message",expected,th.getMessage());
      }
    }

 
Am 12.11.12 01:38, schrieb mostafa kandil:
Hi httpunit developers team:
first i appreciate the work of httpunit framework, i have 4 weeks ago searching for a tool i can use to test java Servlet. so when i found your framework, i was so happy :D . 
i have downloaded last released, and tried a simple case:
void test(){
     try {
            ServletRunner sr = new ServletRunner();
            sr.registerServlet("validateLogin", "validateLogin");  
                         // or  sr.registerServlet("validateLogin", validateLogin.class.getName());
            ServletUnitClient sc = sr.newClient();
            WebRequest request = new PostMethodWebRequest("http://cuportal.cu.edu.eg:8080/ISB/validateLogin");

            request.setParameter("un", "user1");
            request.setParameter("pwd", "userpwd");         
          
            WebResponse response = sc.getResponse(request);
            assertEquals("requested resource", "user_page.jsp", response.getText());
        } catch (Exception e) {
            System.err.println("ERROR: " + e);
            e.printStackTrace();
        }
}
Always i got exception at red line :
  ERROR: com.meterware.httpunit.HttpNotFoundException: Error on HTTP request: 404 No servlet mapping defined [http://cuportal.cu.edu.eg:8080/ISB/validateLogin]
___________________________________
com.meterware.httpunit.HttpNotFoundException: Error on HTTP request: 404 No servlet mapping defined [http://cuportal.cu.edu.eg:8080/ISB/validateLogin]
at com.meterware.servletunit.WebApplication$ServletRequestImpl.getServlet(WebApplication.java:772)
at com.meterware.servletunit.InvocationContextImpl$ExecutionContext.getServlet(InvocationContextImpl.java:248)
at com.meterware.servletunit.InvocationContextImpl.getServlet(InvocationContextImpl.java:86)
at com.meterware.servletunit.InvocationContextImpl.service(InvocationContextImpl.java:76)
at com.meterware.servletunit.ServletUnitClient.newResponse(ServletUnitClient.java:126)
at com.meterware.httpunit.WebClient.createResponse(WebClient.java:647)
at com.meterware.httpunit.WebWindow.getResource(WebWindow.java:220)
at com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:181)
at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:158)
at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:125)
at com.meterware.httpunit.WebClient.getResponse(WebClient.java:96)
at myServletTest.testISB(myServletTest.java:65)
at myServletTest.<init>(myServletTest.java:21)
at myServletTest.main(myServletTest.java:81)

i'm using  'Java EE 6 Web', and  netbeans tool.
i have added all libraries.

Can you help me please solve that exception?  

thanks in advance
 




------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov


_______________________________________________
Httpunit-develop mailing list
Httpunit-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/httpunit-develop

-- 

BITPlan - smart solutions
Wolfgang Fahl
Pater-Delp-Str. 1, D-47877 Willich Schiefbahn
Tel. +49 2154 811-480, Fax +49 2154 811-481
Web: http://www.bitplan.de
BITPlan GmbH, Willich - HRB 6820 Krefeld, Steuer-Nr.: 10258040548, Geschäftsführer: Wolfgang Fahl