Bael 6556 3 (#4382)

* Added parent module on poms that have no parent defined

* Removed dependency reduced pom from undertow module

* [BAEL-6556] - Next set of renames of testcases

* [BAEL-6556] - Next set of renames of testcases

* [BAEL-6556] - Next set of renames of testcases

* [BAEL-6556] - Next set of renames of testcases
This commit is contained in:
Amit Pandey
2018-06-01 16:42:51 +05:30
committed by Grzegorz Piwowarek
parent cfa5f07c96
commit 7206e64bef
150 changed files with 187 additions and 182 deletions

View File

@@ -0,0 +1,90 @@
package com.baeldung.thymeleaf.controller;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.RequestPostProcessor;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import com.baeldung.thymeleaf.config.InitSecurity;
import com.baeldung.thymeleaf.config.WebApp;
import com.baeldung.thymeleaf.config.WebMVCConfig;
import com.baeldung.thymeleaf.config.WebMVCSecurity;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.user;
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.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import javax.servlet.Filter;
import static org.hamcrest.Matchers.containsString;
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(classes = { WebApp.class, WebMVCConfig.class, WebMVCSecurity.class, InitSecurity.class })
public class FragmentsIntegrationTest {
@Autowired
WebApplicationContext wac;
@Autowired
MockHttpSession session;
private MockMvc mockMvc;
@Autowired
private Filter springSecurityFilterChain;
private RequestPostProcessor testUser() {
return user("user1").password("user1Pass").roles("USER");
}
@Before
public void setup() {
mockMvc = MockMvcBuilders.webAppContextSetup(wac).addFilters(springSecurityFilterChain).build();
}
@Test
public void whenAccessingFragmentsRoute_thenViewHasExpectedContent() throws Exception {
this.mockMvc
.perform(get("/fragments").with(testUser()))
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().string(containsString("<title>Thymeleaf Fragments: home</title>")));
}
@Test
public void whenAccessingParamsRoute_thenViewHasExpectedContent() throws Exception {
this.mockMvc
.perform(get("/params").with(testUser()))
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().string(containsString("<span>Name</span>")));
}
@Test
public void whenAccessingMarkupRoute_thenViewHasExpectedContent() throws Exception {
this.mockMvc
.perform(get("/markup").with(testUser()))
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().string(containsString("<div class=\"another\">This is another sidebar</div>")));
}
@Test
public void whenAccessingOtherRoute_thenViewHasExpectedContent() throws Exception {
this.mockMvc
.perform(get("/other").with(testUser()))
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().string(containsString("<td>John Smith</td>")));
}
}