Class HyperSqlUtil
java.lang.Object
com.github.hypfvieh.db.HyperSqlUtil
HyperSQL utility is intended to support database-backed tests by copying HyperSQL test databases
from the classpath to another location (such as the system's temp directory) and performing
clean-up work afterward.
-
Constructor Summary
ConstructorsConstructorDescriptionHyperSqlUtil(String dbBaseName) Copies the given database to system temp directory using the calling class name as subdirectory.HyperSqlUtil(String dbBaseName, File targetDir, boolean deleteOnExit) Constructs a new instance of HyperSqlUtil to manage a HyperSQL database in a target directory. -
Method Summary
Modifier and TypeMethodDescriptionvoidCleans and removes the target directory.copyHsqlDbFiles(String searchPath, boolean overwrite) Returns the path including database file name to use in JDBC URL.toString()
-
Constructor Details
-
HyperSqlUtil
Copies the given database to system temp directory using the calling class name as subdirectory.- Parameters:
dbBaseName- the base name of the database without extension; must not be null
-
HyperSqlUtil
Constructs a new instance of HyperSqlUtil to manage a HyperSQL database in a target directory. This constructor ensures the provided target directory exists, is writable, and may optionally delete the directory on JVM exit.Warning: Existing database files (dbBaseName + any of the extensions listed in
HYPERSQL_EXTENSIONS) will be removed!- Parameters:
dbBaseName- the base name of the database without extension; must not be nulltargetDir- the directory where the database files will be managed; must not be nulldeleteOnExit- specifies if the target directory should be deleted when the JVM exits- Throws:
NullPointerException- if dbBaseName or targetDir is nullRuntimeException- if the target directory cannot be created or its read/write permissions cannot be set
-
-
Method Details
-
getDbPath
Returns the path including database file name to use in JDBC URL.- Returns:
- String
-
copyHsqlDbFiles
- See Also:
-
copyHsqlDbFiles
- See Also:
-
cleanupTargetDir
public void cleanupTargetDir()Cleans and removes the target directory. -
getTargetDir
-
toString
-