From 74e5c3150d0af1465a918039b7b139b5e28e5b5e Mon Sep 17 00:00:00 2001 From: Strong Liu Date: Tue, 27 Mar 2012 17:47:10 +0800 Subject: [PATCH] HHH-7187 configurations should be defined in addConfigurationProperties method, instead configure --- .../flush/ManualFlushAutoCommitDisabled.java | 14 +++++++++----- .../UnversionedOptimisticLockingField.java | 9 ++++++++- .../properties/VersionsProperties.java | 17 ++++++++++++----- .../integration/query/StoreDeletedData.java | 11 +++++++++-- .../GloballyConfiguredRevListenerTest.java | 11 +++++++++-- .../AnnotatedTrackingEntitiesTest.java | 10 +++++++++- .../DefaultTrackingEntitiesTest.java | 11 +++++++++-- .../ExtendedRevisionEntityTest.java | 12 ++++++++++-- .../TrackingEntitiesMultipleChangesTest.java | 10 +++++++++- .../ValidityAuditStrategyManyToManyTest.java | 12 ++++++++---- ...dityAuditStrategyRevEndTestCustomRevEnt.java | 13 ++++++++++--- .../ValidityAuditStrategyRevEndTsTest.java | 13 ++++++++++--- .../integration/tools/SchemaExportTest.java | 15 +++++++++++---- 13 files changed, 123 insertions(+), 35 deletions(-) diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/flush/ManualFlushAutoCommitDisabled.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/flush/ManualFlushAutoCommitDisabled.java index 579bcf015d..49118a7568 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/flush/ManualFlushAutoCommitDisabled.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/flush/ManualFlushAutoCommitDisabled.java @@ -1,5 +1,8 @@ package org.hibernate.envers.test.integration.flush; +import java.util.Properties; + +import org.hibernate.FlushMode; import org.hibernate.ejb.Ejb3Configuration; import org.hibernate.testing.TestForIssue; @@ -8,9 +11,10 @@ import org.hibernate.testing.TestForIssue; */ @TestForIssue(jiraKey = "HHH-7017") public class ManualFlushAutoCommitDisabled extends ManualFlush { - @Override - public void configure(Ejb3Configuration cfg) { - super.configure(cfg); - cfg.setProperty("hibernate.connection.autocommit", "false"); - } + + @Override + public void addConfigurationProperties(Properties configuration) { + super.addConfigurationProperties( configuration ); + configuration.setProperty("hibernate.connection.autocommit", "false"); + } } diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/properties/UnversionedOptimisticLockingField.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/properties/UnversionedOptimisticLockingField.java index 0771faf401..6cf599bd51 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/properties/UnversionedOptimisticLockingField.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/properties/UnversionedOptimisticLockingField.java @@ -25,6 +25,7 @@ package org.hibernate.envers.test.integration.properties; import java.util.Arrays; import java.util.Iterator; +import java.util.Properties; import javax.persistence.EntityManager; import org.junit.Test; @@ -44,7 +45,13 @@ public class UnversionedOptimisticLockingField extends AbstractEntityTest { public void configure(Ejb3Configuration cfg) { cfg.addAnnotatedClass(UnversionedOptimisticLockingFieldEntity.class); - cfg.setProperty("org.hibernate.envers.doNotAuditOptimisticLockingField", "true"); + } + + @Override + public void addConfigurationProperties(Properties configuration) { + super.addConfigurationProperties( configuration ); + configuration.setProperty("org.hibernate.envers.doNotAuditOptimisticLockingField", "true"); + } @Test diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/properties/VersionsProperties.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/properties/VersionsProperties.java index 942e828a0a..fcb6214c3d 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/properties/VersionsProperties.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/properties/VersionsProperties.java @@ -24,6 +24,7 @@ package org.hibernate.envers.test.integration.properties; import java.util.Arrays; +import java.util.Properties; import javax.persistence.EntityManager; import org.junit.Test; @@ -41,13 +42,19 @@ public class VersionsProperties extends AbstractEntityTest { public void configure(Ejb3Configuration cfg) { cfg.addAnnotatedClass(PropertiesTestEntity.class); - cfg.setProperty("org.hibernate.envers.auditTablePrefix", "VP_"); - cfg.setProperty("org.hibernate.envers.auditTableSuffix", "_VS"); - cfg.setProperty("org.hibernate.envers.revisionFieldName", "ver_rev"); - cfg.setProperty("org.hibernate.envers.revisionTypeFieldName", "ver_rev_type"); + } - @Test + @Override + public void addConfigurationProperties(Properties configuration) { + super.addConfigurationProperties( configuration ); + configuration.setProperty("org.hibernate.envers.auditTablePrefix", "VP_"); + configuration.setProperty("org.hibernate.envers.auditTableSuffix", "_VS"); + configuration.setProperty("org.hibernate.envers.revisionFieldName", "ver_rev"); + configuration.setProperty("org.hibernate.envers.revisionTypeFieldName", "ver_rev_type"); + } + + @Test @Priority(10) public void initData() { EntityManager em = getEntityManager(); diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/query/StoreDeletedData.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/query/StoreDeletedData.java index e66df54b00..58d17671f5 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/query/StoreDeletedData.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/query/StoreDeletedData.java @@ -24,6 +24,7 @@ package org.hibernate.envers.test.integration.query; import java.util.List; +import java.util.Properties; import javax.persistence.EntityManager; import org.junit.Test; @@ -44,10 +45,16 @@ public class StoreDeletedData extends AbstractEntityTest { public void configure(Ejb3Configuration cfg) { cfg.addAnnotatedClass(StrIntTestEntity.class); - cfg.setProperty("org.hibernate.envers.storeDataAtDelete", "true"); + } - @Test + @Override + public void addConfigurationProperties(Properties configuration) { + super.addConfigurationProperties( configuration ); + configuration.setProperty("org.hibernate.envers.storeDataAtDelete", "true"); + } + + @Test @Priority(10) public void initData() { // Revision 1 diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/GloballyConfiguredRevListenerTest.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/GloballyConfiguredRevListenerTest.java index 7abc323b42..f5f16d6db6 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/GloballyConfiguredRevListenerTest.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/GloballyConfiguredRevListenerTest.java @@ -1,5 +1,6 @@ package org.hibernate.envers.test.integration.reventity; +import java.util.Properties; import javax.persistence.EntityManager; import org.junit.Assert; @@ -18,10 +19,16 @@ import org.hibernate.testing.TestForIssue; public class GloballyConfiguredRevListenerTest extends AbstractEntityTest { public void configure(Ejb3Configuration cfg) { cfg.addAnnotatedClass(StrTestEntity.class); - cfg.setProperty("org.hibernate.envers.revision_listener", "org.hibernate.envers.test.integration.reventity.CountingRevisionListener"); } - @Test + @Override + public void addConfigurationProperties(Properties configuration) { + super.addConfigurationProperties( configuration ); + configuration.setProperty("org.hibernate.envers.revision_listener", "org.hibernate.envers.test.integration.reventity.CountingRevisionListener"); + + } + + @Test @Priority(10) public void initData() { EntityManager em = getEntityManager(); diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/trackmodifiedentities/AnnotatedTrackingEntitiesTest.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/trackmodifiedentities/AnnotatedTrackingEntitiesTest.java index 3bbbec2fef..ce48475df9 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/trackmodifiedentities/AnnotatedTrackingEntitiesTest.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/trackmodifiedentities/AnnotatedTrackingEntitiesTest.java @@ -1,5 +1,7 @@ package org.hibernate.envers.test.integration.reventity.trackmodifiedentities; +import java.util.Properties; + import org.hibernate.ejb.Ejb3Configuration; import org.hibernate.envers.ModifiedEntityNames; import org.hibernate.envers.test.entities.reventity.trackmodifiedentities.AnnotatedTrackingRevisionEntity; @@ -13,6 +15,12 @@ public class AnnotatedTrackingEntitiesTest extends DefaultTrackingEntitiesTest { public void configure(Ejb3Configuration cfg) { super.configure(cfg); cfg.addAnnotatedClass(AnnotatedTrackingRevisionEntity.class); - cfg.setProperty("org.hibernate.envers.track_entities_changed_in_revision", "false"); + } + + @Override + public void addConfigurationProperties(Properties configuration) { + super.addConfigurationProperties( configuration ); + configuration.setProperty("org.hibernate.envers.track_entities_changed_in_revision", "false"); + } } diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/trackmodifiedentities/DefaultTrackingEntitiesTest.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/trackmodifiedentities/DefaultTrackingEntitiesTest.java index cfbba0ead4..ad840ce1d3 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/trackmodifiedentities/DefaultTrackingEntitiesTest.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/trackmodifiedentities/DefaultTrackingEntitiesTest.java @@ -3,6 +3,7 @@ package org.hibernate.envers.test.integration.reventity.trackmodifiedentities; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Properties; import javax.persistence.EntityManager; import org.junit.Test; @@ -31,12 +32,18 @@ public class DefaultTrackingEntitiesTest extends AbstractEntityTest { @Override public void configure(Ejb3Configuration cfg) { - cfg.setProperty("org.hibernate.envers.track_entities_changed_in_revision", "true"); cfg.addAnnotatedClass(StrTestEntity.class); cfg.addAnnotatedClass(StrIntTestEntity.class); } - @Test + @Override + public void addConfigurationProperties(Properties configuration) { + super.addConfigurationProperties( configuration ); + configuration.setProperty("org.hibernate.envers.track_entities_changed_in_revision", "true"); + + } + + @Test @Priority(10) public void initData() { EntityManager em = getEntityManager(); diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/trackmodifiedentities/ExtendedRevisionEntityTest.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/trackmodifiedentities/ExtendedRevisionEntityTest.java index bc1e8e9e92..3baac66d08 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/trackmodifiedentities/ExtendedRevisionEntityTest.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/trackmodifiedentities/ExtendedRevisionEntityTest.java @@ -1,5 +1,7 @@ package org.hibernate.envers.test.integration.reventity.trackmodifiedentities; +import java.util.Properties; + import org.junit.Test; import org.hibernate.ejb.Ejb3Configuration; @@ -16,10 +18,16 @@ public class ExtendedRevisionEntityTest extends DefaultTrackingEntitiesTest { public void configure(Ejb3Configuration cfg) { super.configure(cfg); cfg.addAnnotatedClass(ExtendedRevisionEntity.class); - cfg.setProperty("org.hibernate.envers.track_entities_changed_in_revision", "false"); } - @Test + @Override + public void addConfigurationProperties(Properties configuration) { + super.addConfigurationProperties( configuration ); + configuration.setProperty("org.hibernate.envers.track_entities_changed_in_revision", "false"); + + } + + @Test public void testCommentPropertyValue() { ExtendedRevisionEntity ere = getAuditReader().findRevision(ExtendedRevisionEntity.class, 1); diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/trackmodifiedentities/TrackingEntitiesMultipleChangesTest.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/trackmodifiedentities/TrackingEntitiesMultipleChangesTest.java index 4c2d73b445..e84186a06c 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/trackmodifiedentities/TrackingEntitiesMultipleChangesTest.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/trackmodifiedentities/TrackingEntitiesMultipleChangesTest.java @@ -1,6 +1,7 @@ package org.hibernate.envers.test.integration.reventity.trackmodifiedentities; import java.util.Arrays; +import java.util.Properties; import javax.persistence.EntityManager; import org.junit.Test; @@ -24,7 +25,14 @@ public class TrackingEntitiesMultipleChangesTest extends AbstractEntityTest { cfg.addAnnotatedClass(StrTestEntity.class); } - @Test + @Override + public void addConfigurationProperties(Properties configuration) { + super.addConfigurationProperties( configuration ); + configuration.setProperty("org.hibernate.envers.track_entities_changed_in_revision", "true"); + + } + + @Test @Priority(10) public void initData() { EntityManager em = getEntityManager(); diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyManyToManyTest.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyManyToManyTest.java index 06b4007482..6a66091c52 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyManyToManyTest.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyManyToManyTest.java @@ -2,6 +2,7 @@ package org.hibernate.envers.test.integration.strategy; import java.util.Arrays; import java.util.HashSet; +import java.util.Properties; import javax.persistence.EntityManager; import org.junit.Test; @@ -33,12 +34,15 @@ public class ValidityAuditStrategyManyToManyTest extends AbstractEntityTest { public void configure(Ejb3Configuration cfg) { cfg.addAnnotatedClass(SetOwningEntity.class); cfg.addAnnotatedClass(SetOwnedEntity.class); - - cfg.setProperty("org.hibernate.envers.audit_strategy", - "org.hibernate.envers.strategy.ValidityAuditStrategy"); } - @Test + @Override + public void addConfigurationProperties(Properties configuration) { + configuration.setProperty("org.hibernate.envers.audit_strategy", + "org.hibernate.envers.strategy.ValidityAuditStrategy"); + } + + @Test @Priority(10) public void initData() { final EntityManager em = getEntityManager(); diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyRevEndTestCustomRevEnt.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyRevEndTestCustomRevEnt.java index 1717b16469..82831a01d8 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyRevEndTestCustomRevEnt.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyRevEndTestCustomRevEnt.java @@ -28,6 +28,7 @@ import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.Set; import javax.persistence.EntityManager; import javax.persistence.Query; @@ -68,17 +69,23 @@ public class ValidityAuditStrategyRevEndTestCustomRevEnt extends AbstractEntityT cfg.addAnnotatedClass(Child1Entity.class); cfg.addAnnotatedClass(Child2Entity.class); cfg.addAnnotatedClass(CustomDateRevEntity.class); + } - cfg.setProperty("org.hibernate.envers.audit_strategy", + @Override + public void addConfigurationProperties(Properties configuration) { + super.addConfigurationProperties( configuration ); + + configuration.setProperty("org.hibernate.envers.audit_strategy", "org.hibernate.envers.strategy.ValidityAuditStrategy"); - cfg + configuration .setProperty( "org.hibernate.envers.audit_strategy_validity_store_revend_timestamp", "true"); - cfg + configuration .setProperty( "org.hibernate.envers.audit_strategy_validity_revend_timestamp_field_name", revendTimestampColumName); + } @Test diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyRevEndTsTest.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyRevEndTsTest.java index 8005545ccc..e62e088f70 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyRevEndTsTest.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyRevEndTsTest.java @@ -28,6 +28,7 @@ import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.Set; import javax.persistence.EntityManager; import javax.persistence.Query; @@ -69,13 +70,19 @@ public class ValidityAuditStrategyRevEndTsTest extends AbstractEntityTest { cfg.addAnnotatedClass(Child1Entity.class); cfg.addAnnotatedClass(Child2Entity.class); - cfg.setProperty("org.hibernate.envers.audit_strategy", + } + + @Override + public void addConfigurationProperties(Properties configuration) { + super.addConfigurationProperties( configuration ); + + configuration.setProperty("org.hibernate.envers.audit_strategy", "org.hibernate.envers.strategy.ValidityAuditStrategy"); - cfg + configuration .setProperty( "org.hibernate.envers.audit_strategy_validity_store_revend_timestamp", "true"); - cfg + configuration .setProperty( "org.hibernate.envers.audit_strategy_validity_revend_timestamp_field_name", revendTimestampColumName); diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/tools/SchemaExportTest.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/tools/SchemaExportTest.java index 1422ac9d92..cc613ecf41 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/tools/SchemaExportTest.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/tools/SchemaExportTest.java @@ -26,14 +26,15 @@ public class SchemaExportTest extends AbstractSessionTest { protected void initMappings() throws MappingException, URISyntaxException { config.addAnnotatedClass(StrTestEntity.class); // Disable schema auto generation. - config.setProperty(Environment.HBM2DDL_AUTO, ""); } - + protected boolean createSchema() { + return false; + } @Test @Priority(10) public void testSchemaCreation() { // Generate complete schema. - new EnversSchemaGenerator(config).export().create(true, true); + new EnversSchemaGenerator(config).export().create( true, true ); // Populate database with test data. Session session = getSession(); @@ -45,7 +46,13 @@ public class SchemaExportTest extends AbstractSessionTest { id = entity.getId(); } - @Test + @Override + public void closeSessionFactory() { + new EnversSchemaGenerator(config).export().drop( true, true ); + super.closeSessionFactory(); + } + + @Test public void testAuditDataRetrieval() { Assert.assertEquals(Arrays.asList(1), getAuditReader().getRevisions(StrTestEntity.class, id)); Assert.assertEquals(new StrTestEntity("data", id), getAuditReader().find(StrTestEntity.class, id, 1));