HHH-6014: Migrating the tests from testng to junit

This commit is contained in:
adamw 2011-04-01 21:37:59 +02:00
parent 26b5e1afa8
commit fb512cdc25
182 changed files with 1958 additions and 1903 deletions

View File

@ -23,12 +23,13 @@
*/
package org.hibernate.envers.test.integration.accesstype;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -40,7 +41,7 @@ public class FieldAccessType extends AbstractEntityTest {
cfg.addAnnotatedClass(FieldAccessTypeEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();
em.getTransaction().begin();

View File

@ -1,11 +1,13 @@
package org.hibernate.envers.test.integration.accesstype;
import static org.testng.Assert.assertEquals;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
import static org.junit.Assert.*;
public class ImmutableClassAccessType extends AbstractEntityTest {
private Country country;
@ -14,7 +16,7 @@ public class ImmutableClassAccessType extends AbstractEntityTest {
cfg.addAnnotatedClass(Country.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,12 +22,13 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.accesstype;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -39,7 +40,7 @@ public class MixedAccessType extends AbstractEntityTest {
cfg.addAnnotatedClass(MixedAccessTypeEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();
em.getTransaction().begin();

View File

@ -22,12 +22,13 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.accesstype;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -39,7 +40,7 @@ public class PropertyAccessType extends AbstractEntityTest {
cfg.addAnnotatedClass(PropertyAccessTypeEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();
em.getTransaction().begin();

View File

@ -22,13 +22,14 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.auditReader;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.exception.NotAuditedException;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* A test which checks the correct behavior of AuditReader.isEntityClassAudited(Class entityClass).
@ -41,7 +42,7 @@ public class AuditReaderAPITest extends AbstractEntityTest {
cfg.addAnnotatedClass(NotAuditedTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();
em.getTransaction().begin();

View File

@ -22,12 +22,13 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.basic;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -41,7 +42,7 @@ public class Delete extends AbstractEntityTest {
cfg.addAnnotatedClass(BasicTestEntity2.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
// Revision 1
EntityManager em = getEntityManager();

View File

@ -22,12 +22,13 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.basic;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -39,7 +40,7 @@ public class GlobalVersioned extends AbstractEntityTest {
cfg.addAnnotatedClass(BasicTestEntity4.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();
em.getTransaction().begin();

View File

@ -22,12 +22,13 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.basic;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -41,7 +42,7 @@ public class ManyOperationsInTransaction extends AbstractEntityTest {
cfg.addAnnotatedClass(BasicTestEntity1.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
// Revision 1
EntityManager em = getEntityManager();

View File

@ -22,12 +22,13 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.basic;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.exception.NotAuditedException;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
/**
* @author Adam Warski (adam at warski dot org)
@ -36,10 +37,11 @@ public class NotVersioned extends AbstractEntityTest {
private Integer id1;
public void configure(Ejb3Configuration cfg) {
cfg.addAnnotatedClass(BasicTestEntity1.class);
cfg.addAnnotatedClass(BasicTestEntity3.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();
em.getTransaction().begin();
@ -55,12 +57,12 @@ public class NotVersioned extends AbstractEntityTest {
em.getTransaction().commit();
}
@Test(expectedExceptions = NotAuditedException.class)
@Test(expected = NotAuditedException.class)
public void testRevisionsCounts() {
getAuditReader().getRevisions(BasicTestEntity3.class, id1);
}
@Test(expectedExceptions = NotAuditedException.class)
@Test(expected = NotAuditedException.class)
public void testHistoryOfId1() {
getAuditReader().find(BasicTestEntity3.class, id1, 1);
}

View File

@ -22,12 +22,13 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.basic;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -59,7 +60,7 @@ public class NullProperties extends AbstractEntityTest {
em.getTransaction().commit();
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
id1 = addNewEntity("x", 1); // rev 1
id2 = addNewEntity(null, 20); // rev 2

View File

@ -22,12 +22,14 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.basic;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.IntTestEntity;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -54,12 +56,12 @@ public class Simple extends AbstractEntityTest {
em.getTransaction().commit();
}
@Test(dependsOnMethods = "initData")
@Test
public void testRevisionsCounts() {
assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(IntTestEntity.class, id1));
}
@Test(dependsOnMethods = "initData")
@Test
public void testHistoryOfId1() {
IntTestEntity ver1 = new IntTestEntity(10, id1);
IntTestEntity ver2 = new IntTestEntity(20, id1);

View File

@ -22,13 +22,14 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.basic;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.exception.RevisionDoesNotExistException;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -61,7 +62,7 @@ public class SingleOperationInTransaction extends AbstractEntityTest {
em.getTransaction().commit();
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
id1 = addNewEntity("x", 1); // rev 1
id2 = addNewEntity("y", 20); // rev 2
@ -91,12 +92,12 @@ public class SingleOperationInTransaction extends AbstractEntityTest {
}
}
@Test(expectedExceptions = RevisionDoesNotExistException.class)
@Test(expected = RevisionDoesNotExistException.class)
public void testNotExistingRevision() {
getAuditReader().getRevisionDate(8);
}
@Test(expectedExceptions = IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testIllegalRevision() {
getAuditReader().getRevisionDate(0);
}

View File

@ -22,12 +22,13 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.basic;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -58,7 +59,7 @@ public class UnversionedPropertiesChange extends AbstractEntityTest {
em.getTransaction().commit();
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
id1 = addNewEntity("x", "a"); // rev 1
modifyEntity(id1, "x", "a"); // no rev

View File

@ -22,13 +22,14 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.basic;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.UnversionedEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -40,7 +41,7 @@ public class UnversionedProperty extends AbstractEntityTest {
cfg.addAnnotatedClass(UnversionedEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,13 +22,14 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.cache;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.onetomany.SetRefEdEntity;
import org.hibernate.envers.test.entities.onetomany.SetRefIngEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
/**
* @author Adam Warski (adam at warski dot org)
@ -46,7 +47,7 @@ public class OneToManyCache extends AbstractEntityTest {
cfg.addAnnotatedClass(SetRefIngEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,13 +22,14 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.cache;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.integration.onetoone.bidirectional.BiRefEdEntity;
import org.hibernate.envers.test.integration.onetoone.bidirectional.BiRefIngEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
/**
* @author Adam Warski (adam at warski dot org)
@ -45,7 +46,7 @@ public class OneToOneCache extends AbstractEntityTest {
cfg.addAnnotatedClass(BiRefIngEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
BiRefEdEntity ed1 = new BiRefEdEntity(1, "data_ed_1");
BiRefEdEntity ed2 = new BiRefEdEntity(2, "data_ed_2");

View File

@ -22,13 +22,14 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.cache;
import java.util.List;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.IntTestEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.List;
/**
* @author Adam Warski (adam at warski dot org)
@ -41,7 +42,7 @@ public class QueryCache extends AbstractEntityTest {
cfg.addAnnotatedClass(IntTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
// Revision 1
EntityManager em = getEntityManager();

View File

@ -22,16 +22,17 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.collection;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.collection.EnumSetEntity;
import org.hibernate.envers.test.entities.collection.EnumSetEntity.E1;
import org.hibernate.envers.test.entities.collection.EnumSetEntity.E2;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -43,7 +44,7 @@ public class EnumSet extends AbstractEntityTest {
cfg.addAnnotatedClass(EnumSetEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,15 +22,16 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.collection;
import java.util.Arrays;
import java.util.Collections;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.collection.StringListEntity;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.Collections;
/**
* @author Adam Warski (adam at warski dot org)
@ -43,7 +44,7 @@ public class StringList extends AbstractEntityTest {
cfg.addAnnotatedClass(StringListEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,15 +22,16 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.collection;
import java.util.Arrays;
import java.util.Collections;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.collection.StringMapEntity;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.Collections;
/**
* @author Adam Warski (adam at warski dot org)
@ -43,7 +44,7 @@ public class StringMap extends AbstractEntityTest {
cfg.addAnnotatedClass(StringMapEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,15 +22,16 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.collection;
import java.util.Arrays;
import java.util.Collections;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.collection.StringSetEntity;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.Collections;
/**
* @author Adam Warski (adam at warski dot org)
@ -43,7 +44,7 @@ public class StringSet extends AbstractEntityTest {
cfg.addAnnotatedClass(StringSetEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,16 +22,17 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.collection.mapkey;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.components.Component1;
import org.hibernate.envers.test.entities.components.Component2;
import org.hibernate.envers.test.entities.components.ComponentTestEntity;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -47,7 +48,7 @@ public class ComponentMapKey extends AbstractEntityTest {
cfg.addAnnotatedClass(ComponentTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,14 +22,15 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.collection.mapkey;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.StrTestEntity;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -45,7 +46,7 @@ public class IdMapKey extends AbstractEntityTest {
cfg.addAnnotatedClass(StrTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -1,10 +1,11 @@
package org.hibernate.envers.test.integration.collection.norevision;
import java.net.URISyntaxException;
import java.util.List;
import org.hibernate.MappingException;
import org.hibernate.envers.test.AbstractSessionTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import java.net.URISyntaxException;
import java.util.List;
public abstract class AbstractCollectionChangeTest extends AbstractSessionTest {
protected Integer personId;
@ -20,7 +21,7 @@ public abstract class AbstractCollectionChangeTest extends AbstractSessionTest {
protected abstract List<Integer> getExpectedPersonRevisions();
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
newSessionFactory();

View File

@ -22,15 +22,16 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.components;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.components.Component1;
import org.hibernate.envers.test.entities.components.Component2;
import org.hibernate.envers.test.entities.components.ComponentTestEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -45,7 +46,7 @@ public class Components extends AbstractEntityTest {
cfg.addAnnotatedClass(ComponentTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
// Revision 1
EntityManager em = getEntityManager();

View File

@ -22,17 +22,19 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.components;
import static org.hibernate.testing.TestLogger.LOG;
import java.math.BigInteger;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.components.DefaultValueComponent1;
import org.hibernate.envers.test.entities.components.DefaultValueComponent2;
import org.hibernate.envers.test.entities.components.DefaultValueComponentTestEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.math.BigInteger;
import java.util.Arrays;
import static org.hibernate.testing.TestLogger.*;
/**
* Test class for components with default values.
@ -58,7 +60,7 @@ public class DefaultValueComponents extends AbstractEntityTest {
cfg.addAnnotatedClass(DefaultValueComponentTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
// Revision 1
EntityManager em = getEntityManager();

View File

@ -22,20 +22,23 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.components.collections;
import java.util.Arrays;
import java.util.Set;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.components.Component1;
import org.hibernate.envers.test.entities.components.ComponentSetTestEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Ignore;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.Set;
/**
* TODO: enable and implement
* @author Adam Warski (adam at warski dot org)
*/
@Ignore
public class CollectionOfComponents extends AbstractEntityTest {
private Integer id1;
@ -43,7 +46,7 @@ public class CollectionOfComponents extends AbstractEntityTest {
cfg.addAnnotatedClass(ComponentSetTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
// Revision 1
EntityManager em = getEntityManager();
@ -68,12 +71,12 @@ public class CollectionOfComponents extends AbstractEntityTest {
id1 = cte1.getId();
}
@Test(enabled = false)
@Test
public void testRevisionsCounts() {
assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(ComponentSetTestEntity.class, id1));
}
@Test(enabled = false)
@Test
public void testHistoryOfId1() {
assert getAuditReader().find(ComponentSetTestEntity.class, id1, 1).getComps().size() == 0;

View File

@ -22,15 +22,16 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.components.relations;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.StrTestEntity;
import org.hibernate.envers.test.entities.components.relations.ManyToOneComponent;
import org.hibernate.envers.test.entities.components.relations.ManyToOneComponentTestEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -45,7 +46,7 @@ public class ManyToOneInComponent extends AbstractEntityTest {
cfg.addAnnotatedClass(StrTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
// Revision 1
EntityManager em = getEntityManager();

View File

@ -22,15 +22,16 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.components.relations;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.UnversionedStrTestEntity;
import org.hibernate.envers.test.entities.components.relations.NotAuditedManyToOneComponent;
import org.hibernate.envers.test.entities.components.relations.NotAuditedManyToOneComponentTestEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -43,7 +44,7 @@ public class NotAuditedManyToOneInComponent extends AbstractEntityTest {
cfg.addAnnotatedClass(UnversionedStrTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
// No revision
EntityManager em = getEntityManager();

View File

@ -22,15 +22,16 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.components.relations;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.StrTestEntity;
import org.hibernate.envers.test.entities.components.relations.OneToManyComponent;
import org.hibernate.envers.test.entities.components.relations.OneToManyComponentTestEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -45,7 +46,7 @@ public class OneToManyInComponent extends AbstractEntityTest {
cfg.addAnnotatedClass(StrTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
// Revision 1
EntityManager em = getEntityManager();

View File

@ -22,14 +22,15 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.customtype;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.customtype.Component;
import org.hibernate.envers.test.entities.customtype.CompositeCustomTypeEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -41,7 +42,7 @@ public class CompositeCustom extends AbstractEntityTest {
cfg.addAnnotatedClass(CompositeCustomTypeEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,13 +22,14 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.customtype;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.customtype.ParametrizedCustomTypeEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -40,7 +41,7 @@ public class ParametrizedCustom extends AbstractEntityTest {
cfg.addAnnotatedClass(ParametrizedCustomTypeEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,13 +22,14 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.data;
import java.util.Arrays;
import java.util.Date;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.Date;
/**
* @author Adam Warski (adam at warski dot org)
@ -40,7 +41,7 @@ public class Dates extends AbstractEntityTest {
cfg.addAnnotatedClass(DateTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();
em.getTransaction().begin();

View File

@ -22,12 +22,13 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.data;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -39,7 +40,7 @@ public class Enums extends AbstractEntityTest {
cfg.addAnnotatedClass(EnumTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();
em.getTransaction().begin();

View File

@ -25,8 +25,7 @@ package org.hibernate.envers.test.integration.data;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
@ -41,7 +40,7 @@ public class LobSerializables extends AbstractEntityTest {
cfg.addAnnotatedClass(LobSerializableTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();
em.getTransaction().begin();

View File

@ -22,12 +22,13 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.data;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -39,7 +40,7 @@ public class Lobs extends AbstractEntityTest {
cfg.addAnnotatedClass(LobTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();
em.getTransaction().begin();

View File

@ -22,12 +22,13 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.data;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -39,7 +40,7 @@ public class Serializables extends AbstractEntityTest {
cfg.addAnnotatedClass(SerializableTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();
em.getTransaction().begin();

View File

@ -1,133 +1,132 @@
package org.hibernate.envers.test.integration.entityNames.auditedEntity;
import org.hibernate.MappingException;
import org.hibernate.envers.test.AbstractOneSessionTest;
import org.junit.Test;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
import org.hibernate.MappingException;
import org.hibernate.envers.test.AbstractOneSessionTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* @author Hern&aacute;n Chanfreau
*
*/
@Test(sequential=true)
public class ReadEntityWhitEntityNameTest extends AbstractOneSessionTest{
private long id_pers1;
private long id_pers2;
private long id_pers3;
private Person person1_1;
private Person person1_2;
private Person person1_3;
private Person currentPers1;
protected void initMappings() throws MappingException, URISyntaxException {
URL url = Thread.currentThread().getContextClassLoader().getResource("mappings/entityNames/auditedEntity/mappings.hbm.xml");
config.addFile(new File(url.toURI()));
}
@BeforeClass(dependsOnMethods = "init")
public void initData() {
initializeSession();
Person pers1 = new Person("Hernan", 28);
Person pers2 = new Person("Leandro", 29);
Person pers3 = new Person("Barba", 30);
//REV 1
getSession().getTransaction().begin();
getSession().persist("Personaje",pers1);
id_pers1 = pers1.getId();
getSession().getTransaction().commit();
//REV 2
getSession().getTransaction().begin();
pers1 = (Person)getSession().get("Personaje", id_pers1);
pers1.setAge(29);
getSession().persist("Personaje",pers1);
getSession().persist("Personaje",pers2);
id_pers2 = pers2.getId();
getSession().getTransaction().commit();
//REV
getSession().getTransaction().begin();
pers1 = (Person)getSession().get("Personaje", id_pers1);
pers1.setName("Hernan David");
pers2 = (Person)getSession().get("Personaje", id_pers2);
pers2.setAge(30);
getSession().persist("Personaje",pers1);
getSession().persist("Personaje",pers2);
getSession().persist("Personaje",pers3);
id_pers3 = pers3.getId();
getSession().getTransaction().commit();
getSession().getTransaction().begin();
currentPers1 = (Person)getSession().get("Personaje", id_pers1);
getSession().getTransaction().commit();
}
@Test
public void testRetrieveRevisionsWithEntityName() {
List<Number> pers1Revs = getAuditReader().getRevisions(Person.class,"Personaje", id_pers1);
List<Number> pers2Revs = getAuditReader().getRevisions(Person.class,"Personaje", id_pers2);
List<Number> pers3Revs = getAuditReader().getRevisions(Person.class,"Personaje", id_pers3);
assert(pers1Revs.size() == 3);
assert(pers2Revs.size() == 2);
assert(pers3Revs.size() == 1);
}
@Test(dependsOnMethods="testRetrieveRevisionsWithEntityName")
public void testRetrieveAuditedEntityWithEntityName() {
person1_1 = getAuditReader().find(Person.class, "Personaje", id_pers1, 1);
person1_2 = getAuditReader().find(Person.class, "Personaje", id_pers1, 2);
person1_3 = getAuditReader().find(Person.class, "Personaje", id_pers1, 3);
assert(person1_1 != null);
assert(person1_2 != null);
assert(person1_3 != null);
}
@Test(dependsOnMethods="testRetrieveAuditedEntityWithEntityName")
public void testObtainEntityNameAuditedEntityWithEntityName() {
String currentPers1EN = getSession().getEntityName(currentPers1);
String person1EN = getAuditReader().getEntityName(person1_1.getId(), 1, person1_1);
assert (currentPers1EN.equals(person1EN));
String person2EN = getAuditReader().getEntityName(person1_2.getId(), 2, person1_2);
assert (currentPers1EN.equals(person2EN));
String person3EN = getAuditReader().getEntityName(person1_3.getId(), 3, person1_3);
assert (currentPers1EN.equals(person3EN));
}
@Test(dependsOnMethods="testObtainEntityNameAuditedEntityWithEntityName")
public void testRetrieveAuditedEntityWithEntityNameWithNewSession() {
// force a new session and AR
forceNewSession();
person1_1 = getAuditReader().find(Person.class, "Personaje", id_pers1, 1);
person1_2 = getAuditReader().find(Person.class, "Personaje", id_pers1, 2);
person1_3 = getAuditReader().find(Person.class, "Personaje", id_pers1, 3);
assert(person1_1 != null);
assert(person1_2 != null);
assert(person1_3 != null);
}
}
/**
* @author Hern&aacute;n Chanfreau
*
*/
public class ReadEntityWhitEntityNameTest extends AbstractOneSessionTest{
private long id_pers1;
private long id_pers2;
private long id_pers3;
private Person person1_1;
private Person person1_2;
private Person person1_3;
private Person currentPers1;
protected void initMappings() throws MappingException, URISyntaxException {
URL url = Thread.currentThread().getContextClassLoader().getResource("mappings/entityNames/auditedEntity/mappings.hbm.xml");
config.addFile(new File(url.toURI()));
}
@Test
public void initData() {
initializeSession();
Person pers1 = new Person("Hernan", 28);
Person pers2 = new Person("Leandro", 29);
Person pers3 = new Person("Barba", 30);
//REV 1
getSession().getTransaction().begin();
getSession().persist("Personaje",pers1);
id_pers1 = pers1.getId();
getSession().getTransaction().commit();
//REV 2
getSession().getTransaction().begin();
pers1 = (Person)getSession().get("Personaje", id_pers1);
pers1.setAge(29);
getSession().persist("Personaje",pers1);
getSession().persist("Personaje",pers2);
id_pers2 = pers2.getId();
getSession().getTransaction().commit();
//REV
getSession().getTransaction().begin();
pers1 = (Person)getSession().get("Personaje", id_pers1);
pers1.setName("Hernan David");
pers2 = (Person)getSession().get("Personaje", id_pers2);
pers2.setAge(30);
getSession().persist("Personaje",pers1);
getSession().persist("Personaje",pers2);
getSession().persist("Personaje",pers3);
id_pers3 = pers3.getId();
getSession().getTransaction().commit();
getSession().getTransaction().begin();
currentPers1 = (Person)getSession().get("Personaje", id_pers1);
getSession().getTransaction().commit();
}
@Test
public void testRetrieveRevisionsWithEntityName() {
List<Number> pers1Revs = getAuditReader().getRevisions(Person.class,"Personaje", id_pers1);
List<Number> pers2Revs = getAuditReader().getRevisions(Person.class,"Personaje", id_pers2);
List<Number> pers3Revs = getAuditReader().getRevisions(Person.class,"Personaje", id_pers3);
assert(pers1Revs.size() == 3);
assert(pers2Revs.size() == 2);
assert(pers3Revs.size() == 1);
}
@Test
public void testRetrieveAuditedEntityWithEntityName() {
person1_1 = getAuditReader().find(Person.class, "Personaje", id_pers1, 1);
person1_2 = getAuditReader().find(Person.class, "Personaje", id_pers1, 2);
person1_3 = getAuditReader().find(Person.class, "Personaje", id_pers1, 3);
assert(person1_1 != null);
assert(person1_2 != null);
assert(person1_3 != null);
}
@Test
public void testObtainEntityNameAuditedEntityWithEntityName() {
String currentPers1EN = getSession().getEntityName(currentPers1);
String person1EN = getAuditReader().getEntityName(person1_1.getId(), 1, person1_1);
assert (currentPers1EN.equals(person1EN));
String person2EN = getAuditReader().getEntityName(person1_2.getId(), 2, person1_2);
assert (currentPers1EN.equals(person2EN));
String person3EN = getAuditReader().getEntityName(person1_3.getId(), 3, person1_3);
assert (currentPers1EN.equals(person3EN));
}
@Test
public void testRetrieveAuditedEntityWithEntityNameWithNewSession() {
// force a new session and AR
forceNewSession();
person1_1 = getAuditReader().find(Person.class, "Personaje", id_pers1, 1);
person1_2 = getAuditReader().find(Person.class, "Personaje", id_pers1, 2);
person1_3 = getAuditReader().find(Person.class, "Personaje", id_pers1, 3);
assert(person1_1 != null);
assert(person1_2 != null);
assert(person1_3 != null);
}
}

View File

@ -1,129 +1,128 @@
package org.hibernate.envers.test.integration.entityNames.manyToManyAudited;
import org.hibernate.MappingException;
import org.hibernate.envers.test.AbstractOneSessionTest;
import org.junit.Test;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.MappingException;
import org.hibernate.envers.test.AbstractOneSessionTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* @author Hern&aacute;n Chanfreau
*
*/
@Test(sequential=true)
public class ReadEntityWithAuditedManyToManyTest extends AbstractOneSessionTest{
private long id_car1;
private long id_car2;
private long id_pers1;
private Person person1;
private Car car1;
private Person person1_1;
private Car car1_2;
protected void initMappings() throws MappingException, URISyntaxException {
URL url = Thread.currentThread().getContextClassLoader().getResource("mappings/entityNames/manyToManyAudited/mappings.hbm.xml");
config.addFile(new File(url.toURI()));
}
@BeforeClass(dependsOnMethods = "init")
public void initData() {
initializeSession();
Person pers1 = new Person("Hernan", 28);
Person pers2 = new Person("Leandro", 29);
Person pers3 = new Person("Barba", 32);
Person pers4 = new Person("Camomo", 15);
//REV 1
getSession().getTransaction().begin();
List<Person > owners = new ArrayList<Person>();
owners.add(pers1);
owners.add(pers2);
owners.add(pers3);
Car car1 = new Car(5, owners);
getSession().persist(car1);
getSession().getTransaction().commit();
id_pers1 = pers1.getId();
id_car1 = car1.getId();
owners = new ArrayList<Person>();
owners.add(pers2);
owners.add(pers3);
owners.add(pers4);
Car car2 = new Car(27, owners);
//REV 2
getSession().getTransaction().begin();
Person person1 = (Person)getSession().get("Personaje", id_pers1);
person1.setName("Hernan David");
person1.setAge(40);
getSession().persist(car1);
getSession().persist(car2);
getSession().getTransaction().commit();
id_car2 = car2.getId();
}
private void loadDataOnSessionAndAuditReader() {
car1_2 = getAuditReader().find(Car.class, id_car1, 2);
Car car2_2 = getAuditReader().find(Car.class, id_car2, 2);
// navigate through relations to load objects
for (Person owner : car1_2.getOwners()) {
for (Car ownedCar : owner.getCars()) {
ownedCar.getNumber();
}
}
for (Person owner : car2_2.getOwners()) {
for (Car ownedCar : owner.getCars()) {
ownedCar.getNumber();
}
}
car1 = (Car)getSession().get(Car.class, id_car1);
person1 = (Person)getSession().get("Personaje", id_pers1);
person1_1 = getAuditReader().find(Person.class, "Personaje", id_pers1, 1);
}
private void checkEntityNames() {
String currPerson1EN = getSession().getEntityName(person1);
String currCar1EN = getSession().getEntityName(car1);
String person1_1EN = getAuditReader().getEntityName(id_pers1, 1, person1_1);
assert(currPerson1EN.equals(person1_1EN));
String car1_2EN = getAuditReader().getEntityName(id_car1, 2, car1_2);
assert(currCar1EN.equals(car1_2EN));
}
@Test
public void testGetEntityNameManyYoManyWithEntityName() {
loadDataOnSessionAndAuditReader();
checkEntityNames();
}
@Test(dependsOnMethods="testGetEntityNameManyYoManyWithEntityName")
public void testGetEntityNameManyYoManyWithEntityNameInNewSession() {
//force new session and AR
forceNewSession();
loadDataOnSessionAndAuditReader();
checkEntityNames();
}
}
/**
* @author Hern&aacute;n Chanfreau
*
*/
public class ReadEntityWithAuditedManyToManyTest extends AbstractOneSessionTest{
private long id_car1;
private long id_car2;
private long id_pers1;
private Person person1;
private Car car1;
private Person person1_1;
private Car car1_2;
protected void initMappings() throws MappingException, URISyntaxException {
URL url = Thread.currentThread().getContextClassLoader().getResource("mappings/entityNames/manyToManyAudited/mappings.hbm.xml");
config.addFile(new File(url.toURI()));
}
@Test
public void initData() {
initializeSession();
Person pers1 = new Person("Hernan", 28);
Person pers2 = new Person("Leandro", 29);
Person pers3 = new Person("Barba", 32);
Person pers4 = new Person("Camomo", 15);
//REV 1
getSession().getTransaction().begin();
List<Person > owners = new ArrayList<Person>();
owners.add(pers1);
owners.add(pers2);
owners.add(pers3);
Car car1 = new Car(5, owners);
getSession().persist(car1);
getSession().getTransaction().commit();
id_pers1 = pers1.getId();
id_car1 = car1.getId();
owners = new ArrayList<Person>();
owners.add(pers2);
owners.add(pers3);
owners.add(pers4);
Car car2 = new Car(27, owners);
//REV 2
getSession().getTransaction().begin();
Person person1 = (Person)getSession().get("Personaje", id_pers1);
person1.setName("Hernan David");
person1.setAge(40);
getSession().persist(car1);
getSession().persist(car2);
getSession().getTransaction().commit();
id_car2 = car2.getId();
}
private void loadDataOnSessionAndAuditReader() {
car1_2 = getAuditReader().find(Car.class, id_car1, 2);
Car car2_2 = getAuditReader().find(Car.class, id_car2, 2);
// navigate through relations to load objects
for (Person owner : car1_2.getOwners()) {
for (Car ownedCar : owner.getCars()) {
ownedCar.getNumber();
}
}
for (Person owner : car2_2.getOwners()) {
for (Car ownedCar : owner.getCars()) {
ownedCar.getNumber();
}
}
car1 = (Car)getSession().get(Car.class, id_car1);
person1 = (Person)getSession().get("Personaje", id_pers1);
person1_1 = getAuditReader().find(Person.class, "Personaje", id_pers1, 1);
}
private void checkEntityNames() {
String currPerson1EN = getSession().getEntityName(person1);
String currCar1EN = getSession().getEntityName(car1);
String person1_1EN = getAuditReader().getEntityName(id_pers1, 1, person1_1);
assert(currPerson1EN.equals(person1_1EN));
String car1_2EN = getAuditReader().getEntityName(id_car1, 2, car1_2);
assert(currCar1EN.equals(car1_2EN));
}
@Test
public void testGetEntityNameManyYoManyWithEntityName() {
loadDataOnSessionAndAuditReader();
checkEntityNames();
}
@Test
public void testGetEntityNameManyYoManyWithEntityNameInNewSession() {
//force new session and AR
forceNewSession();
loadDataOnSessionAndAuditReader();
checkEntityNames();
}
}

View File

@ -1,126 +1,125 @@
package org.hibernate.envers.test.integration.entityNames.oneToManyAudited;
import org.hibernate.MappingException;
import org.hibernate.envers.test.AbstractOneSessionTest;
import org.junit.Test;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.MappingException;
import org.hibernate.envers.test.AbstractOneSessionTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* @author Hern&aacute;n Chanfreau
*
*/
@Test(sequential=true)
public class ReadEntityWithAuditedCollectionTest extends AbstractOneSessionTest{
private long id_car1;
private long id_car2;
private Car currentCar1;
private Person currentPerson1;
private long id_pers1;
private Car car1_1;
private Person person1_1;
protected void initMappings() throws MappingException, URISyntaxException {
URL url = Thread.currentThread().getContextClassLoader().getResource("mappings/entityNames/oneToManyAudited/mappings.hbm.xml");
config.addFile(new File(url.toURI()));
}
@BeforeClass(dependsOnMethods = "init")
public void initData() {
initializeSession();
Person pers1 = new Person("Hernan", 28);
Person pers2 = new Person("Leandro", 29);
Person pers4 = new Person("Camomo", 15);
List<Person > owners = new ArrayList<Person>();
owners.add(pers1);
owners.add(pers2);
Car car1 = new Car(5, owners);
//REV 1
getSession().getTransaction().begin();
getSession().persist(car1);
getSession().getTransaction().commit();
id_pers1 = pers1.getId();
id_car1 = car1.getId();
owners = new ArrayList<Person>();
owners.add(pers2);
owners.add(pers4);
Car car2 = new Car(27, owners);
//REV 2
getSession().getTransaction().begin();
Person person1 = (Person)getSession().get("Personaje", id_pers1);
person1.setName("Hernan David");
person1.setAge(40);
getSession().persist(car1);
getSession().persist(car2);
getSession().getTransaction().commit();
id_car2 = car2.getId();
}
private void loadDataOnSessionAndAuditReader() {
currentCar1 = (Car)getSession().get(Car.class, id_car1);
currentPerson1 = (Person)getSession().get("Personaje", id_pers1);
person1_1 = getAuditReader().find(Person.class,"Personaje", id_pers1, 1);
car1_1 = getAuditReader().find(Car.class, id_car1, 2);
Car car2 = getAuditReader().find(Car.class, id_car2, 2);
for (Person owner : car1_1.getOwners()) {
owner.getName();
owner.getAge();
}
for (Person owner : car2.getOwners()) {
owner.getName();
owner.getAge();
}
}
private void checkEntityNames() {
String currCar1EN = getSession().getEntityName(currentCar1);
String currPerson1EN = getSession().getEntityName(currentPerson1);
String car1_1EN = getAuditReader().getEntityName(id_car1, 2, car1_1);
assert(currCar1EN.equals(car1_1EN));
String person1_1EN = getAuditReader().getEntityName(id_pers1, 1, person1_1);
assert(currPerson1EN.equals(person1_1EN));
}
@Test
public void testObtainEntityNameAuditedCollectionWithEntityName() {
this.loadDataOnSessionAndAuditReader();
checkEntityNames();
}
@Test(dependsOnMethods="testObtainEntityNameAuditedCollectionWithEntityName")
public void testObtainEntityNameAuditedCollectionWithEntityNameInNewSession() {
// force a new session and AR
forceNewSession();
loadDataOnSessionAndAuditReader();
checkEntityNames();
}
}
/**
* @author Hern&aacute;n Chanfreau
*
*/
public class ReadEntityWithAuditedCollectionTest extends AbstractOneSessionTest{
private long id_car1;
private long id_car2;
private Car currentCar1;
private Person currentPerson1;
private long id_pers1;
private Car car1_1;
private Person person1_1;
protected void initMappings() throws MappingException, URISyntaxException {
URL url = Thread.currentThread().getContextClassLoader().getResource("mappings/entityNames/oneToManyAudited/mappings.hbm.xml");
config.addFile(new File(url.toURI()));
}
@Test
public void initData() {
initializeSession();
Person pers1 = new Person("Hernan", 28);
Person pers2 = new Person("Leandro", 29);
Person pers4 = new Person("Camomo", 15);
List<Person > owners = new ArrayList<Person>();
owners.add(pers1);
owners.add(pers2);
Car car1 = new Car(5, owners);
//REV 1
getSession().getTransaction().begin();
getSession().persist(car1);
getSession().getTransaction().commit();
id_pers1 = pers1.getId();
id_car1 = car1.getId();
owners = new ArrayList<Person>();
owners.add(pers2);
owners.add(pers4);
Car car2 = new Car(27, owners);
//REV 2
getSession().getTransaction().begin();
Person person1 = (Person)getSession().get("Personaje", id_pers1);
person1.setName("Hernan David");
person1.setAge(40);
getSession().persist(car1);
getSession().persist(car2);
getSession().getTransaction().commit();
id_car2 = car2.getId();
}
private void loadDataOnSessionAndAuditReader() {
currentCar1 = (Car)getSession().get(Car.class, id_car1);
currentPerson1 = (Person)getSession().get("Personaje", id_pers1);
person1_1 = getAuditReader().find(Person.class,"Personaje", id_pers1, 1);
car1_1 = getAuditReader().find(Car.class, id_car1, 2);
Car car2 = getAuditReader().find(Car.class, id_car2, 2);
for (Person owner : car1_1.getOwners()) {
owner.getName();
owner.getAge();
}
for (Person owner : car2.getOwners()) {
owner.getName();
owner.getAge();
}
}
private void checkEntityNames() {
String currCar1EN = getSession().getEntityName(currentCar1);
String currPerson1EN = getSession().getEntityName(currentPerson1);
String car1_1EN = getAuditReader().getEntityName(id_car1, 2, car1_1);
assert(currCar1EN.equals(car1_1EN));
String person1_1EN = getAuditReader().getEntityName(id_pers1, 1, person1_1);
assert(currPerson1EN.equals(person1_1EN));
}
@Test
public void testObtainEntityNameAuditedCollectionWithEntityName() {
this.loadDataOnSessionAndAuditReader();
checkEntityNames();
}
@Test
public void testObtainEntityNameAuditedCollectionWithEntityNameInNewSession() {
// force a new session and AR
forceNewSession();
loadDataOnSessionAndAuditReader();
checkEntityNames();
}
}

View File

@ -1,129 +1,128 @@
package org.hibernate.envers.test.integration.entityNames.oneToManyNotAudited;
import org.hibernate.MappingException;
import org.hibernate.envers.test.AbstractOneSessionTest;
import org.junit.Test;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.MappingException;
import org.hibernate.envers.test.AbstractOneSessionTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* @author Hern&aacute;n Chanfreau
*
*/
@Test(sequential=true)
public class ReadEntityWithAuditedCollectionTest extends AbstractOneSessionTest{
private long id_car1;
private long id_car2;
private Car currentCar1;
private Person currentPerson1;
private long id_pers1;
private Car car1_1;
protected void initMappings() throws MappingException, URISyntaxException {
URL url = Thread.currentThread().getContextClassLoader().getResource("mappings/entityNames/oneToManyNotAudited/mappings.hbm.xml");
config.addFile(new File(url.toURI()));
}
@BeforeClass(dependsOnMethods = "init")
public void initData() {
initializeSession();
Person pers1 = new Person("Hernan", 28);
Person pers2 = new Person("Leandro", 29);
Person pers4 = new Person("Camomo", 15);
List<Person > owners = new ArrayList<Person>();
owners.add(pers1);
owners.add(pers2);
Car car1 = new Car(5, owners);
//REV 1
getSession().getTransaction().begin();
getSession().persist(car1);
getSession().getTransaction().commit();
id_pers1 = pers1.getId();
id_car1 = car1.getId();
owners = new ArrayList<Person>();
owners.add(pers2);
owners.add(pers4);
Car car2 = new Car(27, owners);
//REV 2
getSession().getTransaction().begin();
Person person1 = (Person)getSession().get("Personaje", id_pers1);
person1.setName("Hernan David");
person1.setAge(40);
getSession().persist(car1);
getSession().persist(car2);
getSession().getTransaction().commit();
id_car2 = car2.getId();
}
private void loadDataOnSessionAndAuditReader() {
currentCar1 = (Car)getSession().get(Car.class, id_car1);
currentPerson1 = (Person)getSession().get("Personaje", id_pers1);
car1_1 = getAuditReader().find(Car.class, id_car1, 2);
Car car2 = getAuditReader().find(Car.class, id_car2, 2);
for (Person owner : car1_1.getOwners()) {
owner.getName();
owner.getAge();
}
for (Person owner : car2.getOwners()) {
owner.getName();
owner.getAge();
}
}
private void checkEntityNames() {
String currCar1EN = getSession().getEntityName(currentCar1);
String currPerson1EN = getSession().getEntityName(currentPerson1);
String car1_1EN = getAuditReader().getEntityName(id_car1, 2, car1_1);
assert(currCar1EN.equals(car1_1EN));
String person1_1EN = getSession().getEntityName(currentPerson1);
assert(currPerson1EN.equals(person1_1EN));
}
@Test
public void testObtainEntityNameCollectionWithEntityNameAndNotAuditedMode() {
loadDataOnSessionAndAuditReader();
checkEntityNames();
}
@Test(dependsOnMethods="testObtainEntityNameCollectionWithEntityNameAndNotAuditedMode")
public void testObtainEntityNameCollectionWithEntityNameAndNotAuditedModeInNewSession() {
// force new session and AR
forceNewSession();
loadDataOnSessionAndAuditReader();
checkEntityNames();
}
}
/**
* @author Hern&aacute;n Chanfreau
*
*/
public class ReadEntityWithAuditedCollectionTest extends AbstractOneSessionTest{
private long id_car1;
private long id_car2;
private Car currentCar1;
private Person currentPerson1;
private long id_pers1;
private Car car1_1;
protected void initMappings() throws MappingException, URISyntaxException {
URL url = Thread.currentThread().getContextClassLoader().getResource("mappings/entityNames/oneToManyNotAudited/mappings.hbm.xml");
config.addFile(new File(url.toURI()));
}
@Test
public void initData() {
initializeSession();
Person pers1 = new Person("Hernan", 28);
Person pers2 = new Person("Leandro", 29);
Person pers4 = new Person("Camomo", 15);
List<Person > owners = new ArrayList<Person>();
owners.add(pers1);
owners.add(pers2);
Car car1 = new Car(5, owners);
//REV 1
getSession().getTransaction().begin();
getSession().persist(car1);
getSession().getTransaction().commit();
id_pers1 = pers1.getId();
id_car1 = car1.getId();
owners = new ArrayList<Person>();
owners.add(pers2);
owners.add(pers4);
Car car2 = new Car(27, owners);
//REV 2
getSession().getTransaction().begin();
Person person1 = (Person)getSession().get("Personaje", id_pers1);
person1.setName("Hernan David");
person1.setAge(40);
getSession().persist(car1);
getSession().persist(car2);
getSession().getTransaction().commit();
id_car2 = car2.getId();
}
private void loadDataOnSessionAndAuditReader() {
currentCar1 = (Car)getSession().get(Car.class, id_car1);
currentPerson1 = (Person)getSession().get("Personaje", id_pers1);
car1_1 = getAuditReader().find(Car.class, id_car1, 2);
Car car2 = getAuditReader().find(Car.class, id_car2, 2);
for (Person owner : car1_1.getOwners()) {
owner.getName();
owner.getAge();
}
for (Person owner : car2.getOwners()) {
owner.getName();
owner.getAge();
}
}
private void checkEntityNames() {
String currCar1EN = getSession().getEntityName(currentCar1);
String currPerson1EN = getSession().getEntityName(currentPerson1);
String car1_1EN = getAuditReader().getEntityName(id_car1, 2, car1_1);
assert(currCar1EN.equals(car1_1EN));
String person1_1EN = getSession().getEntityName(currentPerson1);
assert(currPerson1EN.equals(person1_1EN));
}
@Test
public void testObtainEntityNameCollectionWithEntityNameAndNotAuditedMode() {
loadDataOnSessionAndAuditReader();
checkEntityNames();
}
@Test
public void testObtainEntityNameCollectionWithEntityNameAndNotAuditedModeInNewSession() {
// force new session and AR
forceNewSession();
loadDataOnSessionAndAuditReader();
checkEntityNames();
}
}

View File

@ -1,130 +1,120 @@
package org.hibernate.envers.test.integration.entityNames.singleAssociatedAudited;
import org.hibernate.MappingException;
import org.hibernate.envers.test.AbstractOneSessionTest;
import org.junit.Test;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import org.hibernate.MappingException;
import org.hibernate.envers.test.AbstractOneSessionTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* @author Hern&aacute;n Chanfreau
*
*/
@Test(sequential=true)
public class ReadEntityAssociatedAuditedTest extends AbstractOneSessionTest{
private long id_car1;
private long id_car2;
private Car currentCar1;
private Car car1;
private long id_pers1;
private long id_pers2;
private Person currentPerson1;
private Person person1;
protected void initMappings() throws MappingException, URISyntaxException {
URL url = Thread.currentThread().getContextClassLoader().getResource("mappings/entityNames/singleAssociatedAudited/mappings.hbm.xml");
config.addFile(new File(url.toURI()));
}
@BeforeClass(dependsOnMethods = "init")
public void initData() {
initializeSession();
Person pers1 = new Person("Hernan", 15);
Person pers2 = new Person("Leandro", 19);
Car car1 = new Car(1, pers1);
Car car2 = new Car(2, pers2);
//REV 1
getSession().getTransaction().begin();
getSession().persist("Personaje",pers1);
getSession().persist(car1);
getSession().getTransaction().commit();
id_car1 = car1.getId();
id_pers1 = pers1.getId();
//REV 2
getSession().getTransaction().begin();
pers1.setAge(50);
getSession().persist("Personaje", pers1);
getSession().persist("Personaje", pers2);
getSession().persist(car2);
getSession().getTransaction().commit();
id_car2 = car2.getId();
id_pers2 = pers2.getId();
}
private void loadDataOnSessionAndAuditReader() {
currentCar1 = (Car)getSession().get(Car.class, id_car1);
currentPerson1 = (Person)getSession().get("Personaje", id_pers1);
car1 = getAuditReader().find(Car.class, id_car1, 1);
person1 = car1.getOwner();
}
private void checkEntities() {
assert(currentPerson1.getAge() != person1.getAge());
Person person2 = (Person)getSession().get("Personaje", id_pers2);
Car car2 = getAuditReader().find(Car.class, id_car2, 2);
Person person2_1 = car2.getOwner();
assert(person2.getAge() == person2_1.getAge());
}
private void checkEntityNames() {
String currentCar1EN = getSession().getEntityName(currentCar1);
String currentPerson1EN = getSession().getEntityName(currentPerson1);
String car1EN = getAuditReader().getEntityName(id_car1, 1, car1);
assert (currentCar1EN.equals(car1EN));
String person1EN = getAuditReader().getEntityName(id_pers1, 1, person1);
assert (currentPerson1EN.equals(person1EN));
}
@Test
public void testGetAssociationWithEntityName() {
loadDataOnSessionAndAuditReader();
checkEntities();
checkEntityNames();
}
@Test(dependsOnMethods="testGetAssociationWithEntityName")
public void testGetAssociationWithEntityNameInNewSession() {
//force a new session and AR
forceNewSession();
loadDataOnSessionAndAuditReader();
checkEntities();
checkEntityNames();
//
// Car car1 = getAuditReader().find(Car.class, id_car1, 1);
// car1.getOwner().getName();
// Car car2 = getAuditReader().find(Car.class, id_car2, 2);
// car2.getOwner().getName();
//
// Person person = getAuditReader().find(Person.class, "Personaje", id_car2, 2);
// person.getName();
}
}
/**
* @author Hern&aacute;n Chanfreau
*
*/
public class ReadEntityAssociatedAuditedTest extends AbstractOneSessionTest{
private long id_car1;
private long id_car2;
private Car currentCar1;
private Car car1;
private long id_pers1;
private long id_pers2;
private Person currentPerson1;
private Person person1;
protected void initMappings() throws MappingException, URISyntaxException {
URL url = Thread.currentThread().getContextClassLoader().getResource("mappings/entityNames/singleAssociatedAudited/mappings.hbm.xml");
config.addFile(new File(url.toURI()));
}
@Test
public void initData() {
initializeSession();
Person pers1 = new Person("Hernan", 15);
Person pers2 = new Person("Leandro", 19);
Car car1 = new Car(1, pers1);
Car car2 = new Car(2, pers2);
//REV 1
getSession().getTransaction().begin();
getSession().persist("Personaje",pers1);
getSession().persist(car1);
getSession().getTransaction().commit();
id_car1 = car1.getId();
id_pers1 = pers1.getId();
//REV 2
getSession().getTransaction().begin();
pers1.setAge(50);
getSession().persist("Personaje", pers1);
getSession().persist("Personaje", pers2);
getSession().persist(car2);
getSession().getTransaction().commit();
id_car2 = car2.getId();
id_pers2 = pers2.getId();
}
private void loadDataOnSessionAndAuditReader() {
currentCar1 = (Car)getSession().get(Car.class, id_car1);
currentPerson1 = (Person)getSession().get("Personaje", id_pers1);
car1 = getAuditReader().find(Car.class, id_car1, 1);
person1 = car1.getOwner();
}
private void checkEntities() {
assert(currentPerson1.getAge() != person1.getAge());
Person person2 = (Person)getSession().get("Personaje", id_pers2);
Car car2 = getAuditReader().find(Car.class, id_car2, 2);
Person person2_1 = car2.getOwner();
assert(person2.getAge() == person2_1.getAge());
}
private void checkEntityNames() {
String currentCar1EN = getSession().getEntityName(currentCar1);
String currentPerson1EN = getSession().getEntityName(currentPerson1);
String car1EN = getAuditReader().getEntityName(id_car1, 1, car1);
assert (currentCar1EN.equals(car1EN));
String person1EN = getAuditReader().getEntityName(id_pers1, 1, person1);
assert (currentPerson1EN.equals(person1EN));
}
@Test
public void testGetAssociationWithEntityName() {
loadDataOnSessionAndAuditReader();
checkEntities();
checkEntityNames();
}
@Test
public void testGetAssociationWithEntityNameInNewSession() {
//force a new session and AR
forceNewSession();
loadDataOnSessionAndAuditReader();
checkEntities();
checkEntityNames();
}
}

View File

@ -1,121 +1,120 @@
package org.hibernate.envers.test.integration.entityNames.singleAssociatedNotAudited;
import org.hibernate.MappingException;
import org.hibernate.envers.test.AbstractOneSessionTest;
import org.junit.Test;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import org.hibernate.MappingException;
import org.hibernate.envers.test.AbstractOneSessionTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* @author Hern&aacute;n Chanfreau
*
*/
@Test(sequential=true)
public class ReadEntityAssociatedNotAuditedTest extends AbstractOneSessionTest {
private long id_car1;
private long id_car2;
private long id_pers1;
private long id_pers2;
private Car car1;
private Car car2;
private Person person1_1;
private Person person2;
private Person currentPerson1;
private Car currentCar1;
protected void initMappings() throws MappingException, URISyntaxException {
URL url = Thread.currentThread().getContextClassLoader().getResource("mappings/entityNames/singleAssociatedNotAudited/mappings.hbm.xml");
config.addFile(new File(url.toURI()));
}
@BeforeClass(dependsOnMethods = "init")
public void initData() {
initializeSession();
Person pers1 = new Person("Hernan", 15);
Person pers2 = new Person("Leandro", 19);
Car car1 = new Car(1, pers1);
Car car2 = new Car(2, pers2);
//REV 1
getSession().getTransaction().begin();
getSession().persist("Personaje",pers1);
getSession().persist(car1);
getSession().getTransaction().commit();
id_car1 = car1.getId();
id_pers1 = pers1.getId();
//REV 2
getSession().getTransaction().begin();
pers1.setAge(50);
getSession().persist("Personaje", pers1);
getSession().persist("Personaje", pers2);
getSession().persist(car2);
getSession().getTransaction().commit();
id_car2 = car2.getId();
id_pers2 = pers2.getId();
}
private void loadDataOnSessionAndAuditReader() {
currentPerson1 = (Person)getSession().get("Personaje", id_pers1);
person2 = (Person)getSession().get("Personaje", id_pers2);
currentCar1 = (Car)getSession().get(Car.class, id_car1);
car1 = getAuditReader().find(Car.class, id_car1, 1);
car2 = getAuditReader().find(Car.class, id_car2, 2);
}
private void checkEntityNames() {
String currentCar1EN = getSession().getEntityName(currentCar1);
String car1EN = getAuditReader().getEntityName(id_car1, 1, car1);
assert (currentCar1EN.equals(car1EN));
}
private void checkEntities() {
person1_1 = car1.getOwner();
Person person2_1 = car2.getOwner();
assert(currentPerson1.getAge() == person1_1.getAge());
assert(person2.getAge() == person2_1.getAge());
}
@Test
public void testObtainEntityNameAssociationWithEntityNameAndNotAuditedMode() {
loadDataOnSessionAndAuditReader();
checkEntities();
checkEntityNames();
}
@Test(dependsOnMethods="testObtainEntityNameAssociationWithEntityNameAndNotAuditedMode")
public void testObtainEntityNameAssociationWithEntityNameAndNotAuditedModeInNewSession() {
//force a new session and AR
forceNewSession();
loadDataOnSessionAndAuditReader();
checkEntities();
checkEntityNames();
}
}
/**
* @author Hern&aacute;n Chanfreau
*
*/
public class ReadEntityAssociatedNotAuditedTest extends AbstractOneSessionTest {
private long id_car1;
private long id_car2;
private long id_pers1;
private long id_pers2;
private Car car1;
private Car car2;
private Person person1_1;
private Person person2;
private Person currentPerson1;
private Car currentCar1;
protected void initMappings() throws MappingException, URISyntaxException {
URL url = Thread.currentThread().getContextClassLoader().getResource("mappings/entityNames/singleAssociatedNotAudited/mappings.hbm.xml");
config.addFile(new File(url.toURI()));
}
@Test
public void initData() {
initializeSession();
Person pers1 = new Person("Hernan", 15);
Person pers2 = new Person("Leandro", 19);
Car car1 = new Car(1, pers1);
Car car2 = new Car(2, pers2);
//REV 1
getSession().getTransaction().begin();
getSession().persist("Personaje",pers1);
getSession().persist(car1);
getSession().getTransaction().commit();
id_car1 = car1.getId();
id_pers1 = pers1.getId();
//REV 2
getSession().getTransaction().begin();
pers1.setAge(50);
getSession().persist("Personaje", pers1);
getSession().persist("Personaje", pers2);
getSession().persist(car2);
getSession().getTransaction().commit();
id_car2 = car2.getId();
id_pers2 = pers2.getId();
}
private void loadDataOnSessionAndAuditReader() {
currentPerson1 = (Person)getSession().get("Personaje", id_pers1);
person2 = (Person)getSession().get("Personaje", id_pers2);
currentCar1 = (Car)getSession().get(Car.class, id_car1);
car1 = getAuditReader().find(Car.class, id_car1, 1);
car2 = getAuditReader().find(Car.class, id_car2, 2);
}
private void checkEntityNames() {
String currentCar1EN = getSession().getEntityName(currentCar1);
String car1EN = getAuditReader().getEntityName(id_car1, 1, car1);
assert (currentCar1EN.equals(car1EN));
}
private void checkEntities() {
person1_1 = car1.getOwner();
Person person2_1 = car2.getOwner();
assert(currentPerson1.getAge() == person1_1.getAge());
assert(person2.getAge() == person2_1.getAge());
}
@Test
public void testObtainEntityNameAssociationWithEntityNameAndNotAuditedMode() {
loadDataOnSessionAndAuditReader();
checkEntities();
checkEntityNames();
}
@Test
public void testObtainEntityNameAssociationWithEntityNameAndNotAuditedModeInNewSession() {
//force a new session and AR
forceNewSession();
loadDataOnSessionAndAuditReader();
checkEntities();
checkEntityNames();
}
}

View File

@ -22,14 +22,16 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.flush;
import java.io.IOException;
import javax.persistence.EntityManager;
import org.hibernate.FlushMode;
import org.hibernate.Session;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.StrTestEntity;
import org.testng.annotations.BeforeClass;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.io.IOException;
/**
* @author Adam Warski (adam at warski dot org)
@ -56,7 +58,7 @@ public abstract class AbstractFlushTest extends AbstractEntityTest {
throw new RuntimeException("Invalid entity manager");
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initFlush() throws IOException {
Session session = getSession(getEntityManager());
session.setFlushMode(getFlushMode());

View File

@ -22,12 +22,13 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.flush;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.FlushMode;
import org.hibernate.envers.test.entities.StrTestEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -39,7 +40,7 @@ public class DoubleFlushAddDel extends AbstractFlushTest {
return FlushMode.MANUAL;
}
@BeforeClass(dependsOnMethods = "initFlush")
@Test
public void initData() {
// Revision 1
EntityManager em = getEntityManager();

View File

@ -22,16 +22,18 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.flush;
import static org.testng.Assert.assertEquals;
import java.util.Arrays;
import java.util.List;
import javax.persistence.EntityManager;
import org.hibernate.FlushMode;
import org.hibernate.envers.RevisionType;
import org.hibernate.envers.query.AuditEntity;
import org.hibernate.envers.test.entities.StrTestEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.*;
/**
* @author Adam Warski (adam at warski dot org)
@ -43,7 +45,7 @@ public class DoubleFlushAddMod extends AbstractFlushTest {
return FlushMode.MANUAL;
}
@BeforeClass(dependsOnMethods = "initFlush")
@Test
public void initData() {
// Revision 1
EntityManager em = getEntityManager();

View File

@ -22,16 +22,18 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.flush;
import static org.testng.Assert.assertEquals;
import java.util.Arrays;
import java.util.List;
import javax.persistence.EntityManager;
import org.hibernate.FlushMode;
import org.hibernate.envers.RevisionType;
import org.hibernate.envers.query.AuditEntity;
import org.hibernate.envers.test.entities.StrTestEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.*;
/**
* @author Adam Warski (adam at warski dot org)
@ -43,7 +45,7 @@ public class DoubleFlushModDel extends AbstractFlushTest {
return FlushMode.MANUAL;
}
@BeforeClass(dependsOnMethods = "initFlush")
@Test
public void initData() {
// Revision 1
EntityManager em = getEntityManager();

View File

@ -22,16 +22,18 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.flush;
import static org.testng.Assert.assertEquals;
import java.util.Arrays;
import java.util.List;
import javax.persistence.EntityManager;
import org.hibernate.FlushMode;
import org.hibernate.envers.RevisionType;
import org.hibernate.envers.query.AuditEntity;
import org.hibernate.envers.test.entities.StrTestEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.*;
/**
* @author Adam Warski (adam at warski dot org)
@ -43,7 +45,7 @@ public class DoubleFlushModMod extends AbstractFlushTest {
return FlushMode.MANUAL;
}
@BeforeClass(dependsOnMethods = "initFlush")
@Test
public void initData() {
// Revision 1
EntityManager em = getEntityManager();

View File

@ -22,16 +22,18 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.flush;
import static org.testng.Assert.assertEquals;
import java.util.Arrays;
import java.util.List;
import javax.persistence.EntityManager;
import org.hibernate.FlushMode;
import org.hibernate.envers.RevisionType;
import org.hibernate.envers.query.AuditEntity;
import org.hibernate.envers.test.entities.StrTestEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.*;
/**
* @author Adam Warski (adam at warski dot org)
@ -43,7 +45,7 @@ public class ManualFlush extends AbstractFlushTest {
return FlushMode.MANUAL;
}
@BeforeClass(dependsOnMethods = "initFlush")
@Test
public void initData() {
// Revision 1
EntityManager em = getEntityManager();

View File

@ -22,13 +22,14 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.hashcode;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -42,7 +43,7 @@ public class ChangingHashcode extends AbstractEntityTest {
cfg.addAnnotatedClass(WikiImage.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
// Revision 1
EntityManager em = getEntityManager();

View File

@ -22,15 +22,16 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.ids;
import java.util.Arrays;
import java.util.Date;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.ids.CompositeDateIdTestEntity;
import org.hibernate.envers.test.entities.ids.DateEmbId;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.Date;
/**
* @author Adam Warski (adam at warski dot org)
@ -42,7 +43,7 @@ public class CompositeDateId extends AbstractEntityTest {
cfg.addAnnotatedClass(CompositeDateIdTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
// Revision 1

View File

@ -22,19 +22,14 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.ids;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.ids.CustomEnum;
import org.hibernate.envers.test.entities.ids.EmbId;
import org.hibernate.envers.test.entities.ids.EmbIdTestEntity;
import org.hibernate.envers.test.entities.ids.EmbIdWithCustomType;
import org.hibernate.envers.test.entities.ids.EmbIdWithCustomTypeTestEntity;
import org.hibernate.envers.test.entities.ids.MulId;
import org.hibernate.envers.test.entities.ids.MulIdTestEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.hibernate.envers.test.entities.ids.*;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -53,7 +48,7 @@ public class CompositeIds extends AbstractEntityTest {
cfg.addAnnotatedClass(EmbIdWithCustomTypeTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
id1 = new EmbId(1, 2);
id2 = new EmbId(10, 20);

View File

@ -22,14 +22,15 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.ids;
import java.util.Arrays;
import java.util.Date;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.ids.DateIdTestEntity;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.Date;
/**
* @author Adam Warski (adam at warski dot org)
@ -41,7 +42,7 @@ public class DateId extends AbstractEntityTest {
cfg.addAnnotatedClass(DateIdTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
// Revision 1

View File

@ -1,12 +1,14 @@
package org.hibernate.envers.test.integration.ids;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.StrTestEntity;
import org.hibernate.envers.test.entities.UnversionedStrTestEntity;
import org.hibernate.envers.test.entities.ids.ManyToOneIdNotAuditedTestEntity;
import org.hibernate.envers.test.entities.ids.ManyToOneNotAuditedEmbId;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
/**
* A test checking that when using Envers it is possible to have non-audited entities that use unsupported

View File

@ -23,12 +23,13 @@
*/
package org.hibernate.envers.test.integration.inheritance.joined;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -41,7 +42,7 @@ public class ChildAuditing extends AbstractEntityTest {
cfg.addAnnotatedClass(ParentEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -23,12 +23,13 @@
*/
package org.hibernate.envers.test.integration.inheritance.joined;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -41,7 +42,7 @@ public class ChildNullAuditing extends AbstractEntityTest {
cfg.addAnnotatedClass(ParentEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -23,12 +23,13 @@
*/
package org.hibernate.envers.test.integration.inheritance.joined;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -41,7 +42,7 @@ public class ParentAuditing extends AbstractEntityTest {
cfg.addAnnotatedClass(ParentEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -23,13 +23,14 @@
*/
package org.hibernate.envers.test.integration.inheritance.joined.childrelation;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -45,7 +46,7 @@ public class ChildReferencing extends AbstractEntityTest {
cfg.addAnnotatedClass(ReferencedEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -23,12 +23,13 @@
*/
package org.hibernate.envers.test.integration.inheritance.joined.emptychild;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -41,7 +42,7 @@ public class EmptyChildAuditing extends AbstractEntityTest {
cfg.addAnnotatedClass(ParentEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -23,13 +23,14 @@
*/
package org.hibernate.envers.test.integration.inheritance.joined.notownedrelation;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -45,7 +46,7 @@ public class NotOwnedBidirectional extends AbstractEntityTest {
cfg.addAnnotatedClass(PersonalContact.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -23,15 +23,16 @@
*/
package org.hibernate.envers.test.integration.inheritance.joined.primarykeyjoin;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.integration.inheritance.joined.ParentEntity;
import org.hibernate.mapping.Column;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Assert;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -44,7 +45,7 @@ public class ChildPrimaryKeyJoinAuditing extends AbstractEntityTest {
cfg.addAnnotatedClass(ParentEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -23,13 +23,14 @@
*/
package org.hibernate.envers.test.integration.inheritance.joined.relation;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -45,7 +46,7 @@ public class PolymorphicCollection extends AbstractEntityTest {
cfg.addAnnotatedClass(ReferencedEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -23,13 +23,14 @@
*/
package org.hibernate.envers.test.integration.inheritance.joined.relation.unidirectional;
import java.util.Arrays;
import java.util.Set;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.Set;
/**
* @author Adam Warski (adam at warski dot org)
@ -45,7 +46,7 @@ public class UnidirectionalDoubleAbstract extends AbstractEntityTest {
cfg.addAnnotatedClass(SetEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,12 +22,13 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.inheritance.single;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -40,7 +41,7 @@ public class ChildAuditing extends AbstractEntityTest {
cfg.addAnnotatedClass(ParentEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,12 +22,13 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.inheritance.single;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -40,7 +41,7 @@ public class ParentAuditing extends AbstractEntityTest {
cfg.addAnnotatedClass(ParentEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,13 +22,14 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.inheritance.single.childrelation;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -44,7 +45,7 @@ public class ChildReferencing extends AbstractEntityTest {
cfg.addAnnotatedClass(ReferencedEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -23,13 +23,14 @@
*/
package org.hibernate.envers.test.integration.inheritance.single.notownedrelation;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -45,7 +46,7 @@ public class NotOwnedBidirectional extends AbstractEntityTest {
cfg.addAnnotatedClass(PersonalContact.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,13 +22,14 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.inheritance.single.relation;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -44,7 +45,7 @@ public class PolymorphicCollection extends AbstractEntityTest {
cfg.addAnnotatedClass(ReferencedEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -23,12 +23,13 @@
*/
package org.hibernate.envers.test.integration.inheritance.tableperclass;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -41,7 +42,7 @@ public class ChildAuditing extends AbstractEntityTest {
cfg.addAnnotatedClass(ParentEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -23,12 +23,13 @@
*/
package org.hibernate.envers.test.integration.inheritance.tableperclass;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -41,7 +42,7 @@ public class ParentAuditing extends AbstractEntityTest {
cfg.addAnnotatedClass(ParentEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -23,13 +23,14 @@
*/
package org.hibernate.envers.test.integration.inheritance.tableperclass.childrelation;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -45,7 +46,7 @@ public class ChildReferencing extends AbstractEntityTest {
cfg.addAnnotatedClass(ReferencedEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -23,13 +23,14 @@
*/
package org.hibernate.envers.test.integration.inheritance.tableperclass.notownedrelation;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -45,7 +46,7 @@ public class NotOwnedBidirectional extends AbstractEntityTest {
cfg.addAnnotatedClass(PersonalContact.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -23,13 +23,14 @@
*/
package org.hibernate.envers.test.integration.inheritance.tableperclass.relation;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -45,7 +46,7 @@ public class PolymorphicCollection extends AbstractEntityTest {
cfg.addAnnotatedClass(ReferencedEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,12 +22,13 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.interfaces.components;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -39,7 +40,7 @@ public class InterfacesComponents extends AbstractEntityTest {
cfg.addAnnotatedClass(ComponentTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
// Revision 1
EntityManager em = getEntityManager();

View File

@ -1,11 +1,12 @@
package org.hibernate.envers.test.integration.interfaces.hbm.allAudited;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.envers.exception.NotAuditedException;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Assert;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Hern<EFBFBD>n Chanfreau
@ -15,7 +16,7 @@ public abstract class AbstractAllAuditedTest extends AbstractEntityTest {
private long ai_id;
private long nai_id;
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -1,10 +1,11 @@
package org.hibernate.envers.test.integration.interfaces.hbm.allAudited.joined;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.integration.interfaces.hbm.allAudited.AbstractAllAuditedTest;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.integration.interfaces.hbm.allAudited.AbstractAllAuditedTest;
import org.testng.annotations.Test;
/**
* @author Hern<EFBFBD>n Chanfreau
@ -19,22 +20,4 @@ public class JoinedAllAuditedTest extends AbstractAllAuditedTest {
e.printStackTrace();
}
}
@Test
@Override
public void testRetrieveAudited() {
super.testRetrieveAudited();
}
@Test
@Override
public void testRetrieveNonAudited() {
super.testRetrieveNonAudited();
}
@Test
@Override
public void testRevisions() {
super.testRevisions();
}
}

View File

@ -1,10 +1,11 @@
package org.hibernate.envers.test.integration.interfaces.hbm.allAudited.subclass;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.integration.interfaces.hbm.allAudited.AbstractAllAuditedTest;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.integration.interfaces.hbm.allAudited.AbstractAllAuditedTest;
import org.testng.annotations.Test;
/**
* @author Hern<EFBFBD>n Chanfreau
@ -19,23 +20,5 @@ public class SubclassAllAuditedTest extends AbstractAllAuditedTest {
e.printStackTrace();
}
}
@Test
@Override
public void testRetrieveAudited() {
super.testRetrieveAudited();
}
@Test
@Override
public void testRetrieveNonAudited() {
super.testRetrieveNonAudited();
}
@Test
@Override
public void testRevisions() {
super.testRevisions();
}
}

View File

@ -1,10 +1,11 @@
package org.hibernate.envers.test.integration.interfaces.hbm.allAudited.union;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.integration.interfaces.hbm.allAudited.AbstractAllAuditedTest;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.integration.interfaces.hbm.allAudited.AbstractAllAuditedTest;
import org.testng.annotations.Test;
/**
* @author Hern<EFBFBD>n Chanfreau
@ -19,22 +20,4 @@ public class UnionAllAuditedTest extends AbstractAllAuditedTest {
e.printStackTrace();
}
}
@Test
@Override
public void testRetrieveAudited() {
super.testRetrieveAudited();
}
@Test
@Override
public void testRetrieveNonAudited() {
super.testRetrieveNonAudited();
}
@Test
@Override
public void testRevisions() {
super.testRevisions();
}
}

View File

@ -1,9 +1,10 @@
package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited;
import javax.persistence.EntityManager;
import org.hibernate.envers.exception.NotAuditedException;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
/**
* @author Hern<EFBFBD>n Chanfreau
@ -15,7 +16,7 @@ public abstract class AbstractPropertiesAuditedTest extends AbstractEntityTest {
private static int NUMERITO = 555;
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -1,10 +1,11 @@
package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.joined;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.AbstractPropertiesAuditedTest;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.AbstractPropertiesAuditedTest;
import org.testng.annotations.Test;
/**
* @author Hern<EFBFBD>n Chanfreau
@ -20,9 +21,4 @@ public class JoinedPropertiesAuditedTest extends AbstractPropertiesAuditedTest {
e.printStackTrace();
}
}
@Test
public void testRetrieveAudited() {
super.testRetrieveAudited();
}
}

View File

@ -1,10 +1,11 @@
package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.subclass;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.AbstractPropertiesAuditedTest;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.AbstractPropertiesAuditedTest;
import org.testng.annotations.Test;
/**
* @author Hern<EFBFBD>n Chanfreau
@ -20,10 +21,5 @@ public class SubclassPropertiesAuditedTest extends AbstractPropertiesAuditedTest
e.printStackTrace();
}
}
@Test
public void testRetrieveAudited() {
super.testRetrieveAudited();
}
}

View File

@ -1,10 +1,11 @@
package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.union;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.AbstractPropertiesAuditedTest;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.AbstractPropertiesAuditedTest;
import org.testng.annotations.Test;
/**
* @author Hern<EFBFBD>n Chanfreau
@ -20,9 +21,4 @@ public class UnionPropertiesAuditedTest extends AbstractPropertiesAuditedTest {
e.printStackTrace();
}
}
@Test
public void testRetrieveAudited() {
super.testRetrieveAudited();
}
}

View File

@ -1,9 +1,10 @@
package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2;
import javax.persistence.EntityManager;
import org.hibernate.envers.exception.NotAuditedException;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
/**
* @author Hern<EFBFBD>n Chanfreau
@ -15,7 +16,7 @@ public abstract class AbstractPropertiesAudited2Test extends AbstractEntityTest
private static int NUMERITO = 555;
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -1,10 +1,11 @@
package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.joined;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.AbstractPropertiesAudited2Test;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.AbstractPropertiesAudited2Test;
import org.testng.annotations.Test;
/**
* @author Hern<EFBFBD>n Chanfreau
@ -19,9 +20,4 @@ public class JoinedPropertiesAudited2Test extends AbstractPropertiesAudited2Test
e.printStackTrace();
}
}
@Test
public void testRetrieveAudited() {
super.testRetrieveAudited();
}
}

View File

@ -1,10 +1,11 @@
package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.subclass;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.AbstractPropertiesAudited2Test;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.AbstractPropertiesAudited2Test;
import org.testng.annotations.Test;
/**
* @author Hern<EFBFBD>n Chanfreau
@ -20,11 +21,5 @@ public class SubclassPropertiesAudited2Test extends AbstractPropertiesAudited2Te
e.printStackTrace();
}
}
@Test
public void testRetrieveAudited() {
super.testRetrieveAudited();
}
}

View File

@ -1,10 +1,11 @@
package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.union;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.AbstractPropertiesAudited2Test;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.AbstractPropertiesAudited2Test;
import org.testng.annotations.Test;
/**
* @author Hern<EFBFBD>n Chanfreau
@ -20,9 +21,4 @@ public class UnionPropertiesAudited2Test extends AbstractPropertiesAudited2Test
e.printStackTrace();
}
}
@Test
public void testRetrieveAudited() {
super.testRetrieveAudited();
}
}

View File

@ -22,12 +22,13 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.interfaces.relation;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -43,7 +44,7 @@ public class InterfacesRelation extends AbstractEntityTest {
cfg.addAnnotatedClass(SetRefIngEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -23,18 +23,14 @@
*/
package org.hibernate.envers.test.integration.jta;
import javax.persistence.EntityManager;
import javax.transaction.TransactionManager;
import org.hibernate.envers.test.EnversTestingJtaBootstrap;
import org.testng.annotations.Test;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.StrTestEntity;
import org.hibernate.envers.test.integration.reventity.ExceptionListenerRevEntity;
import org.junit.Test;
import org.hibernate.testing.jta.TestingJtaBootstrap;
import javax.persistence.EntityManager;
import javax.transaction.TransactionManager;
/**
* Same as {@link org.hibernate.envers.test.integration.reventity.ExceptionListener}, but in a JTA environment.
@ -50,7 +46,7 @@ public class JtaExceptionListener extends AbstractEntityTest {
tm = addJTAConfig(cfg);
}
@Test(expectedExceptions = RuntimeException.class)
@Test(expected = RuntimeException.class)
public void testTransactionRollback() throws Exception {
tm.begin();
@ -64,7 +60,7 @@ public class JtaExceptionListener extends AbstractEntityTest {
tm.commit();
}
@Test(dependsOnMethods = "testTransactionRollback")
@Test
public void testDataNotPersisted() throws Exception {
tm.begin();

View File

@ -1,19 +1,13 @@
package org.hibernate.envers.test.integration.jta;
import javax.persistence.EntityManager;
import javax.transaction.NotSupportedException;
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
import java.util.Arrays;
import org.hibernate.envers.test.EnversTestingJtaBootstrap;
import org.testng.annotations.Test;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.IntTestEntity;
import org.junit.Test;
import org.hibernate.testing.jta.TestingJtaBootstrap;
import javax.persistence.EntityManager;
import javax.transaction.TransactionManager;
import java.util.Arrays;
/**
* Same as {@link org.hibernate.envers.test.integration.basic.Simple}, but in a JTA environment.
@ -53,12 +47,12 @@ public class JtaTransaction extends AbstractEntityTest {
tm.commit();
}
@Test(dependsOnMethods = "initData")
@Test
public void testRevisionsCounts() throws Exception {
assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(IntTestEntity.class, id1));
}
@Test(dependsOnMethods = "initData")
@Test
public void testHistoryOfId1() {
IntTestEntity ver1 = new IntTestEntity(10, id1);
IntTestEntity ver2 = new IntTestEntity(20, id1);

View File

@ -22,17 +22,18 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.manytomany;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.manytomany.ListOwnedEntity;
import org.hibernate.envers.test.entities.manytomany.ListOwningEntity;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
/**
* @author Adam Warski (adam at warski dot org)
@ -49,7 +50,7 @@ public class BasicList extends AbstractEntityTest {
cfg.addAnnotatedClass(ListOwnedEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,17 +22,18 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.manytomany;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.manytomany.MapOwnedEntity;
import org.hibernate.envers.test.entities.manytomany.MapOwningEntity;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
/**
* @author Adam Warski (adam at warski dot org)
@ -49,7 +50,7 @@ public class BasicMap extends AbstractEntityTest {
cfg.addAnnotatedClass(MapOwnedEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,17 +22,18 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.manytomany;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.manytomany.SetOwnedEntity;
import org.hibernate.envers.test.entities.manytomany.SetOwningEntity;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
/**
* @author Adam Warski (adam at warski dot org)
@ -49,7 +50,7 @@ public class BasicSet extends AbstractEntityTest {
cfg.addAnnotatedClass(SetOwnedEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,16 +22,18 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.manytomany;
import static org.testng.Assert.assertEquals;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.IntNoAutoIdTestEntity;
import org.hibernate.envers.test.entities.manytomany.WhereJoinTableEntity;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
import static org.junit.Assert.*;
/**
* @author Adam Warski (adam at warski dot org)
@ -50,7 +52,7 @@ public class BasicWhereJoinTable extends AbstractEntityTest {
cfg.addAnnotatedClass(IntNoAutoIdTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,16 +22,18 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.manytomany.biowned;
import static org.testng.Assert.assertEquals;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.manytomany.biowned.ListBiowning1Entity;
import org.hibernate.envers.test.entities.manytomany.biowned.ListBiowning2Entity;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
import static org.junit.Assert.*;
/**
* @author Adam Warski (adam at warski dot org)
@ -47,7 +49,7 @@ public class BasicBiowned extends AbstractEntityTest {
cfg.addAnnotatedClass(ListBiowning2Entity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();
@ -130,7 +132,7 @@ public class BasicBiowned extends AbstractEntityTest {
o2_2_id = o2_2.getId();
}
@Test(enabled = true)
@Test
public void testRevisionsCounts() {
// Although it would seem that when modifying references both entities should be marked as modified, because
// ownly the owning side is notified (because of the bi-owning mapping), a revision is created only for
@ -143,7 +145,7 @@ public class BasicBiowned extends AbstractEntityTest {
assertEquals(Arrays.asList(1, 4), getAuditReader().getRevisions(ListBiowning2Entity.class, o2_2_id));
}
@Test(enabled = true)
@Test
public void testHistoryOfO1_1() {
ListBiowning2Entity o2_1 = getEntityManager().find(ListBiowning2Entity.class, o2_1_id);
ListBiowning2Entity o2_2 = getEntityManager().find(ListBiowning2Entity.class, o2_2_id);
@ -161,7 +163,7 @@ public class BasicBiowned extends AbstractEntityTest {
assert TestTools.checkList(rev5.getReferences(), o2_2);
}
@Test(enabled = true)
@Test
public void testHistoryOfO1_2() {
ListBiowning2Entity o2_1 = getEntityManager().find(ListBiowning2Entity.class, o2_1_id);
ListBiowning2Entity o2_2 = getEntityManager().find(ListBiowning2Entity.class, o2_2_id);
@ -180,7 +182,7 @@ public class BasicBiowned extends AbstractEntityTest {
assert TestTools.checkList(rev5.getReferences(), o2_2);
}
@Test(enabled = true)
@Test
public void testHistoryOfO2_1() {
ListBiowning1Entity o1_1 = getEntityManager().find(ListBiowning1Entity.class, o1_1_id);
ListBiowning1Entity o1_2 = getEntityManager().find(ListBiowning1Entity.class, o1_2_id);
@ -198,7 +200,7 @@ public class BasicBiowned extends AbstractEntityTest {
assert TestTools.checkList(rev5.getReferences());
}
@Test(enabled = true)
@Test
public void testHistoryOfO2_2() {
ListBiowning1Entity o1_1 = getEntityManager().find(ListBiowning1Entity.class, o1_1_id);
ListBiowning1Entity o1_2 = getEntityManager().find(ListBiowning1Entity.class, o1_2_id);

View File

@ -1,13 +1,14 @@
package org.hibernate.envers.test.integration.manytomany.inverseToSuperclass;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* @author Hern<EFBFBD>n Chanfreau
@ -29,7 +30,7 @@ public class ManyToManyInverseToSuperclassTest extends AbstractEntityTest {
}
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,8 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.manytomany.sametable;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.Session;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
@ -31,8 +30,10 @@ import org.hibernate.envers.test.entities.manytomany.sametable.Child1Entity;
import org.hibernate.envers.test.entities.manytomany.sametable.Child2Entity;
import org.hibernate.envers.test.entities.manytomany.sametable.ParentEntity;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* Test which checks that auditing entities which contain multiple mappings to same tables work.
@ -52,7 +53,7 @@ public class BasicSametable extends AbstractEntityTest {
cfg.addAnnotatedClass(Child2Entity.class);
}
@BeforeClass(enabled = true, dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();
@ -160,7 +161,7 @@ public class BasicSametable extends AbstractEntityTest {
c2_2_id = c2_2.getId();
}
@Test(enabled = true)
@Test
public void testRevisionsCounts() {
assert Arrays.asList(1, 2, 3, 4).equals(getAuditReader().getRevisions(ParentEntity.class, p1_id));
assert Arrays.asList(1, 2, 3, 4).equals(getAuditReader().getRevisions(ParentEntity.class, p2_id));
@ -172,7 +173,7 @@ public class BasicSametable extends AbstractEntityTest {
assert Arrays.asList(1, 5).equals(getAuditReader().getRevisions(Child1Entity.class, c2_2_id));
}
@Test(enabled = true)
@Test
public void testHistoryOfParent1() {
Child1Entity c1_1 = getEntityManager().find(Child1Entity.class, c1_1_id);
Child1Entity c1_2 = getEntityManager().find(Child1Entity.class, c1_2_id);
@ -197,7 +198,7 @@ public class BasicSametable extends AbstractEntityTest {
assert TestTools.checkList(rev5.getChildren2(), c2_2);
}
@Test(enabled = true)
@Test
public void testHistoryOfParent2() {
Child1Entity c1_1 = getEntityManager().find(Child1Entity.class, c1_1_id);
Child2Entity c2_1 = getEntityManager().find(Child2Entity.class, c2_1_id);
@ -222,7 +223,7 @@ public class BasicSametable extends AbstractEntityTest {
assert TestTools.checkList(rev5.getChildren2(), c2_1);
}
@Test(enabled = true)
@Test
public void testHistoryOfChild1_1() {
ParentEntity p1 = getEntityManager().find(ParentEntity.class, p1_id);
ParentEntity p2 = getEntityManager().find(ParentEntity.class, p2_id);
@ -240,7 +241,8 @@ public class BasicSametable extends AbstractEntityTest {
assert TestTools.checkList(rev5.getParents(), p2);
}
@Test(enabled = false)
// TODO: was disabled?
@Test
public void testHistoryOfChild1_2() {
ParentEntity p1 = getEntityManager().find(ParentEntity.class, p1_id);
@ -257,7 +259,7 @@ public class BasicSametable extends AbstractEntityTest {
assert TestTools.checkList(rev5.getParents());
}
@Test(enabled = true)
@Test
public void testHistoryOfChild2_1() {
ParentEntity p2 = getEntityManager().find(ParentEntity.class, p2_id);
@ -274,7 +276,7 @@ public class BasicSametable extends AbstractEntityTest {
assert TestTools.checkList(rev5.getParents(), p2);
}
@Test(enabled = true)
@Test
public void testHistoryOfChild2_2() {
ParentEntity p1 = getEntityManager().find(ParentEntity.class, p1_id);
ParentEntity p2 = getEntityManager().find(ParentEntity.class, p2_id);

View File

@ -22,15 +22,16 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.manytomany.ternary;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.IntTestEntity;
import org.hibernate.envers.test.entities.StrTestEntity;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
/**
* @author Adam Warski (adam at warski dot org)
@ -51,7 +52,7 @@ public class TernaryMap extends AbstractEntityTest {
cfg.addAnnotatedClass(IntTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,16 +22,19 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.manytomany.ternary;
import static org.testng.Assert.assertEquals;
import java.util.Arrays;
import java.util.HashMap;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.IntTestEntity;
import org.hibernate.envers.test.entities.StrTestEntity;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.HashMap;
import static org.junit.Assert.*;
/**
* @author Adam Warski (adam at warski dot org)
@ -115,7 +118,7 @@ public class TernaryMapFlush extends AbstractEntityTest {
int2_id = int2.getId();
}
@Test(dependsOnMethods = "createData")
@Test
public void testRevisionsCounts() {
assertEquals(Arrays.asList(1, 2, 3), getAuditReader().getRevisions(TernaryMapEntity.class, map1_id));
assertEquals(Arrays.asList(1), getAuditReader().getRevisions(StrTestEntity.class, str1_id));
@ -124,7 +127,7 @@ public class TernaryMapFlush extends AbstractEntityTest {
assertEquals(Arrays.asList(1) ,getAuditReader().getRevisions(IntTestEntity.class, int2_id));
}
@Test(dependsOnMethods = "createData")
@Test
public void testHistoryOfMap1() {
StrTestEntity str1 = getEntityManager().find(StrTestEntity.class, str1_id);
StrTestEntity str2 = getEntityManager().find(StrTestEntity.class, str2_id);

View File

@ -22,17 +22,18 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.manytomany.unidirectional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.StrTestEntity;
import org.hibernate.envers.test.entities.manytomany.unidirectional.ListUniEntity;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
/**
* @author Adam Warski (adam at warski dot org)
@ -49,7 +50,7 @@ public class BasicUniList extends AbstractEntityTest {
cfg.addAnnotatedClass(StrTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

View File

@ -22,16 +22,17 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.integration.manytomany.unidirectional;
import java.util.Arrays;
import java.util.HashMap;
import javax.persistence.EntityManager;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.StrTestEntity;
import org.hibernate.envers.test.entities.manytomany.unidirectional.MapUniEntity;
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.Test;
import javax.persistence.EntityManager;
import java.util.Arrays;
import java.util.HashMap;
/**
* @author Adam Warski (adam at warski dot org)
@ -47,7 +48,7 @@ public class BasicUniMap extends AbstractEntityTest {
cfg.addAnnotatedClass(MapUniEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
@Test
public void initData() {
EntityManager em = getEntityManager();

Some files were not shown because too many files have changed in this diff Show More