Advertisement
pallinger

Untitled

Oct 2nd, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.78 KB | None | 0 0
  1. @IntegrationTest
  2. @RunWith(SpringJUnit4ClassRunner.class)
  3. @SpringApplicationConfiguration(classes = App.class)
  4. @WebAppConfiguration
  5. public class RestTest {
  6.  
  7.     @Autowired
  8.     private WebApplicationContext wac;
  9.  
  10.     @Autowired
  11.     private Filter springSecurityFilterChain;
  12.  
  13.     private MockMvc mockMvc;
  14.  
  15.     @Before
  16.     public void setUp() {
  17.         this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).
  18.                 addFilters(springSecurityFilterChain).build();
  19.         this.mapper = new ObjectMapper();
  20.     }
  21.  
  22.     @Test
  23.     public void testLogin() throws Exception {
  24.         MvcResult result;
  25.         MockHttpServletRequestBuilder req;
  26.  
  27.         result = mockMvc.perform(get("/login/csrf")).andExpect(status().is(200)).andReturn();
  28.         Cookie[] cookie = result.getResponse().getCookies();
  29.         System.out.println(cookie.length);
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement