Search in sources :

Example 6 with IonLob

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

the class IonWriterTestCase method testWritingClob.

@Test
public void testWritingClob() throws Exception {
    byte[] data = new byte[256];
    for (int i = 0; i < data.length; i++) {
        data[i] = (byte) i;
    }
    iw = makeWriter();
    iw.writeBlob(data);
    iw.writeBlob(data, 10, 90);
    iw.writeClob(data);
    iw.writeClob(data, 20, 30);
    byte[] bytes = outputByteArray();
    IonDatagram dg = loader().load(bytes);
    assertEquals(4, dg.size());
    IonLob lob = (IonBlob) dg.get(0);
    assertTrue(Arrays.equals(data, lob.getBytes()));
    lob = (IonBlob) dg.get(1);
    assertEqualBytes(data, 10, 90, lob.getBytes());
    lob = (IonClob) dg.get(2);
    assertTrue(Arrays.equals(data, lob.getBytes()));
    lob = (IonClob) dg.get(3);
    assertEqualBytes(data, 20, 30, lob.getBytes());
}
Also used : IonDatagram(com.amazon.ion.IonDatagram) IonLob(com.amazon.ion.IonLob) IonBlob(com.amazon.ion.IonBlob) Test(org.junit.Test)

Example 7 with IonLob

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

the class IonWriterTestCase method testWriteLobNull.

@Test
public void testWriteLobNull() throws Exception {
    iw = makeWriter();
    iw.writeBlob(null);
    iw.writeBlob(null, 10, 12);
    iw.writeClob(null);
    iw.writeClob(null, 23, 1);
    IonDatagram dg = reload();
    for (int i = 0; i < 4; i++) {
        IonLob lob = (IonLob) dg.get(i);
        assertTrue("dg[" + i + "] not null", lob.isNullValue());
    }
}
Also used : IonDatagram(com.amazon.ion.IonDatagram) IonLob(com.amazon.ion.IonLob) Test(org.junit.Test)

Aggregations

IonLob (com.amazon.ion.IonLob)7 IonSequence (com.amazon.ion.IonSequence)3 IonStruct (com.amazon.ion.IonStruct)3 IonType (com.amazon.ion.IonType)3 IonDatagram (com.amazon.ion.IonDatagram)2 IonException (com.amazon.ion.IonException)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Test (org.junit.Test)2 IonBlob (com.amazon.ion.IonBlob)1 IonBool (com.amazon.ion.IonBool)1 IonFloat (com.amazon.ion.IonFloat)1 IonInt (com.amazon.ion.IonInt)1 IonSymbol (com.amazon.ion.IonSymbol)1 IonText (com.amazon.ion.IonText)1 IonTimestamp (com.amazon.ion.IonTimestamp)1 IonValue (com.amazon.ion.IonValue)1 SymbolTable (com.amazon.ion.SymbolTable)1 SymbolToken (com.amazon.ion.SymbolToken)1