I developed my own conflict resolution mechanism, which resolves conflicts
based on the document timestamp and type. I have a test which creates a
conflict and then I run my conflict resolution mechanism and verify if
everything is as supposed. After updating to CBL beta2 it seems I am no
longer able to create conflicts locally.
public void testConflict() {
CallsSettings callsSettings =
AdvancedSettings.getInstance().getCallSettings();
assertNotNull(callsSettings);
String id = callsSettings.getId();
//verify the doc doesn't has any conflict
RevisionInternal revision =
SyncDBService.getLocalDbInstance().getAllRevisionsOfDocumentID(
id,
true).get(0);
//remove possible conflicts
CouchUtil.getNewRevHistory(revision);
assertEquals(0, CouchUtil.getConflictRev(revision).size());
//update document
callsSettings.save();
//try to introduce conflict
Status conflictStatus = new Status();
try {
RevisionInternal conflictRev =
SyncDBService.getLocalDbInstance().putRevision(
revision,
revision.getRevId(),
true,
conflictStatus);
Log.d(TAG, "new conflict: " + conflictRev.getRevId());
} catch (CouchbaseLiteException e) {
e.printStackTrace();
Utils.ScLog.d(TAG, "exception code: " +
String.valueOf(e.getCBLStatus().getCode()));
}
assertEquals(1, CouchUtil.getConflictRev(revision).size());
CouchUtil.getNewRevHistory(revision);
assertEquals(0, CouchUtil.getConflictRev(revision).size());
}
When I try to create the conflict I get an exception with the following
StackTrace:
02-04 16:11:46.055 13175-13189/? W/System.err﹕
com.couchbase.lite.CouchbaseLiteException
02-04 16:11:46.055 13175-13189/? W/System.err﹕ at
com.couchbase.lite.Database.putRevision(Database.java:3087)
02-04 16:11:46.055 13175-13189/? W/System.err﹕ at
pt.fraunhofer.test.couch.SyncDBServiceTest.test5createConflict(SyncDBServiceTest.java:131)
02-04 16:11:46.055 13175-13189/? W/System.err﹕ at
java.lang.reflect.Method.invokeNative(Native Method)
02-04 16:11:46.055 13175-13189/? W/System.err﹕ at
java.lang.reflect.Method.invoke(Method.java:525)
02-04 16:11:46.055 13175-13189/? W/System.err﹕ at
junit.framework.TestCase.runTest(TestCase.java:168)
02-04 16:11:46.055 13175-13189/? W/System.err﹕ at
junit.framework.TestCase.runBare(TestCase.java:134)
02-04 16:11:46.063 13175-13189/? W/System.err﹕ at
junit.framework.TestResult$1.protect(TestResult.java:115)
02-04 16:11:46.063 13175-13189/? W/System.err﹕ at
junit.framework.TestResult.runProtected(TestResult.java:133)
02-04 16:11:46.063 13175-13189/? W/System.err﹕ at
junit.framework.TestResult.run(TestResult.java:118)
02-04 16:11:46.063 13175-13189/? W/System.err﹕ at
junit.framework.TestCase.run(TestCase.java:124)
02-04 16:11:46.063 13175-13189/? W/System.err﹕ at
android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
02-04 16:11:46.063 13175-13189/? W/System.err﹕ at
android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
02-04 16:11:46.063 13175-13189/? W/System.err﹕ at
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
02-04 16:11:46.063 13175-13189/? W/System.err﹕ at
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)
02-04 16:11:46.063 13175-13189/? D/SyncDBServiceTest﹕ exception code: 400
In the end you can also see the CBLStatus code returned for the exception:
400(bad request). Is there any other way to introduce conflicts locally?
--
You received this message because you are subscribed to the Google Groups
"Couchbase" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.