diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/schemagen/SchemaDatabaseFileGenerationFailureTest.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/schemagen/SchemaDatabaseFileGenerationFailureTest.java index 1091330560..037d87a913 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/schemagen/SchemaDatabaseFileGenerationFailureTest.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/schemagen/SchemaDatabaseFileGenerationFailureTest.java @@ -13,6 +13,7 @@ import java.sql.Statement; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; +import java.util.regex.Pattern; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.PersistenceException; @@ -37,7 +38,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.when; /** @@ -62,7 +62,7 @@ public class SchemaDatabaseFileGenerationFailureTest { @Test @TestForIssue(jiraKey = "HHH-12192") - public void testGenerateSchemaDoesNotProduceTheSameStatementTwice() throws Exception { + public void testErrorMessageContainsTheFailingDDLCommand() { try { entityManagerFactoryBuilder.generateSchema(); fail( "Should haave thrown IOException" ); @@ -75,7 +75,9 @@ public class SchemaDatabaseFileGenerationFailureTest { CommandAcceptanceException commandAcceptanceException = (CommandAcceptanceException) e.getCause() .getCause(); - assertTrue( commandAcceptanceException.getMessage().contains( "drop table test_entity if exists" ) ); + boolean ddlCommandFound = Pattern.compile( "drop table( if exists)? test_entity( if exists)?" ) + .matcher( commandAcceptanceException.getMessage().toLowerCase() ).find(); + assertTrue( "The Exception Message does not contain the DDL command causing the failure", ddlCommandFound ); assertTrue( commandAcceptanceException.getCause() instanceof SQLException ); diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/schemagen/SchemaScriptFileGenerationFailureTest.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/schemagen/SchemaScriptFileGenerationFailureTest.java index a6f81953c3..aa7c941f8c 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/schemagen/SchemaScriptFileGenerationFailureTest.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/schemagen/SchemaScriptFileGenerationFailureTest.java @@ -11,6 +11,7 @@ import java.io.Writer; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; +import java.util.regex.Pattern; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.PersistenceException; @@ -56,7 +57,7 @@ public class SchemaScriptFileGenerationFailureTest { @Test @TestForIssue(jiraKey = "HHH-12192") - public void testGenerateSchemaDoesNotProduceTheSameStatementTwice() throws Exception { + public void testErrorMessageContainsTheFailingDDLCommand() throws Exception { try { entityManagerFactoryBuilder.generateSchema(); fail( "Should haave thrown IOException" ); @@ -69,7 +70,10 @@ public class SchemaScriptFileGenerationFailureTest { CommandAcceptanceException commandAcceptanceException = (CommandAcceptanceException) e.getCause() .getCause(); - assertTrue( commandAcceptanceException.getMessage().contains( "drop table test_entity if exists" ) ); + + boolean ddlCommandFound = Pattern.compile( "drop table( if exists)? test_entity( if exists)?" ) + .matcher( commandAcceptanceException.getMessage().toLowerCase() ).find(); + assertTrue( "The Exception Message does not contain the DDL command causing the failure", ddlCommandFound ); assertTrue( commandAcceptanceException.getCause() instanceof IOException );