Methods Summary |
---|
protected void | setUp()
super.setUp();
Context c = getContext();
mDatabaseFile = c.getDatabasePath("database_test.db");
if (mDatabaseFile.exists()) {
mDatabaseFile.delete();
}
mDatabase = c.openOrCreateDatabase("database_test.db", 0, null);
assertNotNull(mDatabase);
mDatabase.setVersion(CURRENT_DATABASE_VERSION);
mDatabase.execSQL("CREATE TABLE IF NOT EXISTS test (_id INTEGER PRIMARY KEY, data TEXT);");
|
protected void | tearDown()
mDatabase.close();
mDatabaseFile.delete();
super.tearDown();
|
public void | testOutOfSpace()use fillup -p 90 before run the test
and when disk run out
start delete some fillup files
and see if db recover
int i = 0;
char[] ch = new char[100000];
String str = new String(ch);
String[] strArr = new String[1];
strArr[0] = str;
for (; i < 10000; ++i) {
try {
mDatabase.execSQL("INSERT INTO test (data) VALUES (?)", strArr);
} catch (Exception e) {
Log.e(TAG, "exception " + e.getMessage());
}
}
|
public void | testSingleThreadInsertDelete()
int i = 0;
char[] ch = new char[100000];
String str = new String(ch);
String[] strArr = new String[1];
strArr[0] = str;
for (; i < 10000; ++i) {
try {
mDatabase.execSQL("INSERT INTO test (data) VALUES (?)", strArr);
mDatabase.execSQL("delete from test;");
} catch (Exception e) {
Log.e(TAG, "exception " + e.getMessage());
}
}
|