title: Testing controllers in Spring?
body: <p>I want to write a functional test by calling some controllers.</p>
  
  <pre><code>        @Autowired
          private WebApplicationContext ctx;
  
          private MockMvc mockMvc;
          ....
  
          MvcResult mvcResult = mockMvc.perform(get("/perform/1")).andReturn();
          Map&lt;String, Object&gt; model = mvcResult.getModelAndView().getModel();
  
          //assert....
  
          MvcResult mvcResult = mockMvc.perform(get("/perform/2")).andReturn();
          Map&lt;String, Object&gt; model = mvcResult.getModelAndView().getModel();
  
          //assert....
  </code></pre>
  
  <p>After perform/1 is called a User model is stored in the session:</p>
  
  <pre><code> @Controller
   @SessionAttributes("user")
   public class CoreController {
  </code></pre>
  
  <p>I would like to call perform/2 immediate after perform/1 in the same test but it seems that user = null then.
  Is this normal behavior?</p>
  
  <p>How can I accomplish this? How can I write a functional test with Spring controllers?</p>