HHH-7187 configurations should be defined in addConfigurationProperties method, instead configure

This commit is contained in:
Strong Liu 2012-03-27 17:47:10 +08:00
parent b2c4585921
commit 74e5c3150d
13 changed files with 123 additions and 35 deletions

View File

@ -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");
}
}

View File

@ -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

View File

@ -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();

View File

@ -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

View File

@ -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();

View File

@ -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");
}
}

View File

@ -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();

View File

@ -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);

View File

@ -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();

View File

@ -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();

View File

@ -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

View File

@ -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);

View File

@ -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));