[Webtest] NullPointerException using storeLength step against length of zero

Lars Burgess Lars Burgess" <larsburgess@gmail.com
Wed, 29 Nov 2006 11:36:56 -0800


------=_Part_29342_19864503.1164829016800
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hello,

I'm seeing the following exception when I invoke a url that returns zero
content (which is expected in this test case):


Test Case (in groovy):

invoke(description: 'Positive: Verify server returns no content if cache is
correct',
       url: CACHED_URL)

storeLength(property: 'contentLength')

verifyProperty(description: 'content-length should be 0',
               name: 'contentLength',
               text: '0')


Exception(from webtest report):

com.canoo.webtest.engine.StepExecutionExceptionMessageUnexpected exception
caught: java.lang.NullPointerExceptionStacktrace

com.canoo.webtest.engine.StepExecutionException: Unexpected exception
caught: java.lang.NullPointerException, Step: InvokePage at :  with
(taskName="invoke")
	at com.canoo.webtest.steps.Step.handleUnexpectedException(Step.java:413)
	at com.canoo.webtest.steps.AbstractBrowserAction.handleUnexpectedException(AbstractBrowserAction.java:120)
	at com.canoo.webtest.steps.request.TargetHelper.protectedGoto(TargetHelper.java:115)
	at com.canoo.webtest.steps.request.AbstractTargetAction.gotoTarget(AbstractTargetAction.java:106)
	at com.canoo.webtest.steps.request.AbstractTargetAction.doExecute(AbstractTargetAction.java:78)
	at com.canoo.webtest.steps.Step.execute(Step.java:106)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
	at org.apache.tools.ant.Task.perform(Task.java:364)
	at com.canoo.webtest.ant.TestStepSequence.executeSteps(TestStepSequence.java:43)
	at com.canoo.webtest.ant.TestStepSequence.doExecute(TestStepSequence.java:31)
	at com.canoo.webtest.steps.Step.execute(Step.java:106)
	at org.apache.tools.ant.Task.perform(Task.java:364)
	at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:164)
	at org.apache.tools.ant.Task.perform(Task.java:364)
	at groovy.util.AntBuilder.nodeCompleted(AntBuilder.java:177)
	at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:175)
	at groovy.util.AntBuilder.doInvokeMethod(AntBuilder.java:138)
	at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:86)
	at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:163)
	at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:104)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod(ScriptBytecodeAdapter.java:85)
	at net.mobio.webtest.tests.CacheControlTest.testCacheControlDigest(CacheControlTest.groovy:68)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:210)
	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:135)
	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:122)
	at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
	at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)
Caused by: java.lang.NullPointerException
	at org.apache.commons.io.IOUtils.copy(IOUtils.java:996)
	at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:217)
	at com.gargoylesoftware.htmlunit.WebResponseData.getBody(WebResponseData.java:150)
	at com.gargoylesoftware.htmlunit.WebResponseData.<init>(WebResponseData.java:105)
	at com.gargoylesoftware.htmlunit.HttpWebConnection.makeWebResponse(HttpWebConnection.java:387)
	at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:128)
	at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1371)
	at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1329)
	at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:322)
	at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:389)
	at com.canoo.webtest.steps.request.TargetHelper.getResponse(TargetHelper.java:69)
	at com.canoo.webtest.steps.request.AbstractTargetAction.getResponse(AbstractTargetAction.java:68)
	at com.canoo.webtest.steps.request.InvokePage.findTarget(InvokePage.java:134)
	at com.canoo.webtest.steps.request.AbstractTargetAction$1.call(AbstractTargetAction.java:108)
	at com.canoo.webtest.steps.request.TargetHelper.protectedGoto(TargetHelper.java:88)
	... 45 more


Is it possible to invoke a url and verify that the content length is zero?
I specifically need to test this because I'm testing that my server is
caching content.

Thanks,
Lars

------=_Part_29342_19864503.1164829016800
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hello,<br><br>I'm seeing the following exception when I invoke a url that returns zero content (which is expected in this test case):<br><br><br>Test Case (in groovy):<br><br><font size="2"><span style="font-family: courier new,monospace;">
invoke(description: 'Positive: Verify server returns no content if cache is correct',</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; url: CACHED_URL)<br><br style="font-family: courier new,monospace;">
</span><span style="font-family: courier new,monospace;">storeLength(property: 'contentLength')<br><br style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">verifyProperty(description: 'content-length should be 0',
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; name: 'contentLength', </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; text: '0')</span></font><br><br><br>Exception(from webtest report):<br><br>com.canoo.webtest.engine.StepExecutionException<h3>Message</h3>Unexpected exception caught: java.lang.NullPointerException<h3>Stacktrace
</h3>
<pre>com.canoo.webtest.engine.StepExecutionException: Unexpected exception caught: java.lang.NullPointerException, Step: InvokePage at :  with (taskName=&quot;invoke&quot;)<br>	at com.canoo.webtest.steps.Step.handleUnexpectedException
(Step.java:413)<br>	at com.canoo.webtest.steps.AbstractBrowserAction.handleUnexpectedException(AbstractBrowserAction.java:120)<br>	at com.canoo.webtest.steps.request.TargetHelper.protectedGoto(TargetHelper.java:115)<br>	at 
com.canoo.webtest.steps.request.AbstractTargetAction.gotoTarget(AbstractTargetAction.java:106)<br>	at com.canoo.webtest.steps.request.AbstractTargetAction.doExecute(AbstractTargetAction.java:78)<br>	at com.canoo.webtest.steps.Step.execute
(Step.java:106)<br>	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)<br>	at org.apache.tools.ant.Task.perform(Task.java:364)<br>	at com.canoo.webtest.ant.TestStepSequence.executeSteps(TestStepSequence.java
:43)<br>	at com.canoo.webtest.ant.TestStepSequence.doExecute(TestStepSequence.java:31)<br>	at com.canoo.webtest.steps.Step.execute(Step.java:106)<br>	at org.apache.tools.ant.Task.perform(Task.java:364)<br>	at com.canoo.webtest.ant.WebtestTask.execute
(WebtestTask.java:164)<br>	at org.apache.tools.ant.Task.perform(Task.java:364)<br>	at groovy.util.AntBuilder.nodeCompleted(AntBuilder.java:177)<br>	at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:175)<br>
	at groovy.util.AntBuilder.doInvokeMethod(AntBuilder.java:138)<br>	at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:86)<br>	at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:163)<br>	at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod
(InvokerHelper.java:104)<br>	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod(ScriptBytecodeAdapter.java:85)<br>	at net.mobio.webtest.tests.CacheControlTest.testCacheControlDigest(CacheControlTest.groovy:68)
<br>	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)<br>	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)<br>	at java.lang.reflect.Method.invoke
(Unknown Source)<br>	at junit.framework.TestCase.runTest(TestCase.java:154)<br>	at junit.framework.TestCase.runBare(TestCase.java:127)<br>	at junit.framework.TestResult$1.protect(TestResult.java:106)<br>	at junit.framework.TestResult.runProtected
(TestResult.java:124)<br>	at junit.framework.TestResult.run(TestResult.java:109)<br>	at junit.framework.TestCase.run(TestCase.java:118)<br>	at junit.framework.TestSuite.runTest(TestSuite.java:208)<br>	at junit.framework.TestSuite.run
(TestSuite.java:203)<br>	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)<br>	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
<br>	at java.lang.reflect.Method.invoke(Unknown Source)<br>	at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:210)<br>	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java
:135)<br>	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:122)<br>	at org.apache.maven.surefire.Surefire.run(Surefire.java:129)<br>	at sun.reflect.NativeMethodAccessorImpl.invoke0
(Native Method)<br>	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)<br>	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)<br>	at java.lang.reflect.Method.invoke(Unknown Source)<br>	at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess
(SurefireBooter.java:225)<br>	at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)<br>Caused by: java.lang.NullPointerException<br>	at org.apache.commons.io.IOUtils.copy(IOUtils.java:996)<br>	at 
org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:217)<br>	at com.gargoylesoftware.htmlunit.WebResponseData.getBody(WebResponseData.java:150)<br>	at com.gargoylesoftware.htmlunit.WebResponseData.&lt;init&gt;(WebResponseData.java
:105)<br>	at com.gargoylesoftware.htmlunit.HttpWebConnection.makeWebResponse(HttpWebConnection.java:387)<br>	at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:128)<br>	at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection
(WebClient.java:1371)<br>	at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1329)<br>	at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:322)<br>	at com.gargoylesoftware.htmlunit.WebClient.getPage
(WebClient.java:389)<br>	at com.canoo.webtest.steps.request.TargetHelper.getResponse(TargetHelper.java:69)<br>	at com.canoo.webtest.steps.request.AbstractTargetAction.getResponse(AbstractTargetAction.java:68)<br>	at com.canoo.webtest.steps.request.InvokePage.findTarget
(InvokePage.java:134)<br>	at com.canoo.webtest.steps.request.AbstractTargetAction$1.call(AbstractTargetAction.java:108)<br>	at com.canoo.webtest.steps.request.TargetHelper.protectedGoto(TargetHelper.java:88)<br>	... 45 more
<br><font size="4"><br><span style="font-family: arial,sans-serif;"><br><font size="2">Is it possible to invoke a url and verify that the content length is zero? <br>I specifically need to test this because I'm testing that my server is caching content.
<br><br>Thanks,<br>Lars<br></font></span></font></pre>

------=_Part_29342_19864503.1164829016800--