title: Spring MVC integration tests with Spring Security
body: <p>I'm trying to test my login page using mvc-test.
  I was working pretty good before I added spring security.</p>
  
  <p>My code is:</p>
  
  <pre><code> mockMvc.perform(
       post("j_spring_security_check")
                      .param(LOGIN_FORM_USERNAME_FIELD, testUsernameValue)
                      .param(LOGIN_FORM_PASSWORD_FIELD, testPasswordValue))
                  .andDo(print())
                  .andExpect(status().isOk())
                  .andExpect(model().attribute(LOGIN_PAGE_STATUS_VALUE, LOGIN_PAGE_STATUS_FALSE_INDICATOR));
  </code></pre>
  
  <p>Test class has correct annotations added:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @WebAppConfiguration
  @ContextConfiguration(locations = {"classpath:security-context.xml", "classpath:applicationContext.xml", "classpath:test-contexts/test-context.xml" })
  </code></pre>
  
  <p>My filter is defined (in web.xml):</p>
  
  <pre><code>&lt;filter&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
  &lt;/filter&gt;
  
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>When I try to add web.xml in @ContextConfiguration it fails, when I remove it I'm getting an Exception: </p>
  
  <pre><code>java.lang.AssertionError: Status expected:&lt;200&gt; but was:&lt;405&gt;
  </code></pre>
  
  <p>Is there any way to add DelegatingProxyFilter to test context with configuration defined in my security-context.xml to make it works? I tried few tutorials with injecting FilterProxyChain, but it is not working in my case.</p>
  
  <p>Can someone help me with that?
  Thanks in advance</p>