private void testRecreateDuringMigration(boolean upgrade) { // insert some data to check for later badDatabase.persist(new Employee().setName("Alice")); badDatabase.persist(new Employee().setName("Bob")); badDatabase.persist(new Employee().setName("Cindy")); assertEquals(3, badDatabase.countAll(Employee.class)); testMigrationFailureCalled(upgrade, false, true); // verify the db was recreated with the appropriate version and no previous data SQLiteDatabaseWrapper db = badDatabase.getDatabase(); assertEquals(badDatabase.getVersion(), db.getVersion()); assertEquals(0, badDatabase.countAll(Employee.class)); }
public void testRawQuery() { badDatabase.persist( new TestModel().setFirstName("Sam").setLastName("Bosley").setBirthday(testDate)); Cursor cursor = null; try { // Sanity check that there is only one row in the table assertEquals(1, badDatabase.countAll(TestModel.class)); // Test that raw query binds arguments correctly--if the argument // is bound as a String, the result will be empty cursor = badDatabase.rawQuery("select * from testModels where abs(_id) = ?", new Object[] {1}); assertEquals(1, cursor.getCount()); } finally { if (cursor != null) { cursor.close(); } } }