[BAEL-9552] - Create spring-security-modules folder
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
package com.baeldung.springsecuritythymeleaf;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class SpringSecurityThymeleafApplicationIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
ViewController viewController;
|
||||
@Autowired
|
||||
WebApplicationContext wac;
|
||||
|
||||
@Test
|
||||
public void whenConfigured_thenLoadsContext() {
|
||||
assertNotNull(viewController);
|
||||
assertNotNull(wac);
|
||||
}
|
||||
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.baeldung.springsecuritythymeleaf;
|
||||
|
||||
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.MockMvcResultMatchers.status;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebMvcTest
|
||||
public class ViewControllerIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
MockMvc mockMvc;
|
||||
|
||||
@Test
|
||||
public void givenUser_whenPerformingGet_thenReturnsIndex() throws Exception {
|
||||
mockMvc.perform(get("/index").with(user("user").password("password"))).andExpect(status().isOk()).andExpect(view().name("index"));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user