@Test public void testGetMemoryChunkList() throws IOException { String value = RandomStringUtils.randomAlphanumeric(10000); outputStream.write(value.getBytes()); byte[] totalOutput = outputStream.toByteArray(); List<MemoryChunk> chunkList = outputStream.getMemoryChunkList(); int offset = 0; int byteToRead; for (final MemoryChunk temp : chunkList) { byteToRead = temp.getBuffer().remaining(); byte[] output = new byte[byteToRead]; temp.getBuffer().get(output, 0, byteToRead); byte[] expected = Arrays.copyOfRange(totalOutput, offset, offset+byteToRead); assertEquals(new String(expected), new String(output)); offset += byteToRead; } }
public List<MemoryChunk> getMemoryChunkList() { List<MemoryChunk> result = new LinkedList<>(); for (final MemoryChunk chunk: dataList) { final MemoryChunk dupChunk = chunk.duplicate(); dupChunk.getBuffer().flip(); result.add(dupChunk); } return result; }
DirectByteBufferOutputStream extends OutputStream { public List<MemoryChunk> getMemoryChunkList() { List<MemoryChunk> result = new LinkedList<>(); for (final MemoryChunk chunk: dataList) { final MemoryChunk dupChunk = chunk.duplicate(); dupChunk.getBuffer().flip(); result.add(dupChunk); } return result; } }
DirectByteBufferOutputStream extends OutputStream { public List<MemoryChunk> getMemoryChunkList() { List<MemoryChunk> result = new LinkedList<>(); for (final MemoryChunk chunk: dataList) { final MemoryChunk dupChunk = chunk.duplicate(); dupChunk.getBuffer().flip(); result.add(dupChunk); } return result; } DirectByteBufferOutputStream(final MemoryPoolAssigner memoryPoolAssigner); }
DirectByteBufferOutputStream extends OutputStream { public List<MemoryChunk> getMemoryChunkList() { List<MemoryChunk> result = new LinkedList<>(); for (final MemoryChunk chunk: dataList) { final MemoryChunk dupChunk = chunk.duplicate(); dupChunk.getBuffer().flip(); result.add(dupChunk); } return result; } DirectByteBufferOutputStream(final MemoryPoolAssigner memoryPoolAssigner); @Override void write(final int b); @Override void write(final byte[] b); @Override void write(final byte[] b, final int off, final int len); List<MemoryChunk> getMemoryChunkList(); int size(); @Override void close(); }
DirectByteBufferOutputStream extends OutputStream { public List<MemoryChunk> getMemoryChunkList() { List<MemoryChunk> result = new LinkedList<>(); for (final MemoryChunk chunk: dataList) { final MemoryChunk dupChunk = chunk.duplicate(); dupChunk.getBuffer().flip(); result.add(dupChunk); } return result; } DirectByteBufferOutputStream(final MemoryPoolAssigner memoryPoolAssigner); @Override void write(final int b); @Override void write(final byte[] b); @Override void write(final byte[] b, final int off, final int len); List<MemoryChunk> getMemoryChunkList(); int size(); @Override void close();  }