Weird Spring Mock error
Posted & filed under Spring.
I’ve been looking into a weird Spring testing error from this code:
MockMultipartHttpServletRequest req = new MockMultipartHttpServletRequest();
req.addFile(new MockMultipartFile("file","test1.html","text/html", fi));
req.setContentType("multipart/form-data");
req.setMethod("POST");
req.setRequestURI("/en/uploadaction");
handlerAdapter.handle(req, response, controller);
which threw this exception:
java.lang.AbstractMethodError: org.springframework.mock.web MockMultipartHttpServletRequest.getFiles(Ljava/lang/String;)Ljava/util/List;
Turns out I was using spring-mock-2.0.8 when in fact I should have been using the new Spring test dependency:
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>3.0.5-RELEASE</version> <scope>test</scope> </dependency>