I have two issues with testing a Grails controller.
I have a controller contains some methods like this one:
def save() {
def x =session.SPRING_SECURITY_CONTEXT.authentication.principal.id
def user = User.get(x)
}
and to test this I wrote the test method like this:
def testSave () {
myCont.save()
}
And when I run this, I see a WARN from the database while getting the user which is:
[main] WARN core.DatastoreUtils - Cannot unbind session, there's no SessionHolder registered
So, my questions are:
- How to inject or init the session while testing so I can get this user from session?
- How can I remove the WARN message?