[Webtest] Failling to check an email
Florent Blondeau
Florent Blondeau <fblondeau@pingwy.com>
Mon, 12 Nov 2007 15:32:13 +0100
Hi there,
I'm happy to post here, that seems to be a good place...
I am a new Webtest user, and I encounter some little problems.
(When reading my silly questions, remember I discovered Webtest,
Groovy and Grails the same day one day ago. It's a pretty huge thing, but
how exciting ;-) )
I realize emails tests from some Groovy code with the AntBuilder.I would
like to
check if a certain email is arrived in my box. Here is my Groovy Code :
def config_map=[...] //my configuration
ant.testSpec(name:gname){
config(config_map){
option(name:"ThrowExceptionOnScriptError",value:"false")
}
steps(){
emailSetConfig(server:"pop.mypop3.com", type:"pop3",
password:"pop3pop3", username:"my.email@address.com", delay:"5")
emailStoreMessageId(from:"/info@mytestmail.com/",property:"mail1")
emailMessageStructureFilter(headers:"subject,from,to",messageId:"#{mail1}")
// I tried this one but even if the message exists, it
fails
//emailMessageContentFilter(subject:"test",
messageId:"#{email01}")
}
}
So, everything is OK with the connexion and the authentication to the
server, but a problem
arise when I try to get my mails. I show you the error :
INFO (com.canoo.webtest.ant.WebtestTask) - Starting webtest "Groovy" (: )
INFO (com.canoo.webtest.ant.WebtestTask) - Canoo Webtest: R_1551.
INFO (com.canoo.webtest.engine.Configuration) - Surfing with browser
Mozilla/4.0 (compatible; MSIE 6.0b; Windows 98)
INFO (com.canoo.webtest.engine.Configuration) - set option
<ThrowExceptionOnScriptError> to value <false>
INFO (com.canoo.webtest.steps.Step) - >>>> Start Step: steps (1/3)
INFO (com.canoo.webtest.steps.Step) - >>>> Start Step: emailSetConfig (1/3)
INFO (com.canoo.webtest.steps.Step) - >>>> Start Step:
emailStoreMessageId (2/3)
INFO (com.canoo.webtest.plugins.emailtest.EmailStoreMessageId) -
Multiple matching messages found, using the first.
INFO (com.canoo.webtest.steps.Step) - >>>> Start Step:
emailMessageStructureFilter (3/3)
INFO (com.canoo.webtest.steps.Step) - >>>> Start Step: null (3/3)
INFO (com.canoo.webtest.steps.Step) - Running with: Canoo Webtest: R_1551.
INFO (com.canoo.webtest.steps.Step) - Exception thrown from this class:
java.lang.RuntimeException
INFO (com.canoo.webtest.steps.Step) - Message was: Illegal new current
response
ERROR (com.canoo.webtest.steps.Step) - Cannot handle unexpected
exception in step EmailMessageStructureFilter at : with
(taskName="emailMessageStructureFilter")
java.lang.RuntimeException: Illegal new current response
at com.canoo.webtest.util.Checker.assertTrue(Checker.java:17)
at com.canoo.webtest.util.Checker.assertFalse(Checker.java:12)
at
com.canoo.webtest.engine.WebClientContext.saveResponseAsCurrent(WebClientContext.java:238)
at
com.canoo.webtest.engine.WebClientContext.saveResponseAsCurrent(WebClientContext.java:228)
at
com.canoo.webtest.engine.Context.saveResponseAsCurrent(Context.java:311)
at
com.canoo.webtest.plugins.emailtest.AbstractEmailFilter.performOperation(AbstractEmailFilter.java:38)
at
com.canoo.webtest.plugins.emailtest.AbstractMessageOperationStep.doExecute(AbstractMessageOperationStep.java:53)
at com.canoo.webtest.steps.Step.execute(Step.java:104)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
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:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at groovy.util.AntBuilder.nodeCompleted(AntBuilder.java:184)
at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:184)
at groovy.util.AntBuilder.doInvokeMethod(AntBuilder.java:145)
at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:95)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:136)
at
org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
at com.pingwy.groovy.tests.Webtest.main(Webtest.groovy:32)
INFO (com.canoo.webtest.steps.Step) - Running with: Canoo Webtest: R_1551.
INFO (com.canoo.webtest.steps.Step) - Exception thrown from this class:
com.canoo.webtest.engine.StepExecutionException
INFO (com.canoo.webtest.steps.Step) - Message was: Unexpected exception
caught: java.lang.RuntimeException: Illegal new current response
INFO (com.canoo.webtest.ant.WebtestTask) - Finished executing webtest
"Groovy" (: )
INFO (com.canoo.webtest.ant.WebtestTask) - Test report successfully
created.
Is is a correct way to retreive emails from a server ? Please tell me if
you know what is happening to me
Another thing, I'm trying to get more familiar with groovy syntax and
behavior... but when you can just call
step.context.currentResponse.documentElement in the <groovy .../> step
in the xml file to get the response, how can you achieve it
when writing a groovy script ?
Thanks for your Help
Florent Blondeau
--
Pingwy
27, rue des arčnes
49100 Angers