[Webtest] NullPointerException using storeLength step against length of zero

Dierk Koenig Dierk Koenig" <dierk.koenig@canoo.com
Wed, 29 Nov 2006 23:17:33 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_0004_01C7140C.8C9E82F0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

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
  Message
  Unexpected 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(Abst
ractBrowserAction.java:120)	at
com.canoo.webtest.steps.request.TargetHelper.protectedGoto(TargetHelper.java
:115)	at
com.canoo.webtest.steps.request.AbstractTargetAction.gotoTarget(AbstractTarg
etAction.java:106)	at
com.canoo.webtest.steps.request.AbstractTargetAction.doExecute(AbstractTarge
tAction.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(ScriptBytecod
eAdapter.java:85)	at
net.mobio.webtest.tests.CacheControlTest.testCacheControlDigest(CacheControl
Test.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(Ab
stractDirectoryTestSuite.java
:135)	at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractD
irectoryTestSuite.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:1
50)	at
com.gargoylesoftware.htmlunit.WebResponseData.<init>(WebResponseData.java
:105)	at
com.gargoylesoftware.htmlunit.HttpWebConnection.makeWebResponse(HttpWebConne
ction.java:387)	at
com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnectio
n.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:6
9)	at
com.canoo.webtest.steps.request.AbstractTargetAction.getResponse(AbstractTar
getAction.java:68)	at com.canoo.webtest.steps.request.InvokePage.findTarget
(InvokePage.java:134)	at
com.canoo.webtest.steps.request.AbstractTargetAction$1.call(AbstractTargetAc
tion.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

------=_NextPart_000_0004_01C7140C.8C9E82F0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2995" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D060400922-29112006><FONT face=3DArial color=3D#0000ff =
size=3D2>I=20
don't think that this is the root cause of your issue but it&nbsp;may be =
that in=20
the </FONT></SPAN></DIV>
<DIV><SPAN class=3D060400922-29112006><FONT face=3DArial color=3D#0000ff =
size=3D2>Groovy=20
version you are using "property" is still a keyword.</FONT></SPAN></DIV>
<DIV><SPAN class=3D060400922-29112006><FONT face=3DArial color=3D#0000ff =
size=3D2>please=20
try</FONT></SPAN></DIV>
<DIV><SPAN class=3D060400922-29112006><SPAN=20
style=3D"FONT-FAMILY: courier new,monospace"><FONT =
size=3D2>storeLength('property':=20
'contentLength')</FONT></SPAN></SPAN></DIV>
<DIV><SPAN class=3D060400922-29112006><SPAN=20
style=3D"FONT-FAMILY: courier new,monospace"><FONT=20
size=3D2></FONT></SPAN></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D060400922-29112006><SPAN=20
style=3D"FONT-FAMILY: courier new,monospace"><FONT=20
size=3D2>ciao</FONT></SPAN></SPAN></DIV>
<DIV><SPAN class=3D060400922-29112006><SPAN=20
style=3D"FONT-FAMILY: courier new,monospace"><FONT=20
size=3D2>Dierk</FONT></SPAN></SPAN></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px =
solid; MARGIN-RIGHT: 0px">
  <DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT =
face=3DTahoma=20
  size=3D2>-----Original Message-----<BR><B>From:</B>=20
  webtest-admin@lists.canoo.com =
[mailto:webtest-admin@lists.canoo.com]<B>On=20
  Behalf Of </B>Lars Burgess<BR><B>Sent:</B> Mittwoch, 29. November 2006 =

  20:37<BR><B>To:</B> webtest@lists.canoo.com<BR><B>Subject:</B> =
[Webtest]=20
  NullPointerException using storeLength step against length of=20
  zero<BR><BR></FONT></DIV>Hello,<BR><BR>I'm seeing the following =
exception when=20
  I invoke a url that returns zero content (which is expected in this =
test=20
  case):<BR><BR><BR>Test Case (in groovy):<BR><BR><FONT size=3D2><SPAN=20
  style=3D"FONT-FAMILY: courier new,monospace">invoke(description: =
'Positive:=20
  Verify server returns no content if cache is correct',</SPAN><BR=20
  style=3D"FONT-FAMILY: courier new,monospace"><SPAN=20
  style=3D"FONT-FAMILY: courier =
new,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  url: CACHED_URL)<BR><BR=20
  style=3D"FONT-FAMILY: courier new,monospace"></SPAN><SPAN=20
  style=3D"FONT-FAMILY: courier new,monospace">storeLength(property:=20
  'contentLength')<BR><BR=20
  style=3D"FONT-FAMILY: courier new,monospace"></SPAN><SPAN=20
  style=3D"FONT-FAMILY: courier =
new,monospace">verifyProperty(description:=20
  'content-length should be 0', </SPAN><BR=20
  style=3D"FONT-FAMILY: courier new,monospace"><SPAN=20
  style=3D"FONT-FAMILY: courier new,monospace">&nbsp;&nbsp;&nbsp;&nbsp;=20
  &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; name: 'contentLength', =
</SPAN><BR=20
  style=3D"FONT-FAMILY: courier new,monospace"><SPAN=20
  style=3D"FONT-FAMILY: courier =
new,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;=20
  text: '0')</SPAN></FONT><BR><BR><BR>Exception(from webtest=20
  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=3D"invoke")<BR>	at =
com.canoo.webtest.steps.Step.handleUnexpectedException
(Step.java:413)<BR>	at =
com.canoo.webtest.steps.AbstractBrowserAction.handleUnexpectedException(A=
bstractBrowserAction.java:120)<BR>	at =
com.canoo.webtest.steps.request.TargetHelper.protectedGoto(TargetHelper.j=
ava:115)<BR>	at=20
com.canoo.webtest.steps.request.AbstractTargetAction.gotoTarget(AbstractT=
argetAction.java:106)<BR>	at =
com.canoo.webtest.steps.request.AbstractTargetAction.doExecute(AbstractTa=
rgetAction.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(ScriptByte=
codeAdapter.java:85)<BR>	at =
net.mobio.webtest.tests.CacheControlTest.testCacheControlDigest(CacheCont=
rolTest.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:21=
0)<BR>	at =
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet=
(AbstractDirectoryTestSuite.java
:135)<BR>	at =
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(Abstra=
ctDirectoryTestSuite.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=20
org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:217)<BR>	at =
com.gargoylesoftware.htmlunit.WebResponseData.getBody(WebResponseData.jav=
a:150)<BR>	at =
com.gargoylesoftware.htmlunit.WebResponseData.&lt;init&gt;(WebResponseDat=
a.java
:105)<BR>	at =
com.gargoylesoftware.htmlunit.HttpWebConnection.makeWebResponse(HttpWebCo=
nnection.java:387)<BR>	at =
com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnec=
tion.java:128)<BR>	at =
com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection
(WebClient.java:1371)<BR>	at =
com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:13=
29)<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.jav=
a:69)<BR>	at =
com.canoo.webtest.steps.request.AbstractTargetAction.getResponse(Abstract=
TargetAction.java:68)<BR>	at =
com.canoo.webtest.steps.request.InvokePage.findTarget
(InvokePage.java:134)<BR>	at =
com.canoo.webtest.steps.request.AbstractTargetAction$1.call(AbstractTarge=
tAction.java:108)<BR>	at =
com.canoo.webtest.steps.request.TargetHelper.protectedGoto(TargetHelper.j=
ava:88)<BR>	... 45 more
<BR><FONT size=3D4><BR><SPAN style=3D"FONT-FAMILY: =
arial,sans-serif"><BR><FONT size=3D2>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></BODY=
></HTML>

------=_NextPart_000_0004_01C7140C.8C9E82F0--