Skip to content
This repository was archived by the owner on Mar 10, 2022. It is now read-only.

Commit 2329161

Browse files
author
hideki
committed
Unit test for fix of Android 790 - ClassCastException when upgrading from 1.1 to 1.2
1 parent a923d73 commit 2329161

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/androidTest/java/com/couchbase/lite/DatabaseTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,4 +429,29 @@ public void testNonStringForTypeField() throws CouchbaseLiteException {
429429
Document doc2 = database.createDocument();
430430
doc2.putProperties(props1);
431431
}
432+
433+
// ClassCastException when upgrading from 1.1 to 1.2
434+
// https://github.com/couchbase/couchbase-lite-android/issues/790
435+
public void testForceInsertWithNonStringForTypeField() throws CouchbaseLiteException {
436+
// Non String as type
437+
RevisionInternal rev = new RevisionInternal("MyDocID", "1-1111", false);
438+
Map<String, Object> properties = new HashMap<String, Object>();
439+
properties.put("_id", rev.getDocID());
440+
properties.put("_rev", rev.getRevID());
441+
List<Integer> type1 = Arrays.asList(0, 1);
442+
properties.put("type", type1);
443+
rev.setProperties(properties);
444+
List<String> history = Arrays.asList(rev.getRevID());
445+
database.forceInsert(rev, history, null);
446+
447+
// String as type
448+
rev = new RevisionInternal("MyDocID", "1-ffff", false);
449+
properties = new HashMap<String, Object>();
450+
properties.put("_id", rev.getDocID());
451+
properties.put("_rev", rev.getRevID());
452+
properties.put("type", "STRING");
453+
rev.setProperties(properties);
454+
history = Arrays.asList(rev.getRevID());
455+
database.forceInsert(rev, history, null);
456+
}
432457
}

0 commit comments

Comments
 (0)