use of com.amazon.ion.impl.IonBinary.BufferManager in project ion-java by amzn.
the class ByteBufferTest method testLargeInsertion.
@Test
public void testLargeInsertion() {
BufferManager buf = new BufferManager();
IonBinary.Writer writer = buf.openWriter();
// Write enough data to overflow the first block
byte[] initialData = new byte[BlockedBuffer._defaultBlockSizeMin + 5];
// Now insert lots of stuff at the beginning
try {
writer.write(initialData, 0, initialData.length);
writer.setPosition(0);
writer.insert(5000);
} catch (IOException e) {
throw new IonException(e);
}
}
use of com.amazon.ion.impl.IonBinary.BufferManager in project ion-java by amzn.
the class _Private_Utils method loadStreamBytes.
public static byte[] loadStreamBytes(InputStream in) throws IOException {
BufferManager buffer = new BufferManager(in);
Reader bufReader = buffer.reader();
bufReader.sync();
bufReader.setPosition(0);
byte[] bytes = bufReader.getBytes();
return bytes;
}
use of com.amazon.ion.impl.IonBinary.BufferManager in project ion-java by amzn.
the class ByteBufferTest method testSmallInsertion.
@Test
public void testSmallInsertion() {
BufferManager buf = new BufferManager();
IonBinary.Writer writer = buf.openWriter();
// Write enough data to overflow the first block
byte[] initialData = new byte[BlockedBuffer._defaultBlockSizeMin + 5];
// Now insert some stuff at the beginning
try {
writer.write(initialData, 0, initialData.length);
writer.setPosition(0);
writer.insert(10);
} catch (IOException e) {
throw new IonException(e);
}
}
use of com.amazon.ion.impl.IonBinary.BufferManager in project ion-java by amzn.
the class ByteBufferTest method testUnicodeCodepointOverflow.
@Test
public void testUnicodeCodepointOverflow() {
BufferManager buf = new BufferManager();
IonBinary.Writer writer = buf.openWriter();
try {
writer.writeStringData(new String(new char[] { 0xd799 }, 0, 1));
writer.writeStringData(new String(new char[] { 0xe000 }, 0, 1));
} catch (Exception e) {
fail("Unexpected exception: " + e.getMessage());
}
try {
writer.writeStringData(new String(new char[] { 0xd800 }, 0, 1));
fail("Successfully parsed a partial surrogate");
} catch (Exception e) {
}
try {
writer.writeStringData(new String(new char[] { 0xdfff }, 0, 1));
fail("Successfully parsed a partial surrogate");
} catch (Exception e) {
}
}
Aggregations