Search in sources :

Example 56 with IonValue

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

the class BaseIonSequenceLiteSublistTestCase method sublistAddAllWithIndexConcurrentModification.

@Test(expected = ConcurrentModificationException.class)
public void sublistAddAllWithIndexConcurrentModification() {
    final IonSequence sequence = newSequence();
    final List<IonValue> sublist = sequence.subList(2, 5);
    sequence.remove(0);
    sublist.addAll(0, Arrays.asList(SYSTEM.newInt(100), SYSTEM.newInt(101)));
}
Also used : IonValue(com.amazon.ion.IonValue) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 57 with IonValue

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

the class BaseIonSequenceLiteSublistTestCase method sublistRemoveAllConcurrentModification.

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

Example 58 with IonValue

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

the class IonReaderBinaryIncrementalTest method incrementalMultipleValuesIterateFromInputStream.

@Test
public void incrementalMultipleValuesIterateFromInputStream() throws Exception {
    ResizingPipedInputStream pipe = new ResizingPipedInputStream(128);
    IonSystem system = IonSystemBuilder.standard().withReaderBuilder(STANDARD_READER_BUILDER).build();
    Iterator<IonValue> iterator = system.iterate(pipe);
    incrementalMultipleValuesIterate(iterator, pipe);
}
Also used : IonValue(com.amazon.ion.IonValue) IonSystem(com.amazon.ion.IonSystem) Test(org.junit.Test)

Example 59 with IonValue

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

the class IonWriterTestCase method testWritingWithSystemImport.

@Test
public void testWritingWithSystemImport() throws Exception {
    final int FRED_ID_OFFSET = systemMaxId();
    final int LOCAL_ID_OFFSET = FRED_ID_OFFSET + FRED_MAX_IDS[1];
    SymbolTable fred1 = Symtabs.register("fred", 1, catalog());
    iw = makeWriter(system().getSystemSymbolTable(), fred1);
    iw.writeSymbol("fred_2");
    iw.writeSymbol("localSym");
    byte[] bytes = outputByteArray();
    IonDatagram dg = loader().load(bytes);
    assertEquals(4, dg.systemSize());
    IonValue f2sym = dg.systemGet(2);
    IonValue local = dg.systemGet(3);
    checkSymbol("fred_2", FRED_ID_OFFSET + 2, f2sym);
    checkSymbol("localSym", local);
    SymbolTable symtab = f2sym.getSymbolTable();
    assertSame(symtab, local.getSymbolTable());
    SymbolTable[] importedTables = symtab.getImportedTables();
    assertEquals(1, importedTables.length);
    assertSame(fred1, importedTables[0]);
}
Also used : IonValue(com.amazon.ion.IonValue) IonDatagram(com.amazon.ion.IonDatagram) SymbolTable(com.amazon.ion.SymbolTable) Test(org.junit.Test)

Example 60 with IonValue

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

the class IonWriterTestCase method testWriteValueCantCopyFieldName.

@Test
public void testWriteValueCantCopyFieldName() throws Exception {
    IonStruct data = struct("{a:{b:10}}");
    IonValue a = data.get("a");
    IonReader ir = system().newReader(a);
    ir.next();
    iw = makeWriter();
    iw.stepIn(IonType.STRUCT);
    // field name not set
    thrown.expect(IllegalStateException.class);
    iw.writeValue(ir);
}
Also used : IonValue(com.amazon.ion.IonValue) IonStruct(com.amazon.ion.IonStruct) IonReader(com.amazon.ion.IonReader) Test(org.junit.Test)

Aggregations

IonValue (com.amazon.ion.IonValue)185 Test (org.junit.Test)115 IonSequence (com.amazon.ion.IonSequence)61 SymbolTable (com.amazon.ion.SymbolTable)21 IonDatagram (com.amazon.ion.IonDatagram)20 IonStruct (com.amazon.ion.IonStruct)18 IonInt (com.amazon.ion.IonInt)16 IOException (java.io.IOException)14 IonReader (com.amazon.ion.IonReader)13 IonSystem (com.amazon.ion.IonSystem)12 Result (software.amazon.qldb.Result)11 SymbolToken (com.amazon.ion.SymbolToken)10 ArrayList (java.util.ArrayList)10 IonString (com.amazon.ion.IonString)9 IonException (com.amazon.ion.IonException)7 IonType (com.amazon.ion.IonType)6 IonObjectMapper (com.fasterxml.jackson.dataformat.ion.IonObjectMapper)6 Event (com.amazon.tools.events.Event)5 com.amazon.ion.impl._Private_IonValue (com.amazon.ion.impl._Private_IonValue)4 EventType (com.amazon.tools.events.EventType)4