@@ -0,0 +1,2104 @@
+package io;%0D%0A%0D%0Aimport static org.junit.Assert.*;%0D%0Aimport static org.mockito.Mockito.*;%0D%0A%0D%0Aimport java.util.Properties;%0D%0A%0D%0Aimport org.junit.After;%0D%0Aimport org.junit.Before;%0D%0Aimport org.junit.Test;%0D%0A%0D%0Apublic class SchemaUpdaterTest %7B%0D%0A%09MySQL sql;%0D%0A%09Properties local;%0D%0A%0D%0A%09@Before%0D%0A%09public void setUp() throws Exception %7B%0D%0A%09%09sql = mock(MySQL.class);%0D%0A%09%09local = new Properties();%0D%0A%09%09local.put(DBsettings.SchemaVersion.toString(), %223%22);%0D%0A%09%7D%0D%0A%0D%0A%09@After%0D%0A%09public void tearDown() throws Exception %7B%0D%0A%09%7D%0D%0A%09%0D%0A%09@Test(expected=SchemaUpdateException.class)%0D%0A%09public void testInvalidLocal() throws SchemaUpdateException %7B%0D%0A%09%09local = new Properties();%0D%0A%09%09when(sql.getSetting(DBsettings.SchemaVersion)).thenReturn(%221%22);%0D%0A%09%09SchemaUpdater.update(sql, local);%0D%0A%09%7D%0D%0A%0D%0A%09@Test(expected=SchemaUpdateException.class)%0D%0A%09public void testInvalidVersion1() throws SchemaUpdateException %7B%0D%0A%09%09when(sql.getSetting(DBsettings.SchemaVersion)).thenReturn(%22-1%22);%0D%0A%09%09SchemaUpdater.update(sql, local);%0D%0A%09%7D%0D%0A%09%0D%0A%09@Test(expected=SchemaUpdateException.class)%0D%0A%09public void testInvalidVersion2() throws SchemaUpdateException %7B%0D%0A%09%09when(sql.getSetting(DBsettings.SchemaVersion)).thenReturn(%220%22);%0D%0A%09%09SchemaUpdater.update(sql, local);%0D%0A%09%7D%0D%0A%09%0D%0A%09@Test(expected=SchemaUpdateException.class)%0D%0A%09public void testInvalidVersion3() throws SchemaUpdateException %7B%0D%0A%09%09when(sql.getSetting(DBsettings.SchemaVersion)).thenReturn(%22a%22);%0D%0A%09%09SchemaUpdater.update(sql, local);%0D%0A%09%7D%0D%0A%09%0D%0A%09@Test%0D%0A%09public void testUpdate() throws SchemaUpdateException %7B%0D%0A%09%09when(sql.getSetting(DBsettings.SchemaVersion)).thenReturn(%221%22);%0D%0A%09%09SchemaUpdater.update(sql, local);%0D%0A%09%09verify(sql,times(1)).sendStatement(anyString());%0D%0A%09%7D%0D%0A%09%0D%0A%09@Test%0D%0A%09public void testNoUpdate() throws SchemaUpdateException %7B%0D%0A%09%09when(sql.getSetting(DBsettings.SchemaVersion)).thenReturn(%223%22);%0D%0A%09%09SchemaUpdater.update(sql, local);%0D%0A%09%09verify(sql,times(0)).sendStatement(anyString());%0D%0A%09%7D%0D%0A%09%0D%0A%09@Test(expected=SchemaUpdateException.class)%0D%0A%09public void testRemoteIsNewer() throws SchemaUpdateException %7B%0D%0A%09%09when(sql.getSetting(DBsettings.SchemaVersion)).thenReturn(%224%22);%0D%0A%09%09SchemaUpdater.update(sql, local);%0D%0A%09%7D%0D%0A%0D%0A%7D%0D%0A

test for SchemaUpdater