Created
March 2, 2012 20:22
-
-
Save mguillermin/1961033 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 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