Мы обновились до spring-webmvc 5.2.3.RELEASE
.
Это приводит к сбою JUnit.
Я думаю, что проблема связана с методом .build()
- его невозможно найти.
Код:
@RunWith(MockitoJUnitRunner.class)
public class CommunicationDeliveryControllerTest {
@InjectMocks
CommunicationDeliveryController controller = new CommunicationDeliveryController();
@Mock
private RequestHandler requestHandler;
@Mock
private HttpServletRequest httpServletRequest;
private MockMvc mockMvc;
private Gson gson = new Gson();
private CommunicationDeliveryController spiedController;
@Before
public void setup() {
spiedController = spy(controller);
mockMvc = standaloneSetup(spiedController).build();
}
@Test
public void initiateBatchRunTest() throws Exception{
MvcResult result = mockMvc.perform(post("/api/BatchRun").contentType(MediaType.APPLICATION_JSON_VALUE).content(gson.toJson(BulkCommunicationRequestData.getBulkEmailRequestForPositive()))).andReturn();
assertEquals(HttpStatus.OK.value(), result.getResponse().getStatus());
}
@Test
public void deliverCommunicationTest() throws Exception{
MvcResult result = mockMvc.perform(post("/api/deliverCommunication").contentType(MediaType.APPLICATION_JSON_VALUE).content(gson.toJson(BulkCommunicationRequestData.populateAllEmailDetail()))).andReturn();
assertEquals(HttpStatus.OK.value(), result.getResponse().getStatus());
}
}
Ошибка:
java.lang.NoSuchMethodError: org.springframework.test.web.servlet.setup.StandaloneMockMvcBuilder$StandaloneConfiguration.getInterceptors()[Ljava/lang/Object;
at company.custcomm.service.communicationdelivery.controllers.CommunicationDeliveryControllerTest.setup(CommunicationDeliveryControllerTest.java:45)
Есть ли проблемы совместимости между нашими версиями spring-web mvc, mockito и JUnit?
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.2.3.RELEASE</version>
</dependency>