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());
}
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());
}
}
Aggregations