From c2ba8360c8d298d42233c3ee1db77b3d3a7517a4 Mon Sep 17 00:00:00 2001 From: Svyatoslav Reyentenko Date: Thu, 2 Dec 2010 23:58:58 +0300 Subject: [PATCH] Tests are slightly changed to do more work --- .../CollectionChangeNoRevisionTest.java | 34 +++++++------------ ...java => CollectionChangeRevisionTest.java} | 2 +- 2 files changed, 14 insertions(+), 22 deletions(-) rename hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/norevision/{CollectionChangRevisionTest.java => CollectionChangeRevisionTest.java} (89%) diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/norevision/CollectionChangeNoRevisionTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/norevision/CollectionChangeNoRevisionTest.java index 3786856b8d..767920a817 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/norevision/CollectionChangeNoRevisionTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/norevision/CollectionChangeNoRevisionTest.java @@ -19,10 +19,8 @@ import java.util.List; public class CollectionChangeNoRevisionTest extends AbstractSessionTest { protected static final int EXPECTED_PERSON_REVISION_COUNT = 1; - protected static final int EXPECTED_NAME_REVISION_COUNT = 1; protected static final String CREATE_REVISION_ON_COLLECTION_CHANGE = "false"; protected Integer personId; - protected List namesId = new ArrayList(); @Override protected void initMappings() throws MappingException, URISyntaxException { @@ -35,38 +33,32 @@ public class CollectionChangeNoRevisionTest extends AbstractSessionTest { return CREATE_REVISION_ON_COLLECTION_CHANGE; } - @BeforeMethod(firstTimeOnly = true) + @BeforeClass(dependsOnMethods = "init") public void initData() { newSessionFactory(); Person p = new Person(); Name n = new Name(); n.setName("name1"); p.getNames().add(n); - Transaction transaction = getSession().beginTransaction(); + getSession().getTransaction().begin(); getSession().saveOrUpdate(p); - transaction.commit(); + getSession().getTransaction().commit(); personId = p.getId(); - namesId.add(n.getId()); - + getSession().getTransaction().begin(); + n.setName("Changed name"); + getSession().saveOrUpdate(p); + getSession().getTransaction().commit(); + getSession().getTransaction().begin(); + Name n2 = new Name(); + n2.setName("name2"); + p.getNames().add(n2); + getSession().getTransaction().commit(); } @Test public void testPersonRevisionCount() { - Person p = (Person) getSession().createCriteria(Person.class).add(Restrictions.idEq(personId)).uniqueResult(); - Name n2 = new Name(); - n2.setName("name2"); - p.getNames().add(n2); - Transaction transaction = getSession().beginTransaction(); - getSession().saveOrUpdate(p); - transaction.commit(); - namesId.add(n2.getId()); int sizePerson = getAuditReader().getRevisions(Person.class, personId).size(); - Assert.assertEquals(config.getProperty("org.hibernate.envers.revision_on_collection_change"), getCollectionChangeValue()); - Assert.assertEquals(sizePerson, getExpectedPersonRevisionCount()); - for (Integer id : namesId) { - int sizeName = getAuditReader().getRevisions(Name.class, id).size(); - Assert.assertEquals(sizeName, EXPECTED_NAME_REVISION_COUNT); - } + assert sizePerson == getExpectedPersonRevisionCount(); } protected int getExpectedPersonRevisionCount() { diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/norevision/CollectionChangRevisionTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/norevision/CollectionChangeRevisionTest.java similarity index 89% rename from hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/norevision/CollectionChangRevisionTest.java rename to hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/norevision/CollectionChangeRevisionTest.java index fb9bd8a7e5..d48fec6a8a 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/norevision/CollectionChangRevisionTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/norevision/CollectionChangeRevisionTest.java @@ -5,7 +5,7 @@ import org.testng.annotations.BeforeMethod; import java.net.URISyntaxException; -public class CollectionChangRevisionTest extends CollectionChangeNoRevisionTest { +public class CollectionChangeRevisionTest extends CollectionChangeNoRevisionTest { protected static final int PERSON_COUNT_NEW_REVISION_ON_COLLECTION = 2; protected static final String NEW_REVISION_ON_COLLECTION = "true";