/** * Verify schema. * * @param database * the database * @param context * the context * @param rawId * the raw id */ public static void verifySchema(SQLiteDatabase database, Context context, int rawId) { verifySchema(database, context.getResources().openRawResource(rawId)); }
/** * Verify schema. * * @param <H> * the generic type * @param dataSource * the data source * @param inputStream * the input stream */ public static <H extends AbstractDataSource> void verifySchema(H dataSource, InputStream inputStream) { verifySchema(dataSource.openWritableDatabase(), inputStream); }
/** * Verify schema. * * @param <H> * the generic type * @param dataSource * the data source * @param context * the context * @param rawId * the raw id */ public static <H extends AbstractDataSource> void verifySchema(H dataSource, Context context, int rawId) { verifySchema(dataSource.openWritableDatabase(), context, rawId); }
/** * Allows to update database version to <i>version</i>. This method allows to specify the destination version schema and compare it with schema resulting by version update * applied. * * @param version * the version * @param schemaDefinitionInputStream * the schema definition input stream * @return the SQ lite update test database */ public SQLiteTestDatabase updateAndVerify(int version, final InputStream schemaDefinitionInputStream) { sqlite = new SQLiteOpenHelper(context, TEST_DATABASE, factory, version, errorHandler) { @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { List<SQLiteUpdateTask> task = findTask(oldVersion, newVersion); for (SQLiteUpdateTask item : task) { item.execute(db, oldVersion, oldVersion + 1); oldVersion++; } } @Override public void onCreate(SQLiteDatabase db) { throw (new KriptonRuntimeException("Unsupported situation")); } }; SQLiteTestUtils.verifySchema(sqlite.getWritableDatabase(), schemaDefinitionInputStream); return this; }