content: package alexp.blog;
  
  import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener;
  import org.junit.Before;
  import org.junit.runner.RunWith;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.security.web.FilterChainProxy;
  import org.springframework.test.context.ActiveProfiles;
  import org.springframework.test.context.ContextConfiguration;
  import org.springframework.test.context.TestExecutionListeners;
  import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
  import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
  import org.springframework.test.context.web.WebAppConfiguration;
  import org.springframework.test.web.servlet.MockMvc;
  import org.springframework.web.context.WebApplicationContext;
  import javax.transaction.Transactional;
  
  import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
  
  @RunWith(SpringJUnit4ClassRunner.class)
  @WebAppConfiguration
  @ContextConfiguration({ "file:src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml",
          "classpath:/database.xml",
          "file:src/main/webapp/WEB-INF/spring-security.xml" })
  @ActiveProfiles("test")
  @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
          DirtiesContextTestExecutionListener.class,
          TransactionDbUnitTestExecutionListener.class})
  @Transactional
  public abstract class AbstractIntegrationTest {
  
      @SuppressWarnings("SpringJavaAutowiringInspection")
      @Autowired
      protected FilterChainProxy springSecurityFilterChain;
  
      protected MockMvc mockMvc;
  
      @SuppressWarnings("SpringJavaAutowiringInspection")
      @Autowired
      protected WebApplicationContext wac;
  
      @Before
      public void setup() {
          this.mockMvc = webAppContextSetup(this.wac).addFilter(springSecurityFilterChain).build();
  
          setupTest();
      }
  
      // child classes should override this instead of using @Before (order of @Before is not guaranteed if names are not unique)
      protected void setupTest()
      {
  
      }
  }
  