Created
June 12, 2013 17:21
-
-
Save jannylund/5767312 to your computer and use it in GitHub Desktop.
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
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