Skip to content

Instantly share code, notes, and snippets.

@jannylund
Created June 12, 2013 17:21
Show Gist options
  • Save jannylund/5767312 to your computer and use it in GitHub Desktop.
Save jannylund/5767312 to your computer and use it in GitHub Desktop.
public class DatabaseTest {
public static FakeApplication app;
public static DdlGenerator ddl;
public static EbeanServer server;
@BeforeClass
public static void initialize() {
/* Start fakeapplication with default in memory db. */
Map<String, String> config = new HashMap<String, String>(Helpers.inMemoryDatabase());
config.put("evolutionplugin", "disabled"); // disable evolutionplugin to avoid errors related to manual evolutions.
app = Helpers.fakeApplication(config);
Helpers.start(app);
/* Manually generate ddl for our h2 database. */
ServerConfig serverconfig = new ServerConfig();
server = Ebean.getServer("default");
ddl = new DdlGenerator((SpiEbeanServer) server, new H2Platform(), serverconfig);
// Create
ddl.runScript(false, ddl.generateCreateDdl());
}
@AfterClass
public static void stopApp() {
// Drop
ddl.runScript(false, ddl.generateDropDdl());
Helpers.stop(app);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment