@Test void getMessage() throws Exception { MockHttpSession session1 = new MockHttpSession(); MockHttpSession session2 = new MockHttpSession(); MockHttpServletResponse response1 = mockMvc.perform(get("/session/message").session(session1)) .andReturn().getResponse(); MockHttpServletResponse response2 = mockMvc.perform(get("/session/message").session(session1)) .andReturn().getResponse(); assertThat(response1.equals(to(response2))); MockHttpServletResponse response3 = mockMvc.perform(get("/session/message").session(session2)) .andReturn().getResponse(); assertThat(response3).isNotEqualTo(response1); assertThat(response3).isNotEqualTo(response2); }
@GetMapping("/session/message") public String getMessage() { return "Hello from SessionScopeController"; }
SessionScopeController { @GetMapping("/session/message") public String getMessage() { return "Hello from SessionScopeController"; } }
SessionScopeController { @GetMapping("/session/message") public String getMessage() { return "Hello from SessionScopeController"; }  }
SessionScopeController { @GetMapping("/session/message") public String getMessage() { return "Hello from SessionScopeController"; }  @GetMapping("/session/message") String getMessage(); }
SessionScopeController { @GetMapping("/session/message") public String getMessage() { return "Hello from SessionScopeController"; }  @GetMapping("/session/message") String getMessage();  }