Add database auto updating
This commit is contained in:
@@ -50,6 +50,9 @@ public class TestDataRepo extends AbstractDhRepo<TestDto>
|
||||
|
||||
@Override
|
||||
public String getTableName() { return "Test"; }
|
||||
@Override
|
||||
public String getPrimaryKeyName() { return "Id"; }
|
||||
|
||||
|
||||
@Override
|
||||
public TestDto convertResultSetToDto(ResultSet resultSet) throws SQLException
|
||||
|
||||
@@ -19,12 +19,14 @@
|
||||
|
||||
package tests;
|
||||
|
||||
import com.seibel.distanthorizons.core.sql.DatabaseUpdater;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import testItems.sql.TestDataRepo;
|
||||
import testItems.sql.TestDto;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
@@ -57,6 +59,23 @@ public class DhRepoSqliteTest
|
||||
Assert.assertTrue("dbFile not created", dbFile.exists());
|
||||
|
||||
|
||||
|
||||
//==========================//
|
||||
// Auto update script tests //
|
||||
//==========================//
|
||||
|
||||
ResultSet autoUpdateTablePresentResult = testDataRepo.query("SELECT name FROM sqlite_master WHERE type='table' AND name='"+DatabaseUpdater.SCHEMA_TABLE_NAME+"';");
|
||||
if (!autoUpdateTablePresentResult.next() || autoUpdateTablePresentResult.getString(1) == null)
|
||||
{
|
||||
Assert.fail("Auto DB update table missing.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//===========//
|
||||
// DTO tests //
|
||||
//===========//
|
||||
|
||||
// insert
|
||||
TestDto insertDto = new TestDto(0, "a");
|
||||
testDataRepo.save(insertDto);
|
||||
@@ -97,12 +116,6 @@ public class DhRepoSqliteTest
|
||||
{
|
||||
testDataRepo.close();
|
||||
}
|
||||
|
||||
dbFile = new File(dbFileName);
|
||||
if (dbFile.exists())
|
||||
{
|
||||
Assert.assertTrue("unable to delete test DB File.", dbFile.delete());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user