How to mock HttpServletRequest in Spock

zeroFILL

New Member
We have a ServletFilter we want to unit tests with Spock and check calls to HttpServletRequest.The following code throws\[code\]java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/http/Cookie\[/code\]\[code\]def "some meaningless test"(){ given: HttpServletRequest servletRequest = Mock(HttpServletRequest) when: 1+1 then: true}\[/code\]The JavaEE 5 API (and thus the Servlet API) is on the classpath. The Spock version is 0.6-groovy-1.8.How would we do that right? It works with Mockito but we'd loose the Spock mocking awesomeness.Edit: We know about Grails and Spring built-in mocking capabilities for Servlet stuff, we'd just like to know if there's a way to do it with Spock mocking. Otherwise you'd have a mix of mocking setup techniques...
 
Top