Search in sources :

Example 51 with IonSequence

use of com.amazon.ion.IonSequence in project ion-java by amzn.

the class BaseIonSequenceLiteSublistTestCase method sublistListIteratorWithIndexConcurrentModification.

@Test(expected = ConcurrentModificationException.class)
public void sublistListIteratorWithIndexConcurrentModification() {
    final IonSequence sequence = newSequence();
    final List<IonValue> sublist = sequence.subList(2, 5);
    sequence.add(SYSTEM.newInt(99));
    sublist.listIterator(1);
}
Also used : IonValue(com.amazon.ion.IonValue) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 52 with IonSequence

use of com.amazon.ion.IonSequence in project ion-java by amzn.

the class BaseIonSequenceLiteTestCase method retainAllReadOnly.

@Test(expected = ReadOnlyValueException.class)
public void retainAllReadOnly() {
    final IonSequence sequence = newEmptySequence();
    sequence.makeReadOnly();
    sequence.retainAll(Collections.emptyList());
}
Also used : IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 53 with IonSequence

use of com.amazon.ion.IonSequence in project ion-java by amzn.

the class BaseIonSequenceLiteTestCase method retainAllUsesReferenceEquality.

@Test
public void retainAllUsesReferenceEquality() {
    final IonSequence sequence = newEmptySequence();
    final ArrayList<IonValue> toRetain = new ArrayList<IonValue>();
    final IonValue value = SYSTEM.newInt(1);
    sequence.add(value);
    final IonValue equalValue = SYSTEM.newInt(1);
    toRetain.add(equalValue);
    assertEquals(equalValue, value);
    assertNotSame(equalValue, value);
    assertTrue(sequence.retainAll(toRetain));
    assertEquals(0, sequence.size());
}
Also used : IonValue(com.amazon.ion.IonValue) IonSequence(com.amazon.ion.IonSequence) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 54 with IonSequence

use of com.amazon.ion.IonSequence in project ion-java by amzn.

the class BaseIonSequenceLiteTestCase method retainAll.

@Test
public void retainAll() {
    final IonSequence sequence = newEmptySequence();
    final ArrayList<IonValue> toRetain = new ArrayList<IonValue>();
    final IonValue retainedValue = SYSTEM.newInt(1);
    sequence.add(retainedValue);
    toRetain.add(retainedValue);
    final IonValue toRemoveValue = SYSTEM.newInt(2);
    sequence.add(toRemoveValue);
    assertTrue(sequence.retainAll(toRetain));
    assertEquals(1, sequence.size());
    assertTrue(sequence.contains(retainedValue));
    assertFalse(sequence.contains(toRemoveValue));
}
Also used : IonValue(com.amazon.ion.IonValue) IonSequence(com.amazon.ion.IonSequence) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 55 with IonSequence

use of com.amazon.ion.IonSequence in project ion-java by amzn.

the class BaseIonSequenceLiteSublistTestCase method sublistIndexOfConcurrentModification.

@Test(expected = ConcurrentModificationException.class)
public void sublistIndexOfConcurrentModification() {
    final IonSequence sequence = newSequence();
    final List<IonValue> sublist = sequence.subList(2, 5);
    sequence.remove(0);
    sublist.indexOf(sequence.get(2));
}
Also used : IonValue(com.amazon.ion.IonValue) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Aggregations

IonSequence (com.amazon.ion.IonSequence)68 Test (org.junit.Test)62 IonValue (com.amazon.ion.IonValue)61 IonInt (com.amazon.ion.IonInt)17 IonStruct (com.amazon.ion.IonStruct)5 IonLob (com.amazon.ion.IonLob)3 IonType (com.amazon.ion.IonType)3 SymbolToken (com.amazon.ion.SymbolToken)2 ArrayList (java.util.ArrayList)2 IonBool (com.amazon.ion.IonBool)1 IonDatagram (com.amazon.ion.IonDatagram)1 IonException (com.amazon.ion.IonException)1 IonFloat (com.amazon.ion.IonFloat)1 IonSymbol (com.amazon.ion.IonSymbol)1 IonText (com.amazon.ion.IonText)1 IonTimestamp (com.amazon.ion.IonTimestamp)1 SymbolTable (com.amazon.ion.SymbolTable)1 IOException (java.io.IOException)1