re: [httpunit-develop] servletunit and external javascript
Brought to you by:
russgold
From: daniel s. <da...@pr...> - 2003-12-22 01:57:15
|
**************************************************************** *** THE FOLLOWING MESSAGE HAS BEEN RENDERED SAFE BY SAFESEND *** *** The original email contained a plain text message. Only *** *** the plain text portion of the message is included here. *** *** Other parts of the message may have been removed for *** *** security reasons. *** *** To: htt...@li... *** *** From: "daniel sheppard" <da...@pr...> *** **************************************************************** and now to solve the problem that is actually bugging you. the problem you've got is because servletunit is running everything internally. you haven't told it where your js script file lives, so it is looking inside it's servlet container and finding nothing. from what i remember, servletunit doesn't automatically register a file-serving servlet at the "/" path (like most servlet containers do) - until the advent of javascript, there really wasn't a need for serving static files, so that could be neglected. i don't have time to whip one up at the moment.... you might be able to track down the one from in tomcat and register that - i believe the class is org.apache.tomcat.servlets.defaultservlet daniel sheppard http://freeroller.net/page/soxbox > -----original message----- > from: aaron humphrey [mailto:hum...@ka...] > sent: saturday, 20 december 2003 4:06 am > to: htt...@li... > subject: [httpunit-develop] servletunit and external javascript > > > > okay, so i updated the versions of xerces and neko i'm using > with httpunit, and now everything works fine. > > except for one page. it has an externally included .js file, as so: > > src=3d"http://192.168.0.1/soccer/checkvalid.js"> > > now, possibly because i'm running these tests using > servletunit, like so: > > servletrunner srtest; > private final string webtestdir =3d > "p:\\private\\aaron\\vcs\\soccer\\proj\\test\\"; > > [...] > > public void testeditscore() throws exception { > servletunitclient suctest; > webrequest wrqtest; > string strfilename; > > srtest.registerservlet("editscore", > editscore.class.getname()); > suctest =3d srtest.newclient(); > wrqtest =3d new > postmethodwebrequest("http://localhost/editscore"); > wrqtest.setparameter("gameid","2182"); > strfilename =3d webtestdir + "editscore_sample_2182.html"; > checkservletoutput(suctest.getresponse(wrqtest), strfilename); > } > > ...i get an error running the test: > > 1) > testeditscore(com.kakari.soccer.test.soccerwebtest)com.meterwa > re.httpunit.httpnotfoundexception: error on http request: 404 > no servlet mapping defined [http://192.168.0.1/soccer/checkvalid.js] > at > com.meterware.servletunit.webapplication$servletrequestimpl.ge > tservlet(webapplication.java:555) > at > com.meterware.servletunit.invocationcontextimpl.getservlet(inv > ocationcontextimpl.java:73) > at > com.meterware.servletunit.servletunitclient.newresponse(servle > tunitclient.java:94) > at > com.meterware.httpunit.webwindow.getresource(webwindow.java:162) > at > com.meterware.httpunit.parsedhtml.getincludedscript(parsedhtml > .java:305) > at > com.meterware.httpunit.htmlpage$1.getincludedscript(htmlpage.java:246) > at > com.meterware.httpunit.parsing.nekodomparser.getincludedscript > (nekodomparser.java:105) > at > com.meterware.httpunit.parsing.scriptfilter.startelement(scrip > tfilter.java:92) > at > org.cyberneko.html.htmltagbalancer.callstartelement(unknown source) > at > org.cyberneko.html.htmltagbalancer.startelement(unknown source) > at > org.cyberneko.html.htmlscanner$contentscanner.scanstartelement > (unknown source) > at > org.cyberneko.html.htmlscanner$contentscanner.scan(unknown source) > at org.cyberneko.html.htmlscanner.scandocument(unknown source) > at org.cyberneko.html.htmlconfiguration.parse(unknown source) > at org.cyberneko.html.htmlconfiguration.parse(unknown source) > at org.apache.xerces.parsers.xmlparser.parse(unknown source) > at org.apache.xerces.parsers.domparser.parse(unknown source) > at > com.meterware.httpunit.parsing.nekohtmlparser.parse(nekohtmlpa > rser.java:41) > at com.meterware.httpunit.htmlpage.parse(htmlpage.java:244) > at > com.meterware.httpunit.webresponse.getreceivedpage(webresponse > .java:1014) > at > com.meterware.httpunit.webresponse$scriptable.load(webresponse > .java:611) > at > com.meterware.httpunit.javascript.javascript$window.initialize > (javascript.java:424) > at > com.meterware.httpunit.javascript.javascript.run(javascript.java:80) > at > com.meterware.httpunit.javascript.javascriptenginefactory.asso > ciate(javascriptenginefactory.java:46) > at > com.meterware.httpunit.requestcontext.runscripts(requestcontex > t.java:44) > at > com.meterware.httpunit.webwindow.getresponse(webwindow.java:119) > at > com.meterware.httpunit.webclient.getresponse(webclient.java:112) > at > com.kakari.soccer.test.soccerwebtest.testeditscore(soccerwebte > st.java:177) > at sun.reflect.nativemethodaccessorimpl.invoke0(native method) > at > sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccess > orimpl.java:39) > at > sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmeth > odaccessorimpl.java:25) > at > com.intellij.rt.execution.junit.texttestrunner.main(texttestru > nner.java:12) > > i haven't have the fortitude yet to venture into the source, |