1

I have an application where everything starts from a single servlet and then based on some params to initial servlet complete behaviour of application changes, there are lots of things and forwarding which happens until you get response as a HTML.

I want to write test cases, where I only change those few initial parameters and get a response either as getText() or getXml() or getHTML().

I used HttpUnit, something like.

WebRequest request = new PostMethodWebRequest("http://localhost:9090/xyz/ETransServlet.fsc" );
request.setParameter( "window_id", "1" );
request.setParameter( "screen_id", "4" );
request.setParameter( "nav_to", "something.jsp" );
request.setParameter( "nav_from", "somethingfrom.jsp" );    

HttpSession session = sr.getSession(true);

WebResponse response = client.getResponse(request);`

Now you see I have some parameter set window_id and all.

first thing, they are not reaching somehow.

secondly, even if I call some page with no params, still it gives error something like can't process script <script> blab bla </script>

It's unable to process javascript code that we are using. I have js.jar and nekohtml.jar in build path and beside I don't want it to validate javascript or html at all.

Can anyone tell what's wrong or how to stop javascript to validate or fix it even if it validates or not or some other solution entirely.

cheffe
  • 9,345
  • 2
  • 46
  • 57
Vivek
  • 580
  • 2
  • 7
  • 26
  • (1) Is it an option to disable javascript handling totaly? (2) You are using HtmlUnit, right? Not HttpUnit ... – cheffe Mar 14 '14 at 14:08
  • sorry for later reply , i tried both HttpUnit and HtmlUnit , what i need is a servlet call , with some params some sessions , and a response as HTML or XML or text , i know it would wiser to test only business logic , but this application is ancient , every method has HttpServletRequest as parameters , i rather make dummy of it at start of request instead of writing units cases for every methods it called. – Vivek Mar 18 '14 at 07:26

0 Answers0