I am trying to run a test with JUnit and Mockito against a spring REST webservice I am building. I came across a bug when trying to run the JUnit test and can't find any information on the problem. The stacktrace is listing the error line as the .andDo(print())
though I got that line directly from a spring.io tutorial http://spring.io/guides/tutorials/rest/3/
Test class code:
public class TestSuite {
MockMvc mockMvc;
@Mock
RestController controller;
@Before
public void setup(){
MockitoAnnotations.initMocks(this);
this.mockMvc = standaloneSetup(controller)
.setMessageConverters(new MappingJackson2HttpMessageConverter()).build();
}
@Test
public void testREST() throws Exception {
when(controller.getThing(any(Integer.class))).thenReturn(TestFixture.getREST(1));
this.mockMvc.perform(get("/{number}", String.valueOf(number))
.accept(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isNotFound());
}}
Stacktrace:
java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.isAsyncStarted()Z
at org.springframework.test.web.servlet.result.PrintingResultHandler.printAsyncResult(PrintingResultHandler.java:131)
at org.springframework.test.web.servlet.result.PrintingResultHandler.handle(PrintingResultHandler.java:80)
at org.springframework.test.web.servlet.MockMvc$1.andDo(MockMvc.java:155)
at org.company.test.TestSuite.testREST(TestSuite.java:53)`