// ---------------------------------------------------------- public void testUpdateFrom1() throws SQLException { database.setVersionNumber(updates.subsystemName(), 1); UpdateEngine.instance().applyNecessaryUpdates(updates); assertEquals(2, database.currentVersionNumber(updates.subsystemName())); assertEquals( " hasTable(DBVERSION) tryToLock(mock)" + " executeSQL(v2) unlock(mock) close", database.history); }
// ---------------------------------------------------------- public void testUpdateFrom3() throws SQLException { database.setVersionNumber(updates.subsystemName(), 3); try { UpdateEngine.instance().applyNecessaryUpdates(updates); fail(); } catch (IllegalStateException expected) { // should be thrown because of upsupported version number } }
// ---------------------------------------------------------- public void testUpdateFromEmpty() throws SQLException { database.tablesExist = false; UpdateEngine.instance().applyNecessaryUpdates(updates); assertEquals(2, database.currentVersionNumber(updates.subsystemName())); assertEquals( " hasTable(DBVERSION) initializeVersionTable tryToLock(mock)" + " executeSQL(v0) executeSQL(v1) executeSQL(v2) unlock(mock)" + " close", database.history); }
// ---------------------------------------------------------- protected void setUp() { updates = new MockUpdateSet(); database = new MockDatabase(); UpdateEngine.instance().setDatabase(database); }