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