Hi guys,
I have created a Spring Roo Project using Hibernate and MySQL, and some jpa entities.
This Roo project is a dependency inside another project, and I am trying to create some JUnit tests.
My Roo project is just for persistence.
What I would like to have is a rollback after each @Test execution. Is it possible?
After reading a lot of suggestions I couldn't make any of then work, and my jUnit class is like this right now:
Code:@RunWith(SpringJUnit4ClassRunner.class) @Transactional @ContextConfiguration(locations = { "classpath*:spring/*test-context.xml", "classpath*:spring/applicationContext.xml", "classpath*:spring/passport-client-context.xml"}) public class TaxControllerTest extends AbstractJUnit4SpringContextTests { @Before public void setUp() throws Exception { Tax tax = new Tax(); tax.setCode("IPI"); tax.persist(); tax.flush(); } @Test public void test1() { assertEquals(1, Tax.countTaxes()); } @Test public void test2() { assertEquals(1, Tax.countTaxes()); // It fails here, because there is already one, from the first execution. } }


Reply With Quote
