aboutsummaryrefslogtreecommitdiff
path: root/juick-spring-www/src/test/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-12-20 10:30:53 +0300
committerGravatar Vitaly Takmazov2016-12-20 10:30:53 +0300
commite326e733a7b3e013011fce8ecf081a86a097cc15 (patch)
tree2014cf9aeccc483bdf497d0b6d69870ed3832b26 /juick-spring-www/src/test/java/com
parentfc9b35fbf7ce556b379d3396533962ef1a714888 (diff)
juick-spring-www: fix tests
Diffstat (limited to 'juick-spring-www/src/test/java/com')
-rw-r--r--juick-spring-www/src/test/java/com/juick/www/NotFoundPageTest.java30
1 files changed, 11 insertions, 19 deletions
diff --git a/juick-spring-www/src/test/java/com/juick/www/NotFoundPageTest.java b/juick-spring-www/src/test/java/com/juick/www/NotFoundPageTest.java
index 0b68fe70..c01194f4 100644
--- a/juick-spring-www/src/test/java/com/juick/www/NotFoundPageTest.java
+++ b/juick-spring-www/src/test/java/com/juick/www/NotFoundPageTest.java
@@ -6,7 +6,7 @@ import com.juick.www.configuration.WwwServletConfiguration;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.ContextHierarchy;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -15,6 +15,8 @@ import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
+import javax.inject.Inject;
+
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;
@@ -32,35 +34,25 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@ContextConfiguration(classes = {WwwServletConfiguration.class}),
})
public class NotFoundPageTest {
- @Autowired
+ @Inject
private WebApplicationContext wac;
private MockMvc mockMvc;
@Before
public void setup() {
- this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
+ this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac)
+ .apply(SecurityMockMvcConfigurers.springSecurity()).build();
}
@Test
- public void postNotFoundTest() throws Exception {
+ public void pageNotFoundTest() throws Exception {
mockMvc.perform(get("/-11"))
- .andExpect(status().isOk())
- .andExpect(view().name("postNotFound"));
+ .andExpect(status().is4xxClientError())
+ .andExpect(view().name("views/error"));
mockMvc.perform(get("/-1"))
- .andExpect(status().isOk())
- .andExpect(view().name("postNotFound"));
- }
-
- @Test
- public void userNotFoundTest() throws Exception {
- mockMvc.perform(get("/-0"))
- .andExpect(status().isOk())
- .andExpect(view().name("userNotFound"));
-
- mockMvc.perform(get("/00000000000000000000000000"))
- .andExpect(status().isOk())
- .andExpect(view().name("userNotFound"));
+ .andExpect(status().is4xxClientError())
+ .andExpect(view().name("views/error"));
}
}