// TODO: MArray has isMuated() method, but unable to check mutated to mutated.
// @Test
public void testArrayEnumerationWithDataModification() throws CouchbaseLiteException {
        MutableArray array = new MutableArray();
        for (int i = 0; i < 2; i++)
            array.addValue(i);
        Iterator<Object> itr = array.iterator();
        int count = 0;
        try {
            while (itr.hasNext()) {
                itr.next();
                if (count++ == 0)
                    array.addValue(2);
            }
            fail("Expected ConcurrentModificationException");
        } catch (ConcurrentModificationException e) {
        }
        assertEquals(3, array.count());
        assertEquals(Arrays.asList(0, 1, 2).toString(), array.toList().toString());
        MutableDocument doc = createMutableDocument("doc1");
        doc.setValue("array", array);
        doc = save(doc).toMutable();
        array = doc.getArray("array");
        itr = array.iterator();
        count = 0;
        try {
            while (itr.hasNext()) {
                itr.next();
                if (count++ == 0)
                    array.addValue(3);
            }
            fail("Expected ConcurrentModificationException");
        } catch (ConcurrentModificationException e) {
        }
        assertEquals(4, array.count());
        assertEquals(Arrays.asList(0, 1, 2, 3).toString(), array.toList().toString());
    }
public void testArrayEnumerationWithDataModification() throws CouchbaseLiteException {
MutableArray array = new MutableArray();
for (int i = 0; i < 2; i++)
array.addValue(i);
Iterator<Object> itr = array.iterator();
int count = 0;
try {
while (itr.hasNext()) {
itr.next();
if (count++ == 0)
array.addValue(2);
}
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException e) {
}
assertEquals(3, array.count());
assertEquals(Arrays.asList(0, 1, 2).toString(), array.toList().toString());
MutableDocument doc = createMutableDocument("doc1");
doc.setValue("array", array);
doc = save(doc).toMutable();
array = doc.getArray("array");
itr = array.iterator();
count = 0;
try {
while (itr.hasNext()) {
itr.next();
if (count++ == 0)
array.addValue(3);
}
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException e) {
}
assertEquals(4, array.count());
assertEquals(Arrays.asList(0, 1, 2, 3).toString(), array.toList().toString());
}
public void testArrayEnumerationWithDataModification() throws CouchbaseLiteException {
MutableArray array = new MutableArray();
for (int i = 0; i < 2; i++)
array.addValue(i);
Iterator<Object> itr = array.iterator();
int count = 0;
try {
while (itr.hasNext()) {
itr.next();
if (count++ == 0)
array.addValue(2);
}
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException e) {
}
assertEquals(3, array.count());
assertEquals(Arrays.asList(0, 1, 2).toString(), array.toList().toString());
MutableDocument doc = createMutableDocument("doc1");
doc.setValue("array", array);
doc = save(doc).toMutable();
array = doc.getArray("array");
itr = array.iterator();
count = 0;
try {
while (itr.hasNext()) {
itr.next();
if (count++ == 0)
array.addValue(3);
}
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException e) {
}
assertEquals(4, array.count());
assertEquals(Arrays.asList(0, 1, 2, 3).toString(), array.toList().toString());
}
public void testArrayEnumerationWithDataModification() throws CouchbaseLiteException {
MutableArray array = new MutableArray();
for (int i = 0; i < 2; i++)
array.addValue(i);
Iterator<Object> itr = array.iterator();
int count = 0;
try {
while (itr.hasNext()) {
itr.next();
if (count++ == 0)
array.addValue(2);
}
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException e) {
}
assertEquals(3, array.count());
assertEquals(Arrays.asList(0, 1, 2).toString(), array.toList().toString());
MutableDocument doc = createMutableDocument("doc1");
doc.setValue("array", array);
doc = save(doc).toMutable();
array = doc.getArray("array");
itr = array.iterator();
count = 0;
try {
while (itr.hasNext()) {
itr.next();
if (count++ == 0)
array.addValue(3);
}
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException e) {
}
assertEquals(4, array.count());
assertEquals(Arrays.asList(0, 1, 2, 3).toString(), array.toList().toString());
}