Search in sources :

Example 91 with IonDatagram

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

the class RoundTripStreamingTest method makeTree.

private IonDatagram makeTree(byte[] buffer) throws IOException {
    IonReader in = makeIterator(buffer);
    IonDatagram dg = system().newDatagram();
    IonWriter tw = system().newTreeWriter(dg);
    tw.writeValues(in);
    // IonValue v = tw.getContentAsIonValue();
    in.close();
    return dg;
}
Also used : IonDatagram(com.amazon.ion.IonDatagram) IonReader(com.amazon.ion.IonReader) IonWriter(com.amazon.ion.IonWriter)

Example 92 with IonDatagram

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

the class SeekableReaderTest method testWalkingBackwards.

@Test
public void testWalkingBackwards() {
    if (getStreamingMode() == StreamingMode.NEW_STREAMING_INCREMENTAL) {
        // See ion-java/issues/382 and ion-java/issues/383.
        return;
    }
    String text = "null true 3 4e0 5.0 6666-06-06T '7' \"8\" {{\"\"}} {{}} [] () {}";
    IonDatagram dg = loader().load(text);
    Span[] positions = new Span[dg.size()];
    read(text);
    for (int i = 0; i < dg.size(); i++) {
        assertEquals(dg.get(i).getType(), in.next());
        positions[i] = sr.currentSpan();
    }
    expectEof();
    checkSpans(dg, positions);
    // Collect spans *after* extracting scalar body.
    read(text);
    for (int i = 0; i < dg.size(); i++) {
        IonType t = in.next();
        assertEquals(dg.get(i).getType(), t);
        if (!IonType.isContainer(t)) {
            TestUtils.consumeCurrentValue(in);
        }
        positions[i] = sr.currentSpan();
    }
    expectTopEof();
    checkSpans(dg, positions);
}
Also used : IonType(com.amazon.ion.IonType) IonDatagram(com.amazon.ion.IonDatagram) Span(com.amazon.ion.Span) Test(org.junit.Test)

Aggregations

IonDatagram (com.amazon.ion.IonDatagram)92 Test (org.junit.Test)77 IonValue (com.amazon.ion.IonValue)20 SymbolTable (com.amazon.ion.SymbolTable)18 IonReader (com.amazon.ion.IonReader)17 IonString (com.amazon.ion.IonString)15 IonStruct (com.amazon.ion.IonStruct)13 IonWriter (com.amazon.ion.IonWriter)11 IonSymbol (com.amazon.ion.IonSymbol)6 IonSystem (com.amazon.ion.IonSystem)6 IonLoader (com.amazon.ion.IonLoader)5 IonType (com.amazon.ion.IonType)5 SimpleCatalog (com.amazon.ion.system.SimpleCatalog)5 BlobTest (com.amazon.ion.BlobTest)4 ClobTest (com.amazon.ion.ClobTest)4 IntTest (com.amazon.ion.IntTest)4 IonList (com.amazon.ion.IonList)4 IonTextWriterBuilder (com.amazon.ion.system.IonTextWriterBuilder)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 BinaryTest (com.amazon.ion.BinaryTest)2