Spring Boot 1.4.2 @WebMvcTest returns status 404
<p>I am using Spring Boot 1.4.2 and Jersey (jax-rs) to create a REST controller. I have followed the documentation on how to test REST Controllers (<a href="https://spring.io/blog/2016/04/15/testing-improvements-in-spring-boot-1-4" rel="noreferrer">Testing the Spring MVC slice</a>). But my test returns 404 and I can't seem to find out why. The controller here is simplified but the problem remains.</p>

<p>My question is how to get the 200 status when running the test?</p>

<p><strong>HealthController.java</strong></p>

<pre><code>@Controller
@Path("/health")
public class HealthController {
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Health health() {
        return Health.up().build();
    }
}
</code></pre>

<p><strong>Running the server and doing a query gives me this</strong></p>

<pre><code>%&gt; curl -i http://localhost:8080/health
HTTP/1.1 200 
X-Application-Context: application
Content-Type: application/json
Content-Length: 21
Date: Sun, 27 Nov 2016 15:22:30 GMT

{
  "status" : "UP"
}% 
</code></pre>

<p><strong>HealthControllerTest.java</strong></p>

<pre><code>@RunWith(SpringRunner.class)
@WebMvcTest(HealthController.class)
public class HealthControllerTest {

    @Autowired
    private MockMvc mockMvc;

    @Test
    public void health() throws Exception {
        mockMvc.perform(get("/health").accept(MediaType.APPLICATION_JSON))
                .andExpect(status().isOk()); // 200 expected
    }
}
</code></pre>

<p><strong>This is what I get when running test</strong></p>

<pre><code>  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.4.2.RELEASE)

2016-11-27 16:22:08.254  INFO 9029 --- [           main] no.avec.controller.HealthControllerTest  : Starting HealthControllerTest on ducati.local with PID 9029 (started by avec in /Users/avec/Projects/RESTdemo)
2016-11-27 16:22:08.257 DEBUG 9029 --- [           main] no.avec.controller.HealthControllerTest  : Running with Spring Boot v1.4.2.RELEASE, Spring v4.3.4.RELEASE
2016-11-27 16:22:08.257  INFO 9029 --- [           main] no.avec.controller.HealthControllerTest  : No active profile set, falling back to default profiles: default
2016-11-27 16:22:09.294  INFO 9029 --- [           main] no.avec.controller.HealthControllerTest  : Started HealthControllerTest in 1.421 seconds (JVM running for 2.132)

MockHttpServletRequest:
      HTTP Method = GET
      Request URI = /health
       Parameters = {}
          Headers = {Accept=[application/json]}

Handler:
             Type = org.springframework.web.servlet.resource.ResourceHttpRequestHandler

Async:
    Async started = false
     Async result = null

Resolved Exception:
             Type = null

ModelAndView:
        View name = null
             View = null
            Model = null

FlashMap:
       Attributes = null

MockHttpServletResponse:
           Status = 404
    Error message = null
          Headers = {}
     Content type = null
             Body = 
    Forwarded URL = null
   Redirected URL = null
          Cookies = []

java.lang.AssertionError: Status 
Expected :200
Actual   :404
</code></pre>