1 package liquibase.database.core; 2 3 import liquibase.database.AbstractDatabaseTest; 4 import liquibase.database.Database; 5 import org.junit.Assert; 6 import static org.junit.Assert.*; 7 import org.junit.Test; 8 9 public class H2DatabaseTest extends AbstractDatabaseTest { 10 11 public H2DatabaseTest() throws Exception { 12 super(new H2Database()); 13 } 14 15 @Override 16 protected String getProductNameString() { 17 return "H2"; 18 } 19 20 21 @Override 22 @Test 23 public void supportsInitiallyDeferrableColumns() { 24 assertFalse(getDatabase().supportsInitiallyDeferrableColumns()); 25 } 26 27 @Override 28 @Test 29 public void getCurrentDateTimeFunction() { 30 Assert.assertEquals("NOW()", getDatabase().getCurrentDateTimeFunction()); 31 } 32 33 @Test 34 public void testGetDefaultDriver() { 35 Database database = getDatabase(); 36 37 assertEquals("org.h2.Driver", database.getDefaultDriver("jdbc:h2:mem:liquibase")); 38 39 assertNull(database.getDefaultDriver("jdbc:db2://localhost;databaseName=liquibase")); 40 } 41 42 @Override 43 @Test 44 public void escapeTableName_noSchema() { 45 Database database = getDatabase(); 46 assertEquals("tableName", database.escapeTableName(null, "tableName")); 47 } 48 49 @Override 50 @Test 51 public void escapeTableName_withSchema() { 52 Database database = getDatabase(); 53 assertEquals("schemaName.tableName", database.escapeTableName("schemaName", "tableName")); 54 } 55 }