[SPR-5315][SPR-5699] Reverted changes to TransactionalTestExecutionListener: transactions are no longer automatically flushed before rolling back.
This commit is contained in:
parent
ec2833cd63
commit
ee1938eb74
|
|
@ -499,7 +499,6 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis
|
||||||
|
|
||||||
public void endTransaction(boolean rollback) {
|
public void endTransaction(boolean rollback) {
|
||||||
if (rollback) {
|
if (rollback) {
|
||||||
this.transactionStatus.flush();
|
|
||||||
this.transactionManager.rollback(this.transactionStatus);
|
this.transactionManager.rollback(this.transactionStatus);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.exception.ConstraintViolationException;
|
import org.hibernate.exception.ConstraintViolationException;
|
||||||
import org.hibernate.exception.GenericJDBCException;
|
import org.hibernate.exception.GenericJDBCException;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
|
@ -34,8 +33,8 @@ import org.springframework.test.context.junit4.orm.domain.Person;
|
||||||
import org.springframework.test.context.junit4.orm.service.PersonService;
|
import org.springframework.test.context.junit4.orm.service.PersonService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transactional integration tests regarding <i>automatic vs. manual</i> session
|
* Transactional integration tests regarding <i>manual</i> session flushing with
|
||||||
* flushing with Hibernate.
|
* Hibernate.
|
||||||
*
|
*
|
||||||
* @author Sam Brannen
|
* @author Sam Brannen
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
|
|
@ -78,7 +77,6 @@ public class HibernateSessionFlushingTests extends AbstractTransactionalJUnit4Sp
|
||||||
assertNotNull("Juergen's ID should have been set", juergen.getId());
|
assertNotNull("Juergen's ID should have been set", juergen.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore("Disabled until SPR-5699 is resolved")
|
|
||||||
@Test(expected = ConstraintViolationException.class)
|
@Test(expected = ConstraintViolationException.class)
|
||||||
public void saveJuergenWithNullDriversLicense() {
|
public void saveJuergenWithNullDriversLicense() {
|
||||||
personService.save(new Person(JUERGEN));
|
personService.save(new Person(JUERGEN));
|
||||||
|
|
@ -91,19 +89,19 @@ public class HibernateSessionFlushingTests extends AbstractTransactionalJUnit4Sp
|
||||||
personService.save(sam);
|
personService.save(sam);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = GenericJDBCException.class)
|
@Test
|
||||||
// @IfProfileValue(name = "spring-compatibility", value = "2.5.6")
|
// no expected exception!
|
||||||
public void updateSamWithNullDriversLicenseSpring256() {
|
public void updateSamWithNullDriversLicenseWithoutSessionFlush() {
|
||||||
updateSamWithNullDriversLicense();
|
updateSamWithNullDriversLicense();
|
||||||
|
// False positive, since an exception will be thrown once the session is
|
||||||
|
// finally flushed (i.e., in production code)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = GenericJDBCException.class)
|
||||||
|
public void updateSamWithNullDriversLicenseWithSessionFlush() {
|
||||||
|
updateSamWithNullDriversLicense();
|
||||||
|
// Manual flush is required to avoid false positive in test
|
||||||
sessionFactory.getCurrentSession().flush();
|
sessionFactory.getCurrentSession().flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore("Disabled until SPR-5699 is resolved")
|
|
||||||
@Test(expected = GenericJDBCException.class)
|
|
||||||
// @Test(expected = UncategorizedSQLException.class)
|
|
||||||
// @IfProfileValue(name = "spring-compatibility", value = "3.0.0.M2")
|
|
||||||
public void updateSamWithNullDriversLicenseSpring300() {
|
|
||||||
updateSamWithNullDriversLicense();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue