use of sqlite.feature.schema.version2.BindSchoolDataSource in project kripton by xcesco.
the class TestSchemaRuntime method testRun.
@Test
public void testRun() {
BindSchoolDataSource.build(DataSourceOptions.builder().databaseLifecycleHandler(new DatabaseLifecycleHandler() {
@Override
public void onUpdate(SQLiteDatabase db, int oldVersion, int newVersion, boolean upgrade) {
// TODO Auto-generated method stub
}
@Override
public void onCreate(SQLiteDatabase database) {
// TODO Auto-generated method stub
}
@Override
public void onConfigure(SQLiteDatabase database) {
// TODO Auto-generated method stub
}
}).build());
try (BindSchoolDataSource dataSource = BindSchoolDataSource.open();
DaoProfessorImpl dao = dataSource.getDaoProfessor()) {
// dataSource.execute(transaction);
for (int i = 0; i < 10; i++) {
Professor professor = new Professor();
professor.name = String.format("professor%03d", i);
professor.surname = "surname" + i;
professor.birthDate = new Date();
dao.insert(professor);
}
}
try (BindSchoolDataSource dataSource = BindSchoolDataSource.open();
DaoStudentImpl dao = dataSource.getDaoStudent()) {
// dataSource.execute(transaction);
for (int i = 0; i < 100; i++) {
Student student = new Student();
student.name = String.format("professor%03d", i);
student.location = String.format("location%03d", i);
dao.insert(student);
}
}
}
use of sqlite.feature.schema.version2.BindSchoolDataSource in project kripton by xcesco.
the class TestSchemaUpdater2 method testStandardUpdate.
/**
* Destroy and recreate everything
*/
@Test
public void testStandardUpdate() throws Exception {
SQLiteUpdateTestHelper.resetInstance(BindSchoolDataSource.class);
BindSchoolDataSource.build(DataSourceOptions.builder().addUpdateTask(3, new FileInputStream("schemas/school_update_2_3.sql")).build());
BindSchoolDataSource dataSource = BindSchoolDataSource.open();
SQLiteSchemaVerifierHelper.forceSchemaUpdate(dataSource, 3);
dataSource = BindSchoolDataSource.open();
Logger.info("finish");
}
Aggregations