0

Is the Spring Boot annotation @WebMvcTest only intended for sliced RestController tests or should SOAP Endpoints be testable with it too?

When I setup my test and run it, I only get a 404 response as if the endpoint wasn't there so I assume it isn't part of the WebMvc slice.

@RunWith(SpringRunner.class)
@WebMvcTest(value = IdServerPortTypeV10.class)
@Import({SecurityConfig.class, ModelMapperConfig.class, WebServiceConfig.class, ControllerTestBeans.class})
public class AccountEndpointTests {
    @Autowired
    IdServerPortTypeV10 soapEndpoint;

    ...

    @Before
    public void setup() {
        mockMvc = MockMvcBuilders
            .webAppContextSetup(wac)
            .apply(springSecurity())
            .build();
    }

    @Test
    @WithMockUser(roles = VALID_ROLE)
    public void getAccountTest_Success() throws Exception {

        mockMvc.perform(
            post("/soap/idserver/1.0")
                .accept(MediaType.TEXT_XML_VALUE)
                .headers(SoapTestUtility.getHeader(SERVICE.getNamespaceURI(), "getAccount"))
                .content(SoapTestUtility.getAccountXml())
        ).andDo(print())
            .andExpect(status().isOk());
    }
}

The endpoint is enabled in WebServiceConfig.class in which @EnableWs is set.

user3105453
  • 1,881
  • 5
  • 32
  • 55

1 Answers1

0

@WebMvcTest is, as the name implies, only for Spring MVC related tests.

Spring's SOAP support is from the Spring Web Services project which has its own integration testing support.

Sam Brannen
  • 29,611
  • 5
  • 104
  • 136