Hallo Marc,
I updated Webtest to Canoo Webtest: R_1378. After some problems Webtest is
working again.
I had to change my test setup as following:
<webtest (...)>
<config (...)/>
<steps>
<storeProperty description="convert Ant to dynamic" name="hasAdminRights"
value="def.hasAdm.Prop"/>
<groovy> System.out.println(
"#hasAdminRights BEFORE call=
"+step.getWebtestProperty("hasAdminRights")
.toString());</groovy>
<mytask userRole="usuario"/>
<groovy> System.out.println(
"#hasAdminRights AFTER call=
"+step.getWebtestProperty("hasAdminRights")
.toString());</groovy>
</steps>
</webtest>
My class looks basically like this:
public class CommonTasks extends WebtestTask{
private String userRole = null;
public void execute() throws BuildException{
if (userRole == null) throw new BuildException("ResolveUserRights.userRole
not set");
userRole = userRole.toUpperCase();
getProject().log("userRole: "+userRole, Project.MSG_WARN);
(CodeInsideHere)
}
public void setUserRole(String userRole) {
if (userRole == null) throw new BuildException("ResolveUserRights.userRole
is null");
this.userRole = userRole;
}
}
(CodeInsideHere) is where I try to access the dynamic
1)
CodeInsideHere=
setDynamicProperty("hasAdminRights", "hasAdminRights2");
getProject().log("hasAdminRightsDyn
:"+getDynamicProperty("hasAdminRights"));
===>
[groovy] INFO (com.canoo.webtest.extension.groovy.GroovyInvoker) - No
existing binding for this webtest, creating a new one
[groovy] #hasAdminRights BEFORE call= def.hasAdm.Prop
[null] INFO (com.canoo.webtest.steps.Step) - >>>> Start Step: null (3/4)
[null] INFO (com.canoo.webtest.steps.Step) - WrappedSteps.attributes not
found.
userRole: USUARIO
hasAdminRightsDyn :hasAdminRights2
[groovy] INFO (com.canoo.webtest.steps.Step) - >>>> Start Step: groovy (4/4)
[groovy] INFO (com.canoo.webtest.extension.groovy.GroovyInvoker) - Reusing
existing binding of this webtest.
[groovy] #hasA
Conclusion:
Looks like I can set dynamic properties in my java class with NO effect for
everything outside the class.
2)
getProject().log("hasAdminRightsDyn :"+getDynamicProperty("hasAdminRights"));
===>
[null] INFO (com.canoo.webtest.steps.Step) - WrappedSteps.attributes not
found.
userRole: USUARIO
hasAdminRightsDyn :null
[groovy] INFO (com.canoo.webtest.steps.Step) - >>>> Start Step: groovy (4/4)
[groovy] INFO (com.canoo.webtest.extension.groovy.GroovyInvoker) - Reusing
existing binding of this webtest.
[groovy] #hasAdminRights AFTER call= def.hasAdm.Prop
Conclusion:
hasAdminRights was never set
3)
boolean isUser=true;
getProject().log("-->BEFORE:", Project.MSG_ERR);
StorePropertyStep sp = new StorePropertyStep();
sp.setProject(getProject());
sp.setLocation(getLocation());
sp.setRuntimeConfigurableWrapper(getRuntimeConfigurableWrapper());
sp.setDescription("set isUserProperty");
//sp.setWebtestProperty("userRole", "userRole",
Step.PROPERTY_TYPE_DYNAMIC);
sp.setName("hasAdminRights");
sp.setProperty("hasAdminRights");
sp.setValue(Boolean.toString(isUser));
sp.doExecute();
//sp.setWebtestProperty("userRole", "userRole");
//sp.execute();
getProject().log("<--AFTER", Project.MSG_ERR);
===>
userRole: USUARIO
-->BEFORE:
INFO (com.canoo.webtest.steps.Step) - Running with: Canoo Webtest: R_1378.
INFO (com.canoo.webtest.steps.Step) - Exception thrown from this class:
org.apache.tools.ant.BuildException
INFO (com.canoo.webtest.steps.Step) - Message was:
java.lang.NullPointerException
ERROR (com.canoo.webtest.steps.Step) - Cannot handle unexpected exception in
step AntWrapper at with ()
C:\projetos\celplay_pettoy\workspace\website\webtest\testes\justATest.webtest.xml:25:
java.lang.NullPointerException
at org.apache.tools.ant.Task.perform(Task.java:373)
at com.canoo.webtest.extension.AntWrapper.doExecute(AntWrapper.java:85)
...
Caused by: java.lang.NullPointerException
at com.canoo.webtest.steps.Step.getDefaultPropertyType(Step.java:311)
at com.canoo.webtest.steps.Step.setWebtestProperty(Step.java:333)
...
java.lang.NullPointerException
at com.canoo.webtest.steps.Step.getDefaultPropertyType(Step.java:311)
at com.canoo.webtest.steps.Step.setWebtestProperty(Step.java:333)
4)
The same as above happens when using this for (CodeInsideHere)
StorePropertyStep sp = new StorePropertyStep();
sp.setWebtestProperty("hasAdminRights", "hasAdminRights");
Trys I made with the old Version ......... (not really important any more)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<<<<<<<<<<<Concerning Canoo Webtest: R_1217. <<<<<<<<<<<
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Here I tried to access a Dynamic Property via
1)
getProject().log("hasAdminRights
:"+getWebtestProperty("hasAdminRights"));
2)
setWebtestProperty("isUser", Boolean.toString(isUser),
Step.PROPERTY_TYPE_DYNAMIC);
3)
getProject().log("-->BEFORE:", Project.MSG_ERR);
StorePropertyStep sp = new StorePropertyStep();
sp.setContext(getContext());
sp.setContainer(getContainer());
sp.setProject(getProject());
sp.setLocation(getLocation());
sp.setRuntimeConfigurableWrapper(getRuntimeConfigurableWrapper());
sp.setDescription("set isUserProperty");
sp.setName("userRole");
sp.setProperty("userRole2");
sp.setValue(Boolean.toString(isUser));
sp.doExecute();
getProject().log("<--AFTER", Project.MSG_ERR);
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
with this class:
Line3: import java.util.Map;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.Echo;
import com.canoo.webtest.ant.WebtestTask;
import com.canoo.webtest.engine.Context;
import com.canoo.webtest.steps.Step;
import com.canoo.webtest.steps.store.StorePropertyStep;
// extends com.canoo.webtest.steps.Step
// WebtestTask
public class CommonTasks extends Step{
private static final long serialVersionUID = -1390935335854603020L;
private String userRole = null;
@Override
public void doExecute() throws BuildException{
if (userRole == null) throw new BuildException("ResolveUserRights.userRole
not set");
super.expandProperties();
userRole = userRole.toUpperCase();
getProject().log("userRole: "+userRole, Project.MSG_WARN);
// getProject().log("user.user.rolename::
//
"+getProject().getProperty("user.user.rolename").toString(),Project.MSG_WARN);
boolean isUser = false;
boolean isAdmin = false;
boolean isClient = false;
boolean hasUserRights = false;
boolean hasClientRights = false;
boolean hasAdminRights = false;
if
(userRole.equals(getProject().getProperty("user.user.rolename")))
isUser = true;
if (userRole.equals(getProject().getProperty("user.admin.rolename")))
isAdmin = true;
if (userRole.equals(getProject().getProperty("user.client.rolename")))
isClient = true;
if (isUser || isAdmin || isClient)
hasUserRights = true;
if (isAdmin || isClient)
hasClientRights = true;
if (isAdmin)
hasAdminRights = true;
com.canoo.webtest.extension.groovy.GroovyStep st;
/*
getProject().log("-->BEFORE:", Project.MSG_ERR);
StorePropertyStep sp = new StorePropertyStep();
sp.setContext(getContext());
sp.setContainer(getContainer());
sp.setProject(getProject());
sp.setLocation(getLocation());
sp.setRuntimeConfigurableWrapper(getRuntimeConfigurableWrapper());
sp.setDescription("set isUserProperty");
//sp.setWebtestProperty("userRole", "userRole",
Step.PROPERTY_TYPE_DYNAMIC);
sp.setName("userRole");
sp.setProperty("userRole2");
sp.setValue(Boolean.toString(isUser));
sp.doExecute();
//sp.setWebtestProperty("userRole", "userRole");
//sp.execute();
getProject().log("<--AFTER", Project.MSG_ERR);
getProject().setProperty("isUser",
Boolean.toString(isUser));
getProject().setProperty("isAdmin", Boolean.toString(isAdmin));
getProject().setProperty("isClient", Boolean.toString(isClient));
getProject().setProperty("hasUserRights",
Boolean.toString(hasUserRights));
getProject().setProperty("hasAdminRights",
Boolean.toString(hasAdminRights));
getProject().setProperty("hasClientRights",
Boolean.toString(hasClientRights));
*/
// getProject().log("hasAdminRights
:"+getWebtestProperty("hasAdminRights"));
// getProject().log("con class :"+con.getClass(),Project.MSG_WARN);
// step.dynamicProperties.image_alt
//getContext();
//super.expandProperties();
//setDynamicProperty();
//expandDynamicProperties("isUser");
//setWebtestProperty("isUser", Boolean.toString(isUser),
Step.PROPERTY_TYPE_DYNAMIC);
//getContext().getWebtest().setDynamicProperty(name, value);
//setWebtestProperty("isUser", Boolean.toString(isUser),
Step.PROPERTY_TYPE_DYNAMIC);
getProject().log("isUser(I): "+Boolean.toString(isUser),
Project.MSG_ERR);
getProject().log("isUser(E):
"+getProject().getProperty("isUser").toString(), Project.MSG_ERR);
/*
for (Object o : getProject().getProperties().keySet()) {
getProject().log("Key: " + o.toString(), Project.MSG_WARN);
}*/
/*
for(java.util.Iterator it =
getProject().getProperties().entrySet().iterator(); it.hasNext();){
Map.Entry e = (Map.Entry) it.next();
getProject().log(e.getKey() +"::"+ e.getValue(), Project.MSG_WARN);
};*/
}
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
the result is
1)
[webtest] INFO (com.canoo.webtest.ant.WebtestTask) - Canoo Webtest: R_1217.
[config] INFO (com.canoo.webtest.engine.Configuration) - Surfing with
browser Mozilla/4.0 (compatible; MSIE 6.0b; Windows 98)
[null] INFO (com.canoo.webtest.steps.Step) - >>>> Start Step: null
"<unknown>" (1/1)
userRole: USUARIO
[mytask] 2006-08-24 15:34:53,687 [main ERROR Step ]: Cannot handle unexpected
exception in step CommonTasks at
C:\projetos\celplay_pettoy\workspace\website\webtest\testes\justATest.webtest.xml:17:
with (stepType="mytask")
[mytask] java.lang.NullPointerException
[mytask] at
com.canoo.webtest.steps.Step.getDefaultPropertyType(Step.java:402)
[mytask] at com.canoo.webtest.steps.Step.getWebtestProperty(Step.java:462)
[mytask] at com.canoo.webtest.steps.Step.getWebtestProperty(Step.java:451)
[mytask] at javaTestSupport.CommonTasks.doExecute(CommonTasks.java:78)
[mytask] at com.canoo.webtest.steps.Step.execute(Step.java:135)
[mytask] at org.apache.tools.ant.Task.perform(Task.java:364)
[mytask] at
com.canoo.webtest.extension.AntWrapper.doExecute(AntWrapper.java:77)
[mytask] at com.canoo.webtest.steps.Step.execute(Step.java:135)
[mytask] at org.apache.tools.ant.Task.perform(Task.java:364)
[mytask] at com.canoo.webtest.engine.Engine.executeSteps(Engine.java:38)
[mytask] at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:105)
[mytask] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[mytask] at org.apache.tools.ant.Task.perform(Task.java:364)
[mytask] at
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:64)
[mytask] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[mytask] at org.apache.tools.ant.Task.perform(Task.java:364)
[mytask] at
org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:378)
[mytask] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[mytask] at org.apache.tools.ant.Task.perform(Task.java:364)
[mytask] at org.apache.tools.ant.Target.execute(Target.java:341)
[mytask] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[mytask] at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[mytask] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[mytask] at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
[mytask] at
org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
[mytask] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[mytask] at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
[mytask] at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
INFO (com.canoo.webtest.steps.Step) - Running with: Canoo Webtest: R_1217.
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.NullPointerException
ERROR (com.canoo.webtest.steps.Step) - Cannot handle unexpected exception in step AntWrapper at
with (description="<unknown>")
com.canoo.webtest.engine.StepExecutionException: Unexpected exception caught:
java.lang.NullPointerException, Step: CommonTasks at
C:\projetos\celplay_pettoy\workspace\website\webtest\testes\justATest.webtest.xml:17:
with (stepType="mytask")
at com.canoo.webtest.steps.Step.handleUnexpectedException(Step.java:607)
at com.canoo.webtest.steps.Step.execute(Step.java:138)
at org.apache.tools.ant.Task.perform(Task.java:364)
at com.canoo.webtest.extension.AntWrapper.doExecute(AntWrapper.java:77)
at com.canoo.webtest.steps.Step.execute(Step.java:135)
at org.apache.tools.ant.Task.perform(Task.java:364)
at com.canoo.webtest.engine.Engine.executeSteps(Engine.java:38)
at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:64)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:378)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at
org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
Caused by: java.lang.NullPointerException
at com.canoo.webtest.steps.Step.getDefaultPropertyType(Step.java:402)
at com.canoo.webtest.steps.Step.getWebtestProperty(Step.java:462)
at com.canoo.webtest.steps.Step.getWebtestProperty(Step.java:451)
at javaTestSupport.CommonTasks.doExecute(CommonTasks.java:78)
at com.canoo.webtest.steps.Step.execute(Step.java:135)
... 23 more
INFO (com.canoo.webtest.ant.WebtestTask) - Test report successfully created.
[echo] justATest
BUILD SUCCESSFUL
Total time: 11 seconds
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2)
Buildfile:
C:\projetos\celplay_pettoy\workspace\website\webtest\testes\justATest.webtest.xml
Trying to override old definition of task sleep
test3:
[webtest] INFO (com.canoo.webtest.ant.WebtestTask) - Canoo Webtest: R_1217.
[config] INFO (com.canoo.webtest.engine.Configuration) - Surfing with
browser Mozilla/4.0 (compatible; MSIE 6.0b; Windows 98)
[null] INFO (com.canoo.webtest.steps.Step) - >>>> Start Step: null
"<unknown>" (1/1)
userRole: USUARIO
[mytask] 2006-08-24 15:38:06,437 [main ERROR Step ]: Cannot handle unexpected
exception in step CommonTasks at
C:\projetos\celplay_pettoy\workspace\website\webtest\testes\justATest.webtest.xml:17:
with (stepType="mytask")
[mytask] java.lang.NullPointerException
[mytask] at com.canoo.webtest.steps.Step.setWebtestProperty(Step.java:426)
[mytask] at javaTestSupport.CommonTasks.doExecute(CommonTasks.java:86)
[mytask] at com.canoo.webtest.steps.Step.execute(Step.java:135)
[mytask] at org.apache.tools.ant.Task.perform(Task.java:364)
[mytask] at
com.canoo.webtest.extension.AntWrapper.doExecute(AntWrapper.java:77)
[mytask] at com.canoo.webtest.steps.Step.execute(Step.java:135)
[mytask] at org.apache.tools.ant.Task.perform(Task.java:364)
[mytask] at com.canoo.webtest.engine.Engine.executeSteps(Engine.java:38)
[mytask] at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:105)
[mytask] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[mytask] at org.apache.tools.ant.Task.perform(Task.java:364)
[mytask] at
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:64)
[mytask] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[mytask] at org.apache.tools.ant.Task.perform(Task.java:364)
[mytask] at
org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:378)
[mytask] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[mytask] at org.apache.tools.ant.Task.perform(Task.java:364)
[mytask] at org.apache.tools.ant.Target.execute(Target.java:341)
[mytask] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[mytask] at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[mytask] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[mytask] at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
[mytask] at
org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
[mytask] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[mytask] at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
[mytask] at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
INFO (com.canoo.webtest.steps.Step) - Running with: Canoo Webtest: R_1217.
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.NullPointerException
ERROR (com.canoo.webtest.steps.Step) - Cannot handle unexpected exception in step AntWrapper at
with (description="<unknown>")
com.canoo.webtest.engine.StepExecutionException: Unexpected exception caught:
java.lang.NullPointerException, Step: CommonTasks at
C:\projetos\celplay_pettoy\workspace\website\webtest\testes\justATest.webtest.xml:17:
with (stepType="mytask")
at com.canoo.webtest.steps.Step.handleUnexpectedException(Step.java:607)
at com.canoo.webtest.steps.Step.execute(Step.java:138)
at org.apache.tools.ant.Task.perform(Task.java:364)
at com.canoo.webtest.extension.AntWrapper.doExecute(AntWrapper.java:77)
at com.canoo.webtest.steps.Step.execute(Step.java:135)
at org.apache.tools.ant.Task.perform(Task.java:364)
at com.canoo.webtest.engine.Engine.executeSteps(Engine.java:38)
at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:64)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:378)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at
org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
Caused by: java.lang.NullPointerException
at com.canoo.webtest.steps.Step.setWebtestProperty(Step.java:426)
at javaTestSupport.CommonTasks.doExecute(CommonTasks.java:86)
at com.canoo.webtest.steps.Step.execute(Step.java:135)
... 23 more
INFO (com.canoo.webtest.ant.WebtestTask) - Test report successfully created.
[echo] justATest
BUILD SUCCESSFUL
Total time: 6 seconds
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3)
Buildfile:
C:\projetos\celplay_pettoy\workspace\website\webtest\testes\justATest.webtest.xml
Trying to override old definition of task sleep
test3:
[webtest] INFO (com.canoo.webtest.ant.WebtestTask) - Canoo Webtest: R_1217.
[config] INFO (com.canoo.webtest.engine.Configuration) - Surfing with
browser Mozilla/4.0 (compatible; MSIE 6.0b; Windows 98)
[null] INFO (com.canoo.webtest.steps.Step) - >>>> Start Step: null
"<unknown>" (1/1)
userRole: USUARIO
-->BEFORE:
[mytask] 2006-08-24 15:46:20,656 [main ERROR Step ]: Cannot handle unexpected
exception in step CommonTasks at
C:\projetos\celplay_pettoy\workspace\website\webtest\testes\justATest.webtest.xml:17:
with (stepType="mytask")
[mytask] java.lang.NullPointerException
[mytask] at
com.canoo.webtest.steps.Step.getDefaultPropertyType(Step.java:402)
[mytask] at com.canoo.webtest.steps.Step.setWebtestProperty(Step.java:422)
[mytask] at
com.canoo.webtest.steps.store.StorePropertyStep.doExecute(StorePropertyStep.java:28)
[mytask] at javaTestSupport.CommonTasks.doExecute(CommonTasks.java:66)
[mytask] at com.canoo.webtest.steps.Step.execute(Step.java:135)
[mytask] at org.apache.tools.ant.Task.perform(Task.java:364)
[mytask] at
com.canoo.webtest.extension.AntWrapper.doExecute(AntWrapper.java:77)
[mytask] at com.canoo.webtest.steps.Step.execute(Step.java:135)
[mytask] at org.apache.tools.ant.Task.perform(Task.java:364)
[mytask] at com.canoo.webtest.engine.Engine.executeSteps(Engine.java:38)
[mytask] at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:105)
[mytask] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[mytask] at org.apache.tools.ant.Task.perform(Task.java:364)
[mytask] at
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:64)
[mytask] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[mytask] at org.apache.tools.ant.Task.perform(Task.java:364)
[mytask] at
org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:378)
[mytask] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[mytask] at org.apache.tools.ant.Task.perform(Task.java:364)
[mytask] at org.apache.tools.ant.Target.execute(Target.java:341)
[mytask] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[mytask] at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[mytask] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[mytask] at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
[mytask] at
org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
[mytask] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[mytask] at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
[mytask] at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
INFO (com.canoo.webtest.steps.Step) - Running with: Canoo Webtest: R_1217.
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.NullPointerException
ERROR (com.canoo.webtest.steps.Step) - Cannot handle unexpected exception in step AntWrapper at
with (description="<unknown>")
com.canoo.webtest.engine.StepExecutionException: Unexpected exception caught:
java.lang.NullPointerException, Step: CommonTasks at
C:\projetos\celplay_pettoy\workspace\website\webtest\testes\justATest.webtest.xml:17:
with (stepType="mytask")
at com.canoo.webtest.steps.Step.handleUnexpectedException(Step.java:607)
at com.canoo.webtest.steps.Step.execute(Step.java:138)
at org.apache.tools.ant.Task.perform(Task.java:364)
at com.canoo.webtest.extension.AntWrapper.doExecute(AntWrapper.java:77)
at com.canoo.webtest.steps.Step.execute(Step.java:135)
at org.apache.tools.ant.Task.perform(Task.java:364)
at com.canoo.webtest.engine.Engine.executeSteps(Engine.java:38)
at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:64)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:378)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at
org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
Caused by: java.lang.NullPointerException
at com.canoo.webtest.steps.Step.getDefaultPropertyType(Step.java:402)
at com.canoo.webtest.steps.Step.setWebtestProperty(Step.java:422)
at
com.canoo.webtest.steps.store.StorePropertyStep.doExecute(StorePropertyStep.java:28)
at javaTestSupport.CommonTasks.doExecute(CommonTasks.java:66)
at com.canoo.webtest.steps.Step.execute(Step.java:135)
... 23 more
INFO (com.canoo.webtest.ant.WebtestTask) - Test report successfully created.
[echo] justATest
BUILD SUCCESSFUL
Total time: 9 seconds
Marc Guillemot wrote:
Hi Stefan,
1) the stack of the root exception should appear in the log. It is more
helpfull. Otherwise, try with the debugger.
2) same thing, provided information is not enough
3 & 4) sorry, I've never used these steps, perhaps can Paul answer your
question.
Marc.
PS: what about using the latest build, it would be easier for us to look at a
particular line of the source
Stefan Kuhn wrote:
Concerning webtest.version::Canoo Webtest: R_1217.
I have several problems with Canoo Webtest, they could be split in these points:
1. Access dynamic properties in an own java class
2. Execute webtest steps in a java class
3. Access an email (via the filters)
4. Proper way to wait for a specific email
1)
The declarative approach of ANT (and webtest) seems inappropriate sometimes.
The webtest documentation suggests to use Groovy in this case, but because of
the good Eclipse support and meaningful error msgs I choose to use Java for
more complex situations.
My first problem is that I can't access webtests dynamic properties in my Java
class. The ANT side declaration looks like this :
<taskdef name="mytask" classname="javaTestSupport.CommonTasks"
classpathref="classpath"/>
<webtest (...)">
<config (...)/>
<steps>
<mytask userRole="test" />
</steps>
</webtest>
My Java-Class:
public class CommonTasks extends com.canoo.webtest.steps.Step{
public void doExecute() throws BuildException{
setWebtestProperty("isUser", Boolean.toString(isUser),
Step.PROPERTY_TYPE_DYNAMIC);
}
}
leads to:
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.NullPointerException
ERROR (com.canoo.webtest.steps.Step) - Cannot handle unexpected exception in step AntWrapper at
with (description="<unknown>")
com.canoo.webtest.engine.StepExecutionException: Unexpected exception caught:
java.lang.NullPointerException, Step: CommonTasks at C:\(...)\justATest.webtest.xml:17:
with (stepType="mytask")
at com.canoo.webtest.steps.Step.handleUnexpectedException(Step.java:607)
at com.canoo.webtest.steps.Step.execute(Step.java:138)
at org.apache.tools.ant.Task.perform(Task.java:364)
at com.canoo.webtest.extension.AntWrapper.doExecute(AntWrapper.java:77)
at com.canoo.webtest.steps.Step.execute(Step.java:135)
My first thought Just to use ant properties (because they are not immutable in
a java-class) doesn't work neither, because webtest doesn't seems to expand the
ant properties during a webtest. Starting a new webtest with another session
is not useful.
2)
My workaround now was just to execute StoreProperty inside Java.
So I created a StoreProperty Step and tried to execute it as follows:
StorePropertyStep sp = new StorePropertyStep();
sp.setContext(getContext());
sp.setContainer(getContainer());
sp.setProject(getProject());
sp.setLocation(getLocation());
sp.setRuntimeConfigurableWrapper(getRuntimeConfigurableWrapper());
sp.setDescription("set isUserProperty");
sp.setWebtestProperty("userRole", "userRole", "dynamic");
/* Other options I played around with
sp.setName("userRole");
sp.setProperty("userRole2");
sp.setValue(Boolean.toString(isUser));
sp.doExecute();
sp.setWebtestProperty("userRole", "userRole");
sp.execute();
*/
all result in this kind of exception:
ERROR (com.canoo.webtest.steps.Step) - Cannot handle unexpected exception in step AntWrapper at
with (description="<unknown>")
com.canoo.webtest.engine.StepExecutionException: Unexpected exception caught:
java.lang.NullPointerException, Step: CommonTasks at C:\(...)\justATest.webtest.xml:17:
with (stepType="mytask")
at com.canoo.webtest.steps.Step.handleUnexpectedException(Step.java:607)
at com.canoo.webtest.steps.Step.execute(Step.java:138)
at org.apache.tools.ant.Task.perform(Task.java:364)
at com.canoo.webtest.extension.AntWrapper.doExecute(AntWrapper.java:77)
at com.canoo.webtest.steps.Step.execute(Step.java:135)
(...)
Caused by: java.lang.NullPointerException
at com.canoo.webtest.steps.Step.setWebtestProperty(Step.java:426)
at javaTestSupport.CommonTasks.doExecute(CommonTasks.java:61)
at com.canoo.webtest.steps.Step.execute(Step.java:135)
==> How to set/get dynamic canoo/webtest properties in a java class?
3)
I switched to testing emails and after some hours I stuck in problems again.
I want to access the content of a plain email. Therefore I want to SAVE the
email once. Whenever I try to do this, an exception is thrown
Following code is working:
<emailSetConfig server="@{eMail.mailServer}" type="@{eMail.serverType}"
password="@{eMail.password}" username="@{eMail.userName}" delay="@{eMail.serverDelay}" />
<sleep seconds="@{emailReceiveTime}"/>
<emailStoreMessageId from="@{eMail.petToyServerEMailAdress}"
to="@{eMail.UserEmailAddress}" property="confirmEMail.id" propertyType="dynamic"
subject="@{eMail.registerdNewUserSuccessfully.Header}" />
<emailMessageContentFilter description="MessageContent of confirmation email"
contentType="simple" messageId="#{confirmEMail.id}" />
I verified that the code is working properly by adding <verifyText
text="xxxx"/> with good/bad values.
If I add to emailMessageContentFilter save="xxx" or if I change in my <config>
saveresponse="true" the following exception occurs:
C:\\webtest\commonTasks.webLib.xml:258: The following error occurred while
executing this line:
C:\\website\build.xml:310: org.dbunit.dataset.NoSuchTableException: rotina
ERROR (com.canoo.webtest.steps.Step) - Cannot handle unexpected exception in step AntWrapper at
with (description="<unknown>")
C:\\website\webtest\testes\createNewUser.webtest.xml:108: The following error
occurred while executing this line:
C:\\website\webtest\commonTasks.webLib.xml:258: The following error occurred
while executing this line:
C:\\website\build.xml:310: org.dbunit.dataset.NoSuchTableException: rotina
at
org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:539)
at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:380)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:64)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
4)
Is there a better way than try to guess the time until a specific email
arrives? My code right now looks like this and is not very useful.
<emailSetConfig .../>
<sleep seconds="@{emailReceiveTime}"/>
<emailStoreMessageCount ...
Thanks /MfG
Stefan
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest