Hi Clovis, I don�t know what's happening. I've checked line 105 of HTMLPage.java (in CVS HEAD) but you must be using an older version of httpunit as it doesn't match. I think this question should be asked on the HttpUnit mailing list. Russell would be able to figure out what's happening pretty quickly I would say.
Thanks -Vincent > -----Original Message----- > From: Clovis Yutaka Harada [mailto:[EMAIL PROTECTED] > Sent: 19 March 2003 15:35 > To: [EMAIL PROTECTED] > Subject: External Javascript files > > > Hi list, > > I�m using cactus 1.4.1 to test a web app. > I�ve built some unit tests with cactus and junit and everything is ok. > They are integrated with ant and cruise-control so all tests run every > hour. > > Now I�m doing some functional tests using cactus with httpunit and I�m > having problems with external javascript files. > > If i have something like: > ----- > <SCRIPT language=JavaScript1.2 src="common/HM_Loader.js" > type=text/javascript></SCRIPT> > ----- > the test fails with this trace: > [junit] Testcase: testTelaMenu1 took 0.794 sec > [junit] Caused an ERROR > [junit] null > [junit] java.lang.NullPointerException > [junit] at > com.meterware.httpunit.HTMLPage.getIncludedScript(HTMLPage.java:105) > [junit] at > com.meterware.httpunit.DOMParser.getIncludedScript(NekoHTMLParser.java:1 17 > ) > [junit] at > com.meterware.httpunit.ScriptFilter.startElement(ScriptFilter.java:87) > [junit] at org.cyberneko.html.HTMLTagBalancer.startElement(Unknown > Source) > [junit] at > org.cyberneko.html.HTMLScanner$ContentScanner.scanStartElement(Unknown > Source) > [junit] at > org.cyberneko.html.HTMLScanner$ContentScanner.scan(Unknown Source) > [junit] at org.cyberneko.html.HTMLScanner.scanDocument(Unknown > Source) > [junit] at org.cyberneko.html.HTMLConfiguration.parse(Unknown > Source) > [junit] at org.cyberneko.html.HTMLConfiguration.parse(Unknown > Source) > [junit] at org.apache.xerces.parsers.XMLParser.parse(Unknown > Source) > [junit] at org.apache.xerces.parsers.DOMParser.parse(Unknown > Source) > [junit] at > com.meterware.httpunit.NekoHTMLParser.parse(NekoHTMLParser.java:49) > [junit] at > com.meterware.httpunit.HTMLPage.parse(HTMLPage.java:249) > [junit] at > com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:918) > [junit] at > com.meterware.httpunit.WebResponse.getForms(WebResponse.java:289) > [junit] at > iwse.controller.ControllerTest.endTelaMenu1(ControllerTest.java:280) > [junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native > Method) > [junit] at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav a: > 39 > ) > [junit] at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor Im > pl > .java:25) > [junit] at > org.apache.cactus.AbstractWebTestCase.callEndMethod(AbstractWebTestCase. ja > va > :177) > [junit] at > org.apache.cactus.AbstractWebTestCase.runGenericTest(AbstractWebTestCase .j > av > a:263) > [junit] at > org.apache.cactus.ServletTestCase.runTest(ServletTestCase.java:133) > [junit] at > org.apache.cactus.AbstractTestCase.runBare(AbstractTestCase.java:195) > > > Note that, if I retrive the page with HttpUnit alone everything works > fine. > Also, if I put the javascript code inside the html page (insted of loading > in separate file) using: > ----- > <script> > <[EMAIL PROTECTED] file="HM_Loader.js" %> > </script> > ----- > the test run without any problem. > > > I think it is obvious but here is the code that fails (with external > javascript file): > --------- > public void endTelaMenu1( > com.meterware.httpunit.WebResponse theResponse) throws > Exception > { > com.meterware.httpunit.WebForm form = theResponse.getForms()[0]; > assertEquals(reqScrambled, form.getParameterValue("CTL")); > assertEquals("-1", form.getParameterValue("NUMCC")); > assertEquals("-1", form.getParameterValue("NUMPP")); > --------- > > And here is the httpunit code that works (with external javascript file): > --------- > public void testTelaMenu() { > WebConversation wc = new WebConversation(); > WebRequest req = > new GetMethodWebRequest( > > "http://xxxxx:8080/xxx/xxxx/xxxxxx.asp?CTL=4272910994907"); > WebResponse resp = wc.getResponse(req); > WebForm form = resp.getForms()[0]; > assertEquals(reqScrambled, form.getParameterValue("CTL")); > assertEquals("-1", form.getParameterValue("NUMCC")); > assertEquals("-1", form.getParameterValue("NUMPP")); > } > --------- > > Clovis > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
