title: How to test that Spring MVC configuration is present?
body: <p>I would like to have a test which would fail when a Spring MVC configuration is absent, and would pass when it's present. For instance, I have a following test to assure I have Spring Security configured (this test is based on a similar test residing in spring):</p>
  
  <pre><code>
  @RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration(classes = { SecurityConfiguration.class, JpaConfiguration.class })
  @WebAppConfiguration
  public class SecurityConfigurationTest {
  
      @Autowired
      private org.springframework.security.web.FilterChainProxy springSecurityFilterChain;
  
      @Autowired
      private AuthenticationManagerBuilder auth;
  
      @Test
      public void shouldLoadSecurityConfiguration() {}
  
      @Test
      public void shouldUseCustomUserDetailsService() {
          assertNotNull(auth.getDefaultUserDetailsService());
          assertTrue(auth.getDefaultUserDetailsService() instanceof UserDetailsServiceImpl);
      }
  
  }
  </code></pre>
  
  <p>Basically it tests just the presence of Spring Security configuration, which forces me to create such a config when adhering to TDD. I tried to create a similar test, based on <a href="http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/testing.html#spring-mvc-test-server" rel="nofollow">this Spring MVC test</a> :</p>
  
  <pre><code>
  @RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration(classes = {SecurityConfiguration.class, JpaConfiguration.class})
  @WebAppConfiguration
  public class WebConfigurationTest {
  
      @Autowired
      private WebApplicationContext wac;
  
      private MockMvc mockMvc;
  
      @Before
      public void setup() {
          this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
      }
  
      @Test
      public void shouldReturn404ForNonExistingPage() throws Exception {
          this.mockMvc.perform(get("/mandible-is-inorganic")).andExpect(status().isNotFound());
      }
  
  }
  </code></pre>
  
  <p>However, all that test required to pass was downloading spring-webmvc dependency. It managed to pass without my having extended a AbstractAnnotationConfigDispatcherServletInitializer and without @EnableWebMvc-annotated web configuration. What are my options ?</p>