Java Code Examples for org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf#writeCharSequence()
The following examples show how to use
org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf#writeCharSequence() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractByteBufTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test(expected = IndexOutOfBoundsException.class) public void testReaderIndexLargerThanWriterIndex() { String content1 = "hello"; String content2 = "world"; int length = content1.length() + content2.length(); ByteBuf buffer = newBuffer(length); buffer.setIndex(0, 0); buffer.writeCharSequence(content1, CharsetUtil.US_ASCII); buffer.markWriterIndex(); buffer.skipBytes(content1.length()); buffer.writeCharSequence(content2, CharsetUtil.US_ASCII); buffer.skipBytes(content2.length()); assertTrue(buffer.readerIndex() <= buffer.writerIndex()); try { buffer.resetWriterIndex(); } finally { buffer.release(); } }
Example 2
Source File: AbstractByteBufTest.java From flink with Apache License 2.0 | 6 votes |
@Test(expected = IndexOutOfBoundsException.class) public void testReaderIndexLargerThanWriterIndex() { String content1 = "hello"; String content2 = "world"; int length = content1.length() + content2.length(); ByteBuf buffer = newBuffer(length); buffer.setIndex(0, 0); buffer.writeCharSequence(content1, CharsetUtil.US_ASCII); buffer.markWriterIndex(); buffer.skipBytes(content1.length()); buffer.writeCharSequence(content2, CharsetUtil.US_ASCII); buffer.skipBytes(content2.length()); assertTrue(buffer.readerIndex() <= buffer.writerIndex()); try { buffer.resetWriterIndex(); } finally { buffer.release(); } }
Example 3
Source File: AbstractByteBufTest.java From flink with Apache License 2.0 | 6 votes |
@Test(expected = IndexOutOfBoundsException.class) public void testReaderIndexLargerThanWriterIndex() { String content1 = "hello"; String content2 = "world"; int length = content1.length() + content2.length(); ByteBuf buffer = newBuffer(length); buffer.setIndex(0, 0); buffer.writeCharSequence(content1, CharsetUtil.US_ASCII); buffer.markWriterIndex(); buffer.skipBytes(content1.length()); buffer.writeCharSequence(content2, CharsetUtil.US_ASCII); buffer.skipBytes(content2.length()); assertTrue(buffer.readerIndex() <= buffer.writerIndex()); try { buffer.resetWriterIndex(); } finally { buffer.release(); } }
Example 4
Source File: AbstractByteBufTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private void testWriteCharSequenceExpand(Charset charset) { ByteBuf buf = newBuffer(1); try { int writerIndex = buf.capacity() - 1; buf.writerIndex(writerIndex); int written = buf.writeCharSequence("AB", charset); assertEquals(writerIndex, buf.writerIndex() - written); } finally { buf.release(); } }
Example 5
Source File: AbstractByteBufTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private void testWriteReadCharSequence(Charset charset) { ByteBuf buf = newBuffer(1024); CharBuffer sequence = CharsetUtil.US_ASCII.equals(charset) ? ASCII_CHARS : EXTENDED_ASCII_CHARS; buf.writerIndex(1); int bytes = buf.writeCharSequence(sequence, charset); buf.readerIndex(1); assertEquals(sequence, CharBuffer.wrap(buf.readCharSequence(bytes, charset))); buf.release(); }
Example 6
Source File: AbstractByteBufTest.java From flink with Apache License 2.0 | 5 votes |
private void testWriteCharSequenceExpand(Charset charset) { ByteBuf buf = newBuffer(1); try { int writerIndex = buf.capacity() - 1; buf.writerIndex(writerIndex); int written = buf.writeCharSequence("AB", charset); assertEquals(writerIndex, buf.writerIndex() - written); } finally { buf.release(); } }
Example 7
Source File: AbstractByteBufTest.java From flink with Apache License 2.0 | 5 votes |
private void testWriteReadCharSequence(Charset charset) { ByteBuf buf = newBuffer(1024); CharBuffer sequence = CharsetUtil.US_ASCII.equals(charset) ? ASCII_CHARS : EXTENDED_ASCII_CHARS; buf.writerIndex(1); int bytes = buf.writeCharSequence(sequence, charset); buf.readerIndex(1); assertEquals(sequence, CharBuffer.wrap(buf.readCharSequence(bytes, charset))); buf.release(); }
Example 8
Source File: AbstractByteBufTest.java From flink with Apache License 2.0 | 5 votes |
private void testWriteCharSequenceExpand(Charset charset) { ByteBuf buf = newBuffer(1); try { int writerIndex = buf.capacity() - 1; buf.writerIndex(writerIndex); int written = buf.writeCharSequence("AB", charset); assertEquals(writerIndex, buf.writerIndex() - written); } finally { buf.release(); } }
Example 9
Source File: AbstractByteBufTest.java From flink with Apache License 2.0 | 5 votes |
private void testWriteReadCharSequence(Charset charset) { ByteBuf buf = newBuffer(1024); CharBuffer sequence = CharsetUtil.US_ASCII.equals(charset) ? ASCII_CHARS : EXTENDED_ASCII_CHARS; buf.writerIndex(1); int bytes = buf.writeCharSequence(sequence, charset); buf.readerIndex(1); assertEquals(sequence, CharBuffer.wrap(buf.readCharSequence(bytes, charset))); buf.release(); }