jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Franz Roth" <franzr...@gmx.de>
Subject Re: problem with httpunit-1.6: Unable to retrieve script included by this response
Date Thu, 31 Aug 2006 17:22:07 GMT
Hi,

this may not be a good solution, but i had this exception, too (years ago  
:)))).
I've seen no better way than this:
I've modified - this may not be very reliable(!!!) - the ParsedHTML-class:


  Method: getIncludedScript:


String getIncludedScript( String srcAttribute )  {
         try {
			StringBuffer back= new StringBuffer("\t<script>");
			/*URL url = getBaseURL();
			URL scriptUrl= new URL(url.getProtocol() + "://" +
					url.getHost() + srcAttribute);
			HttpURLConnection http = (HttpURLConnection)url.openConnection();
			
			BufferedReader in = new BufferedReader(new
					InputStreamReader(http.getInputStream()));
			String line;
			while ((line = in.readLine()) != null) {
				back.append(line + "\n");
			}
			in.close();*/
			back.append("\t</script>");
			return back.toString();
			/** orig. code:
			WebRequest req = new GetMethodWebRequest( getBaseURL(), srcAttribute );
			
			WebWindow window = getResponse().getWindow();
			if (window == null)
				throw new IllegalStateException(
						"Unable to retrieve script included by this response, " +
						"since it was loaded by getResource(). Use getResponse() instead.");
			
			return window.getResource( req ).getText();**/
		} catch (Exception e) {
			
			return "";
		}
     }



On Thu, 31 Aug 2006 11:08:47 +0200, Sushma Suresh <era_sushma@yahoo.co.in>  
wrote:

> Hi,
>
> Now getting some other problem.
>
> the code is as follows...
>
> endJspOutput(com.meterware.httpunit.WebResponse
> res)throws Exception {
> 	 HttpUnitOptions.setScriptingEnabled( false );
>          WebTable[] table = res.getTables();
>          assertEquals("table", 1, table.length );
>       }
> Actually the JSP which I'm using has javascript.
> However Httpunit doc says by setting
> HttpUnitOptions.setScriptingEnabled( false ); we can
> turn off scripting.
> "http://httpunit.sourceforge.net/doc/faq.html#disable%20scripting"
> however that does not seem to have any
> effect in the above code.
>
> The error message I'm getting is as follows...
>
> is it necessary to include js.jar...please suggest how
> to go abt it.
>
>   <?xml version="1.0" encoding="UTF-8" ?>
> - <testsuites>
> - <testsuite name="HTMLSampleTestCase" tests="1"
> failures="0" errors="1" time="2.219">
> - <testcase name="testJspOutput" time="2.141">
>   <error message="Unable to retrieve script included
> by this response, since it was loaded by
> getResource(). Use getResponse() instead."
> type="java.lang.IllegalStateException">java.lang.IllegalStateException:
> Unable to retrieve script included by this response,
> since it was loaded by getResource(). Use
> getResponse() instead. at
> com.meterware.httpunit.ParsedHTML.getIncludedScript(ParsedHTML.java:356)
> at
> com.meterware.httpunit.ParsedHTML.getScript(ParsedHTML.java:339)
> at
> com.meterware.httpunit.ParsedHTML.interpretScriptElement(ParsedHTML.java:319)
> at
> com.meterware.httpunit.ParsedHTML.access$700(ParsedHTML.java:37)
> at
> com.meterware.httpunit.ParsedHTML$ScriptFactory.recordElement(ParsedHTML.java:489)
> at
> com.meterware.httpunit.ParsedHTML$2.processElement(ParsedHTML.java:702)
> at
> com.meterware.httpunit.NodeUtils$PreOrderTraversal.perform(NodeUtils.java:195)
> at
> com.meterware.httpunit.ParsedHTML.loadElements(ParsedHTML.java:718)
> at
> com.meterware.httpunit.ParsedHTML.getTables(ParsedHTML.java:185)
> at
> com.meterware.httpunit.WebResponse.getTables(WebResponse.java:555)
> at
> HTMLSampleTestCase.endJspOutput(HTMLSampleTestCase.java:69)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method) at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at
> org.apache.cactus.internal.client.ClientTestCaseCaller.callGenericEndMethod(ClientTestCaseCaller.java:441)
> at
> org.apache.cactus.internal.client.ClientTestCaseCaller.callEndMethod_aroundBody2(ClientTestCaseCaller.java:208)
> at
> org.apache.cactus.internal.client.ClientTestCaseCaller.callEndMethod_aroundBody3$advice(ClientTestCaseCaller.java:306)
> at
> org.apache.cactus.internal.client.ClientTestCaseCaller.callEndMethod(ClientTestCaseCaller.java)
> at
> org.apache.cactus.internal.client.ClientTestCaseCaller.runTest(ClientTestCaseCaller.java:148)
> at
> org.apache.cactus.internal.AbstractCactusTestCase.runBareClient(AbstractCactusTestCase.java:215)
> at
> org.apache.cactus.internal.AbstractCactusTestCase.runBare(AbstractCactusTestCase.java:133)
> at
> org.apache.cactus.server.runner.ServletTestRunner.run(ServletTestRunner.java:308)
> at
> org.apache.cactus.server.runner.ServletTestRunner.doGet_aroundBody0(ServletTestRunner.java:186)
> at
> org.apache.cactus.server.runner.ServletTestRunner.doGet_aroundBody1$advice(ServletTestRunner.java:224)
> at
> org.apache.cactus.server.runner.ServletTestRunner.doGet(ServletTestRunner.java)
> at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
> at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
> at
> com.hypertechsolutions.ipm.controller.UtfFilter.doFilter(UtfFilter.java:47)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
> at
> com.hypertechsolutions.ipm.controller.GZIPFilter.doFilter(GZIPFilter.java:27)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
> at
> com.hypertechsolutions.ipm.controller.ThreadInitializerFilter.doFilter(ThreadInitializerFilter.java:26)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
> at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
> at
> org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
> at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
> at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
> at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
> at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
> at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
> at
> org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
> at
> org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
> at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
> at java.lang.Thread.run(Thread.java:595)</error>
>   </testcase>
>   </testsuite>
>   </testsuites>
>
> Thanks and regards,
> Suresh.
>
>
> 		
> __________________________________________________________
> Yahoo! India Answers: Share what you know. Learn something new
> http://in.answers.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org
>

Mime
View raw message