Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Closeable/AutoCloseable on Database & interface (#2990)
* Add AutoCloseable on Database interface * Adapt close() implementation into AbstractJdbcDatabase * Handle the eventuality of no connection. * Use `try with resources` into unit test Co-authored-by: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Co-authored-by: Nathan Voxland <nathan@voxland.net>
- Loading branch information
1 parent
3d3f827
commit c72e682
Showing
16 changed files
with
215 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 2 additions & 6 deletions
8
liquibase-core/src/test/java/liquibase/database/ConnectionServiceFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 11 additions & 7 deletions
18
liquibase-core/src/test/java/liquibase/database/core/AbstractDb2DatabaseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
package liquibase.database.core; | ||
|
||
import junit.framework.TestCase; | ||
import liquibase.database.Database; | ||
import liquibase.exception.DatabaseException; | ||
|
||
public class AbstractDb2DatabaseTest extends TestCase { | ||
public void testGetDateLiteral() { | ||
AbstractDb2Database database = new DB2Database(); | ||
|
||
assertEquals("DATE('2018-12-31')", database.getDateLiteral("2018-12-31")); | ||
assertEquals("TIME('23:58:59')", database.getDateLiteral("23:58:59")); | ||
assertEquals("TIMESTAMP('2018-12-31 23:58:59')", database.getDateLiteral("2018-12-31 23:58:59")); | ||
assertEquals("UNSUPPORTED:foo", database.getDateLiteral("foo")); | ||
public void testGetDateLiteral() throws DatabaseException { | ||
try (AbstractDb2Database database = new DB2Database()) { | ||
assertEquals("DATE('2018-12-31')", database.getDateLiteral("2018-12-31")); | ||
assertEquals("TIME('23:58:59')", database.getDateLiteral("23:58:59")); | ||
assertEquals("TIMESTAMP('2018-12-31 23:58:59')", database.getDateLiteral("2018-12-31 23:58:59")); | ||
assertEquals("UNSUPPORTED:foo", database.getDateLiteral("foo")); | ||
} catch (final DatabaseException e) { | ||
throw e; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.