* BAEL-3827 Add CSS and JS to Thymeleaf * BAEL-3827 Add integration tests * BAEL-3827 Add new spring-thymeleaf-3 module to the parent pom.xml * BAEL-3827 Add new spring-thymeleaf-3 module to the parent pom.xml in both places
42 lines
1.7 KiB
Java
42 lines
1.7 KiB
Java
package com.baeldung.thymeleaf.cssandjs;
|
|
|
|
import static org.hamcrest.CoreMatchers.containsString;
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
|
|
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.test.context.ContextConfiguration;
|
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
import org.springframework.test.context.web.WebAppConfiguration;
|
|
import org.springframework.test.web.servlet.MockMvc;
|
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
|
import org.springframework.web.context.WebApplicationContext;
|
|
|
|
@RunWith(SpringJUnit4ClassRunner.class)
|
|
@WebAppConfiguration
|
|
@ContextConfiguration(classes = CssAndJsApplication.class)
|
|
public class CssAndJsControllerIntegrationTest {
|
|
@Autowired
|
|
private WebApplicationContext context;
|
|
|
|
private MockMvc mockMvc;
|
|
|
|
@Before
|
|
public void setup() {
|
|
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
|
}
|
|
|
|
@Test
|
|
public void whenCalledGetStyledPage_thenReturnContent() throws Exception {
|
|
this.mockMvc.perform(MockMvcRequestBuilders.get("/styled-page"))
|
|
.andExpect(status().isOk())
|
|
.andExpect(view().name("cssandjs/styledPage"))
|
|
.andExpect(content().string(containsString("Carefully Styled Heading")));
|
|
}
|
|
}
|