HHH-11851 - Fix for native envers test cases to execute against validity and default audit strategies.
This commit is contained in:
parent
c42df6a11b
commit
0d5f9c16ff
|
@ -66,6 +66,10 @@ public abstract class BaseEnversFunctionalTestCase extends BaseNonConfigCoreFunc
|
||||||
super.addSettings( settings );
|
super.addSettings( settings );
|
||||||
|
|
||||||
settings.put( EnversSettings.USE_REVISION_ENTITY_WITH_NATIVE_ID, "false" );
|
settings.put( EnversSettings.USE_REVISION_ENTITY_WITH_NATIVE_ID, "false" );
|
||||||
|
|
||||||
|
if ( getAuditStrategy() != null ) {
|
||||||
|
settings.put( EnversSettings.AUDIT_STRATEGY, getAuditStrategy() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,30 +6,24 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.envers.test.integration.customtype;
|
package org.hibernate.envers.test.integration.customtype;
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
|
||||||
import org.hibernate.envers.test.BaseEnversFunctionalTestCase;
|
import org.hibernate.envers.test.BaseEnversFunctionalTestCase;
|
||||||
import org.hibernate.envers.test.Priority;
|
import org.hibernate.envers.test.Priority;
|
||||||
import org.hibernate.envers.test.entities.customtype.UnspecifiedEnumTypeEntity;
|
import org.hibernate.envers.test.entities.customtype.UnspecifiedEnumTypeEntity;
|
||||||
|
|
||||||
import org.hibernate.jdbc.Work;
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
|
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-7780")
|
@TestForIssue(jiraKey = "HHH-7780")
|
||||||
@RequiresDialect(value = H2Dialect.class)
|
|
||||||
public class UnspecifiedEnumTypeTest extends BaseEnversFunctionalTestCase {
|
public class UnspecifiedEnumTypeTest extends BaseEnversFunctionalTestCase {
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
|
||||||
|
@ -42,60 +36,8 @@ public class UnspecifiedEnumTypeTest extends BaseEnversFunctionalTestCase {
|
||||||
protected void addSettings(Map settings) {
|
protected void addSettings(Map settings) {
|
||||||
super.addSettings( settings );
|
super.addSettings( settings );
|
||||||
|
|
||||||
settings.put( Environment.HBM2DDL_AUTO, "" );
|
settings.put( AvailableSettings.SHOW_SQL, "true" );
|
||||||
}
|
settings.put( AvailableSettings.FORMAT_SQL, "true" );
|
||||||
|
|
||||||
@Test
|
|
||||||
@Priority(10)
|
|
||||||
public void prepareSchema() {
|
|
||||||
Session session = openSession();
|
|
||||||
dropSchema( session );
|
|
||||||
createSchema( session );
|
|
||||||
session.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Priority(1)
|
|
||||||
public void dropSchema() {
|
|
||||||
dropSchema( getSession() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dropSchema(Session session) {
|
|
||||||
executeUpdateSafety( session, "drop table ENUM_ENTITY if exists" );
|
|
||||||
executeUpdateSafety( session, "drop table ENUM_ENTITY_AUD if exists" );
|
|
||||||
executeUpdateSafety( session, "drop table REVINFO if exists" );
|
|
||||||
executeUpdateSafety( session, "drop sequence REVISION_GENERATOR if exists" );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createSchema(Session session) {
|
|
||||||
executeUpdateSafety(
|
|
||||||
session,
|
|
||||||
"create table ENUM_ENTITY (ID bigint not null, enum1 integer, enum2 integer, primary key (ID))"
|
|
||||||
);
|
|
||||||
executeUpdateSafety(
|
|
||||||
session,
|
|
||||||
"create table ENUM_ENTITY_AUD (ID bigint not null, REV integer not null, REVTYPE tinyint, enum1 integer, enum2 integer, primary key (ID, REV))"
|
|
||||||
);
|
|
||||||
executeUpdateSafety(
|
|
||||||
session,
|
|
||||||
"create table REVINFO (REV integer not null, REVTSTMP bigint, primary key (REV))"
|
|
||||||
);
|
|
||||||
executeUpdateSafety(
|
|
||||||
session,
|
|
||||||
"alter table ENUM_ENTITY_AUD add constraint FK_AUD_REV foreign key (REV) references REVINFO"
|
|
||||||
);
|
|
||||||
executeUpdateSafety( session, "create sequence REVISION_GENERATOR start with 1 increment by 1" );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void executeUpdateSafety(Session session, String query) {
|
|
||||||
session.doWork(
|
|
||||||
new Work() {
|
|
||||||
@Override
|
|
||||||
public void execute(Connection connection) throws SQLException {
|
|
||||||
connection.createStatement().execute( query );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -158,7 +100,10 @@ public class UnspecifiedEnumTypeTest extends BaseEnversFunctionalTestCase {
|
||||||
@Priority(6)
|
@Priority(6)
|
||||||
public void testEnumRepresentation() {
|
public void testEnumRepresentation() {
|
||||||
Session session = getSession();
|
Session session = getSession();
|
||||||
List<Object[]> values = session.createSQLQuery( "SELECT enum1, enum2 FROM enum_entity_aud ORDER BY rev ASC" )
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<Object[]> values = session
|
||||||
|
.createSQLQuery( "SELECT enum1, enum2 FROM enum_entity_aud ORDER BY rev ASC" )
|
||||||
.list();
|
.list();
|
||||||
session.close();
|
session.close();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue