BAEL-3827 Add CSS and JS to Thymeleaf (#8985)

* 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
This commit is contained in:
Amy DeGregorio
2020-03-31 12:02:54 -04:00
committed by GitHub
parent 8c69054bec
commit 1e052c5a72
11 changed files with 221 additions and 0 deletions
@@ -0,0 +1,13 @@
package com.baeldung.thymeleaf;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
public class ApplicationIntegrationTest {
@Test
public void contextLoads() {
}
}
@@ -0,0 +1,41 @@
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")));
}
}