package org.itevents;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
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.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;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;

@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(locations = {"classpath*:applicationContext.xml", "classpath*:mvc-dispatcher-servlet.xml"})
public class AppTests {
    @SuppressWarnings("SpringJavaAutowiringInspection")
    @Inject
    protected WebApplicationContext wac;
    private MockMvc mockMvc;

    @Before
    public void setup() {
        this.mockMvc = webAppContextSetup(this.wac).build();
    }

    @Test
    public void simple() throws Exception {
        mockMvc.perform(get("/"))
                .andExpect(status().isOk())
                .andExpect(view().name("login"));
    }
}

@@ -41,16 +41,41 @@
 Before;%0A
+import org.junit.Ignore;%0A
 import o
@@ -374,16 +374,83 @@
 ockMvc;%0A
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;%0A
 import o
@@ -529,24 +529,133 @@
 ct.Inject;%0A%0A
+import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity;%0A
 import stati
@@ -813,193 +813,9 @@
 ers.
-status;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;%0Aimport static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup
+*
 ;%0A%0A@
@@ -857,29 +857,8 @@
 ss)%0A
-@WebAppConfiguration%0A
 @Con
@@ -924,16 +924,24 @@
 xt.xml%22,
+%0A       
  %22classp
@@ -976,10 +976,65 @@
 xml%22
-%7D)
+, %22classpath*:spring-security.xml%22%7D)%0A@WebAppConfiguration
 %0Apub
@@ -1132,15 +1132,13 @@
   pr
-otec
+iva
 te
-d
  Web
@@ -1156,19 +1156,23 @@
 Context 
-wac
+context
 ;%0A    pr
@@ -1186,20 +1186,16 @@
 ockMvc m
-ockM
 vc;%0A%0A   
@@ -1229,24 +1229,26 @@
 tup() %7B%0A
+//
         
 this.moc
@@ -1243,18 +1243,9 @@
     
-this.mockM
+m
 vc =
@@ -1268,16 +1268,106 @@
 tup(
-this.wac
+context).build();%0A        mvc = MockMvcBuilders.webAppContextSetup(context).apply(springSecurity()
 ).bu
@@ -1443,20 +1443,16 @@
        m
-ockM
 vc.perfo
@@ -1495,71 +1495,379 @@
 ect(
-status().isOk())%0A                .andExpect(view().name(%22login%22
+view().name(%22index%22))%0A                .andExpect(status().isOk());%0A    %7D%0A%0A    @Ignore  //Ignore because of corrupting database table visit_log%0A    @Test%0A    public void testRedirect() throws Exception %7B%0A        mvc.perform(get(%22/events/1/register%22))%0A                .andExpect(redirectedUrl(%22http://www.java.com.ua%22))%0A                .andExpect(status().is3xxRedirection(
 ));%0A

add testRedirect