I banged my head against the wall for quite a while trying to figure this error out in my Groovy Junit tests:
Request processing failed; nested exception is java.lang.IllegalStateException: Last method called on mock already has a non-fixed count set.
I’m using Spring 4.0 with Spring Security 3.2.5 and thought maybe it was something to do with my test setup. It turns out to be pretty straightforward. I hadn’t wrapped my test in a play closure. So going from this:
def r = mockMvc.perform(get("/...")).andExpect(status().isOk()).andReturn()
to this:
play { def r = mockMvc.perform(get("/...")).andExpect(status().isOk()).andReturn() }
solved my problem.