Package org.dbunit
Class DatabaseEnvironment
java.lang.Object
org.dbunit.DatabaseEnvironment
- Direct Known Subclasses:
DerbyEnvironment,H2Environment,HypersonicEnvironment,MsSqlEnvironment,MySqlEnvironment,OracleEnvironment,PostgresqlEnvironment
- Since:
- Feb 18, 2002
- Version:
- $Revision$
- Author:
- Manuel Laflamme
-
Constructor Summary
ConstructorsConstructorDescriptionDatabaseEnvironment(DatabaseProfile profile) DatabaseEnvironment(DatabaseProfile profile, Callable<Void> preDdlFunction) -
Method Summary
Modifier and TypeMethodDescriptionvoidconvertString(String str) Returns the string converted as an identifier according to the metadata rules of the database environment.static DatabaseEnvironmentprotected static PropertiesOptional "dbunit.properties" is loaded (if present and the "dbunit.profile" property is null) and merged with System properties and the whole set is returned.protected static voidloadDbunitPropertiesFromFile(Properties properties) protected voidsetupDatabaseConfig(DatabaseConfig config) booleansupport(TestFeature feature) toString()
-
Constructor Details
-
Method Details
-
getProperties
Optional "dbunit.properties" is loaded (if present and the "dbunit.profile" property is null) and merged with System properties and the whole set is returned.If absent (which is the normal scenario), only System properties are returned.
"dbunit.properties" is useful for environment which make it difficult if not impossible to use Maven's profiles. Example is IntelliJ IDEA which when calling Junit tests, bypass Maven completely. Since profiles are not used, database configuration is not properly set and tests fail. "dbunit.properties" contains the missing properties which a profile would set.
Following is a few properties as an example of the content of "dbunit.properties":
database.profile=h2 dbunit.profile.driverClass=org.hsqldb.jdbcDriver dbunit.profile.url=jdbc:hsqldb:mem:.
Simply create "dbunit.properties" under "src/test/resources".
- Returns:
- Merged DbUnit and System properties.
- Throws:
IOException- Thrown if an error occurs when attempting to read "dbunit.properties".
-
loadDbunitPropertiesFromFile
- Throws:
IOException
-
getInstance
- Throws:
Exception
-
getConnection
- Throws:
Exception
-
setupDatabaseConfig
-
getDatabaseTester
-
closeConnection
- Throws:
Exception
-
getInitDataSet
- Throws:
Exception
-
getProfile
- Throws:
Exception
-
support
-
convertString
Returns the string converted as an identifier according to the metadata rules of the database environment. Most databases convert all metadata identifiers to uppercase. PostgreSQL converts identifiers to lowercase. MySQL preserves case.- Parameters:
str- The identifier.- Returns:
- The identifier converted according to database rules.
-
toString
-