[Webtest] NullPointerException using storeLength step against length of zero

Lars Burgess Lars Burgess" <larsburgess@gmail.com
Wed, 29 Nov 2006 14:49:58 -0800


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

Thanks for the quick reply. Unfortunately, I'm still getting the same
NullPointerException. I'm using the latest webtest build in maven format
(R_1440) which uses groovy-all-1.0-jsr-06. All of my other test cases which
store properties run successfully written in the format:

storeHeader(name: 'cookie', property: 'cookieHeader')

Anything else I should try?

Thanks,
Lars


On 11/29/06, Dierk Koenig <dierk.koenig@canoo.com> wrote:
>
>  I don't think that this is the root cause of your issue but it may be
> that in the
> Groovy version you are using "property" is still a keyword.
> please try
> storeLength('property': 'contentLength')
>
> ciao
> Dierk
>
> -----Original Message-----
> *From:* webtest-admin@lists.canoo.com [mailto:
> webtest-admin@lists.canoo.com]*On Behalf Of *Lars Burgess
> *Sent:* Mittwoch, 29. November 2006 20:37
> *To:* webtest@lists.canoo.com
> *Subject:* [Webtest] NullPointerException using storeLength step against
> length of zero
>
> 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.StepExecutionException MessageUnexpected
> exception caught: java.lang.NullPointerException Stacktrace
>
> 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_31904_13157219.1164840598698
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Thanks for the quick reply. Unfortunately, I'm still getting the same NullPointerException. I'm using the latest webtest build in maven format (R_1440) which uses groovy-all-1.0-jsr-06. All of my other test cases which store properties run successfully written in the format:
<br><br>storeHeader(name: 'cookie', property: 'cookieHeader')<br><br>Anything else I should try?<br><br>Thanks,<br>Lars<br><br><br><div><span class="gmail_quote">On 11/29/06, <b class="gmail_sendername">Dierk Koenig</b> &lt;
<a href="mailto:dierk.koenig@canoo.com">dierk.koenig@canoo.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">



<div>
<div><span><font color="#0000ff" face="Arial" size="2">I 
don't think that this is the root cause of your issue but it&nbsp;may be that in 
the </font></span></div>
<div><span><font color="#0000ff" face="Arial" size="2">Groovy 
version you are using &quot;property&quot; is still a keyword.</font></span></div>
<div><span><font color="#0000ff" face="Arial" size="2">please 
try</font></span></div>
<div><span><span style="font-family: courier new,monospace;"><font size="2">storeLength('property': 
'contentLength')</font></span></span></div>
<div><span><span style="font-family: courier new,monospace;"><font size="2"></font></span></span>&nbsp;</div>
<div><span><span style="font-family: courier new,monospace;"><font size="2">ciao</font></span></span></div><span class="sg">
<div><span><span style="font-family: courier new,monospace;"><font size="2">Dierk</font></span></span></div></span><div><span class="e" id="q_10f35cad73e76a90_2">
<blockquote dir="ltr" style="border-left: 2px solid rgb(0, 0, 255); padding-left: 5px; margin-left: 5px; margin-right: 0px;">
  <div dir="ltr" align="left"><font face="Tahoma" size="2">-----Original Message-----<br><b>From:</b> 
  <a href="mailto:webtest-admin@lists.canoo.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">webtest-admin@lists.canoo.com</a> [mailto:<a href="mailto:webtest-admin@lists.canoo.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
webtest-admin@lists.canoo.com</a>]<b>On 
  Behalf Of </b>Lars Burgess<br><b>Sent:</b> Mittwoch, 29. November 2006 
  20:37<br><b>To:</b> <a href="mailto:webtest@lists.canoo.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">webtest@lists.canoo.com</a><br><b>Subject:</b> [Webtest] 
  NullPointerException using storeLength step against length of 
  zero<br><br></font></div>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></blockquote></span></div></div>

</blockquote></div><br>

------=_Part_31904_13157219.1164840598698--