From 9286f9147b06eb64d6089b36b297578f8be96ec7 Mon Sep 17 00:00:00 2001 From: Martin Simka Date: Thu, 19 Jul 2018 15:39:02 +0200 Subject: [PATCH] HHH-12833 Fix UniqueConstraintDropTest with DB2 --- .../uniqueconstraint/UniqueConstraintDropTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/uniqueconstraint/UniqueConstraintDropTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/uniqueconstraint/UniqueConstraintDropTest.java index 380e4968ee..44507f5271 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/uniqueconstraint/UniqueConstraintDropTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/uniqueconstraint/UniqueConstraintDropTest.java @@ -20,6 +20,7 @@ import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.cfg.Environment; +import org.hibernate.dialect.DB2Dialect; import org.hibernate.dialect.Dialect; import org.hibernate.dialect.MySQLDialect; import org.hibernate.engine.config.spi.ConfigurationService; @@ -111,6 +112,9 @@ public class UniqueConstraintDropTest { is( true ) ); } + else if ( getDialect() instanceof DB2Dialect ) { + checkDB2DropIndex( "test_entity_item", "item" ); + } else { assertThat( "The test_entity_item table unique constraint has not been dropped", @@ -154,6 +158,12 @@ public class UniqueConstraintDropTest { return isMatching( matches, regex ); } + private boolean checkDB2DropIndex(String tableName, String columnName) throws IOException { + boolean matches = false; + String regex = "drop index " + tableName + ".uk_(.)*"; + return isMatching( matches, regex ); + } + private boolean isMatching(boolean matches, String regex) throws IOException { final String fileContent = new String( Files.readAllBytes( output.toPath() ) ).toLowerCase(); final String[] split = fileContent.split( System.lineSeparator() );