, Play , FakeApplication. . https://www.playframework.com/documentation/2.2.x/JavaTest .
Evolution .
java:
@Before
public void setUp() throws IOException {
fakeapp = Helpers.fakeApplication(testconfiguration)
evolutions = Evolutions.applicationEvolutions(fakeapp.getWrappedApplication().path(), fakeapp.getWrappedApplication().classloader(), "database");
Iterator<Evolution> iterator = evolutions.iterator();
while (iterator.hasNext()) {
Evolution current = iterator.next();
if (latestEvolution == null) {
latestEvolution = current;
} else {
latestEvolution = current.revision() > latestEvolution.revision() ? current : latestEvolution;
}
}
latestEvolutionFile = new File(fakeapp.getWrappedApplication().path(), "path/to/evolution/files" + latestEvolution.revision() + ".sql");
latestEvolutionFileContent = Files.readAllBytes(Paths.get(latestEvolutionFile.getAbsolutePath()));
}
@Test
public void testLatestDownEvolution() throws IOException {
try {
Evolutions.updateEvolutionScript("database", latestEvolution.revision(), "", "", "", fakeapp.getWrappedApplication());
app.getWrappedApplication().plugin(EvolutionsPlugin.class).get().onStart();
} catch (InconsistentDatabase ex) {
Assert.fail(ex.subTitle() + " " + ex.rev() + ".sql");
} finally {
try (FileOutputStream stream = new FileOutputStream(latestEvolutionFile)) {
stream.write(latestEvolutionFileContent);
}
}
, ebean, .