HHH-12192 - Fix tests failing on PostgreSQL
This commit is contained in:
parent
e9c3870909
commit
803b29fc1a
|
@ -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 );
|
||||
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
Loading…
Reference in New Issue