Skip to content

Instantly share code, notes, and snippets.

@mguillermin
Created March 2, 2012 20:22
Show Gist options
  • Save mguillermin/1961033 to your computer and use it in GitHub Desktop.
Save mguillermin/1961033 to your computer and use it in GitHub Desktop.
public class BaseModelTest {
public static FakeApplication app;
public static String createDdl = "";
public static String dropDdl = "";
@BeforeClass
public static void startApp() throws IOException {
app = Helpers.fakeApplication(Helpers.inMemoryDatabase());
Helpers.start(app);
// Reading the evolution file
String evolutionContent = FileUtils.readFileToString(
app.getWrappedApplication().getFile("conf/evolutions/default/1.sql"));
// Splitting the String to get Create & Drop DDL
String[] splittedEvolutionContent = evolutionContent.split("# --- !Ups");
String[] upsDowns = splittedEvolutionContent[1].split("# --- !Downs");
createDdl = upsDowns[0];
dropDdl = upsDowns[1];
}
@AfterClass
public static void stopApp() {
Helpers.stop(app);
}
@Before
public void createCleanDb() {
Ebean.execute(Ebean.createCallableSql(dropDdl));
Ebean.execute(Ebean.createCallableSql(createDdl));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment