package org.nextprot.api.web.dbunit.base.mvc;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
import org.junit.Before;
import org.nextprot.api.commons.dbunit.AbstractUnitBaseTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.WebApplicationContext;
import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener;
/**
* Base class used to test mock controllers on top of dbunit test
* Nice article: http://coderphil.wordpress.com/2012/04/23/database-testing-using-dbunit-spring-and-annotations/
* @author dteixeira
*/
@TransactionConfiguration(defaultRollback = true)
@Transactional
@WebAppConfiguration
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
DirtiesContextTestExecutionListener.class,
TransactionDbUnitTestExecutionListener.class })
@ContextConfiguration("classpath:META-INF/spring/web-context.xml")
public abstract class MVCDBUnitBaseTest extends AbstractUnitBaseTest {
@Autowired
protected WebApplicationContext wac;
protected MockMvc mockMvc;
@Before
public void setup() {
this.mockMvc = webAppContextSetup(this.wac).build();
}
}