Source:
public void testUpdateConflictCase() { Uri uri = Carriers.CONTENT_URI; ContentValues contentValues = new ContentValues(); contentValues.put(Carriers.NAME, NAME); contentValues.put(Carriers.APN, APN); contentValues.put(Carriers.PORT, PORT); contentValues.put(Carriers.PROTOCOL, PROTOCOL); contentValues.put(Carriers.NUMERIC, NUMERIC); try { Log.d(TAG, "testInsertCarriers Inserting contentValues: " + contentValues); mContentResolver.insert(uri, contentValues); final String[] testProjection = { Carriers.NAME, Carriers.APN, Carriers.PORT, Carriers.PROTOCOL, Carriers.NUMERIC, }; String selection = Carriers.NAME + "=?"; String[] selectionArgs = { NAME }; Log.d(TAG, "testInsertCarriers query projection: " + testProjection + "\ntestInsertCarriers selection: " + selection + "\ntestInsertCarriers selectionArgs: " + selectionArgs); Cursor cursor = mContentResolver.query(uri, testProjection, selection, selectionArgs, null); assertEquals(1, cursor.getCount()); String randomColumn = "random"; contentValues.put(randomColumn, randomColumn); try { mContentResolver.update(uri, contentValues, selection, selectionArgs); fail(); } catch (SQLiteException e) { } final String selectionToDelete = Carriers.NAME + "=?"; String[] selectionArgsToDelete = { NAME }; Log.d(TAG, "testInsertCarriers deleting selection: " + selectionToDelete + "testInsertCarriers selectionArgs: " + selectionArgs); int numRowsDeleted = mContentResolver.delete(uri, selectionToDelete, selectionArgsToDelete); assertEquals(1, numRowsDeleted); cursor = mContentResolver.query( uri, testProjection, selectionToDelete, selectionArgsToDelete, null); assertEquals(0, cursor.getCount()); } catch (SecurityException e) { failMessage(); } }

Target:
public void testUpdateConflictCase() { Uri uri = Carriers.CONTENT_URI; ContentValues contentValues = new ContentValues(); contentValues.put(Carriers.NAME, NAME); contentValues.put(Carriers.APN, APN); contentValues.put(Carriers.PORT, PORT); contentValues.put(Carriers.PROTOCOL, PROTOCOL); contentValues.put(Carriers.NUMERIC, NUMERIC); try { Log.d(TAG, "testInsertCarriers Inserting contentValues: " + contentValues); mContentResolver.insert(uri, contentValues); final String[] testProjection = { Carriers.NAME, Carriers.APN, Carriers.PORT, Carriers.PROTOCOL, Carriers.NUMERIC, }; String selection = Carriers.NAME + "=?"; String[] selectionArgs = { NAME }; Log.d(TAG, "testInsertCarriers query projection: " + testProjection + "\ntestInsertCarriers selection: " + selection + "\ntestInsertCarriers selectionArgs: " + selectionArgs); Cursor cursor = mContentResolver.query(uri, testProjection, selection, selectionArgs, null); assertEquals(1, cursor.getCount()); String invalidColumn = "random"; contentValues.put(invalidColumn, invalidColumn); try { mContentResolver.update(uri, contentValues, selection, selectionArgs); fail(); } catch (SQLiteException e) { } final String selectionToDelete = Carriers.NAME + "=?"; String[] selectionArgsToDelete = { NAME }; Log.d(TAG, "testInsertCarriers deleting selection: " + selectionToDelete + "testInsertCarriers selectionArgs: " + selectionArgs); int numRowsDeleted = mContentResolver.delete(uri, selectionToDelete, selectionArgsToDelete); assertEquals(1, numRowsDeleted); cursor = mContentResolver.query( uri, testProjection, selectionToDelete, selectionArgsToDelete, null); assertEquals(0, cursor.getCount()); } catch (SecurityException e) { failMessage(); } }