Nikolay Kuznetsov
Nikolay Kuznetsov

Reputation: 9579

Play 2 framework clean in memory DB

In Play 2 Framework we can create in memory database for testing purposes and then load yaml file into the DD.

@Before
public void setUp() {
   start(fakeApplication(inMemoryDatabase()));
}

Ebean.save((List) Yaml.load("test-data.yml"));

The question is how to easily clean the DB (drop all tables)?

Something like Ebean.clean() or Ebean.dropAll(), but it does not exist.

Upvotes: 0

Views: 420

Answers (1)

James Roper
James Roper

Reputation: 12850

inMemoryDatabase() uses a random database name, so each time you create it, it should return you a new database. Nevertheless, if you want to drop all tables, just create an @After method, and use the DB class to get a jdbc connection, then you can issue a drop database SQL statement.

Upvotes: 2

Related Questions