I am developing an application in play and in my selenium tests I use several tags for repetitive tasks. Two tags are:
app/views/tags/loginAs.html
*{ Tag for running selenium tests when being logged in }*
#{if !_keepData}
#{braindumpFixture delete:'all', load:'users.yml' /}
#{/if}
#{selenium}
... some selenium code to log into the application
#{/selenium}
app/views/tags/braindumpFixture.html
%{
if(_delete == 'all') {
play.test.Fixtures.deleteAll()
} else if(_delete) {
play.test.Fixtures.delete(_delete)
}
}%
%{
if(_load) {
play.test.Fixtures.load(_load)
}
// finally make sure the index is correctly updated.
new application.jobs.CompleteReindexJob().doJob();
}%
These work without a problem in Play 1.1. After switching to play 1.2.2, I get the following exception when running a selenium test that uses loginAs:
test/selenium/AddCard.test.html
*{ Tests adding a simple card }*
#{loginAs login:'foobar@foobar.com', password:'foobar' /}
#{selenium}
open('@{Application.index()}')
... more selenium stuff here
#{/selenium}
The exception being:
play.exceptions.TemplateExecutionException: Cannot get property 'data' on null object
at play.templates.BaseTemplate.throwException(BaseTemplate.java:84)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:252)
at play.templates.GroovyTemplate$ExecutableTemplate.invokeTag(GroovyTemplate.java:374)
at /test/selenium/AddCard.test.html.(line:3)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:229)
at play.templates.Template.render(Template.java:26)
at play.templates.GroovyTemplate.render(GroovyTemplate.java:184)
at controllers.TestRunner.run(TestRunner.java:107)
at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:543)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:499)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:475)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:470)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:158)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.NullPointerException: Cannot get property 'data' on null object
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:229)
... 12 more
When I remove the #{if !_keepData} around the call to braindumpFixture I get an EmptyStackException:
play.exceptions.TemplateExecutionException
at play.templates.BaseTemplate.throwException(BaseTemplate.java:84)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:252)
at play.templates.Template.render(Template.java:26)
at play.templates.GroovyTemplate.render(GroovyTemplate.java:184)
at controllers.TestRunner.run(TestRunner.java:107)
at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:543)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:499)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:475)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:470)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:158)
at Invocation.HTTP Request(Play!)
Caused by: java.util.EmptyStackException
at java.util.Stack.peek(Stack.java:85)
at java.util.Stack.pop(Stack.java:67)
at play.templates.TagContext.exitTag(TagContext.java:31)
at play.templates.GroovyTemplate$ExecutableTemplate.invokeTag(GroovyTemplate.java:380)
at /test/selenium/AddCard.test.html.(line:3)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:229)
... 9 more
I wonder if something fundamentally changed with tags in Play 1.2 and I just overlooked it in the documentation or if this might be a bug. Any ideas on solving this riddle are welcome.
I am not aware that anything should have changed to stop this from working, so would expect this is a bug.