Skip to content

Commit

Permalink
HHH-12833 Fix UniqueConstraintDropTest with DB2
Browse files Browse the repository at this point in the history
  • Loading branch information
simkam authored and gsmet committed Jul 19, 2018
1 parent ad5f96c commit 9286f91
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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;
Expand Down Expand Up @@ -111,6 +112,9 @@ public void testUniqueConstraintIsGenerated() throws Exception {
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",
Expand Down Expand Up @@ -154,6 +158,12 @@ private boolean checkDropIndex(String tableName, String columnName) throws IOExc
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() );
Expand Down

0 comments on commit 9286f91

Please sign in to comment.