package thymeleafexamples.layouts.signup; import org.junit.Test; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; import thymeleafexamples.layouts.config.WebAppConfigurationAware; public class SignupControllerTest extends WebAppConfigurationAware { @Test public void displaysSignupForm() throws Exception { mockMvc.perform(get("/signup").header("X-Requested-With", "")) .andExpect(model().attributeExists("signupForm")) .andExpect(view().name("signup/signup")) .andExpect(content().string( allOf( containsString("<title>Signup</title>"), containsString("<legend>Please Sign Up</legend>") )) ); } }