Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Example of a @AutoConfigureMockMvc test. This test gives the unit test access to a mock
- * Spring Application context, but does not actually start the server.
- *
- * The entire application context is mocked in this case (@Controller, @Service, etc...). See
- * the @WebMvcTest for an example.
- */
- package com.healthpartners.foundation.sso;
- import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
- import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
- import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrlPattern;
- import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
- import org.springframework.test.context.ActiveProfiles;
- import org.springframework.test.context.junit4.SpringRunner;
- import org.springframework.test.web.servlet.MockMvc;
- @RunWith(SpringRunner.class)
- @AutoConfigureMockMvc
- @ActiveProfiles("test")
- public class ExampleAutoConfigureMockMvcTest {
- @Autowired
- private MockMvc mockMvc;
- @Test
- public void shouldRedirect() throws Exception {
- this.mockMvc.perform(get("/")).andDo(print()).andExpect(status().is3xxRedirection())
- .andExpect(redirectedUrlPattern("/index.html**"));
- }
- }
Add Comment
Please, Sign In to add comment