public class EmbeddedDatabaseBuilder extends Object
Usage example:
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); EmbeddedDatabase db = builder.setType(H2).addScript("schema.sql").addScript("data.sql").build(); db.shutdown();
Constructor and Description |
---|
EmbeddedDatabaseBuilder()
Create a new embedded database builder.
|
EmbeddedDatabaseBuilder(ResourceLoader resourceLoader)
Create a new embedded database builder with the given ResourceLoader.
|
Modifier and Type | Method and Description |
---|---|
EmbeddedDatabaseBuilder |
addDefaultScripts()
Add default scripts to execute to populate the database.
|
EmbeddedDatabaseBuilder |
addScript(String sqlResource)
Add a SQL script to execute to populate the database.
|
EmbeddedDatabase |
build()
Build the embedded database.
|
EmbeddedDatabaseBuilder |
setName(String databaseName)
Set the name of the embedded database.
|
EmbeddedDatabaseBuilder |
setType(EmbeddedDatabaseType databaseType)
Set the type of embedded database.
|
public EmbeddedDatabaseBuilder()
public EmbeddedDatabaseBuilder(ResourceLoader resourceLoader)
resourceLoader
- the ResourceLoader to delegate topublic EmbeddedDatabaseBuilder setName(String databaseName)
Defaults to "testdb" if not called.
databaseName
- the database namepublic EmbeddedDatabaseBuilder setType(EmbeddedDatabaseType databaseType)
Defaults to HSQL if not called.
databaseType
- the database typepublic EmbeddedDatabaseBuilder addScript(String sqlResource)
sqlResource
- the sql resource locationpublic EmbeddedDatabaseBuilder addDefaultScripts()
The default scripts are schema.sql
to create the db
schema and data.sql
to populate the db with data.
public EmbeddedDatabase build()