Created
January 31, 2017 10:35
-
-
Save antofar/c41eba1fecc45794775b8467ce6fcb30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final int DEFAULT_BUFFER_SIZE = 1024 * 1024 * 4; | |
/** | |
* Test that bytes are written to the provided WriteStream correctly and the callback returns | |
* the excepted result. | |
*/ | |
@Test | |
public void happyPathWriteWithNotAlignedBuffer() { | |
byte[] bytes = "123456789ABCDEF".getBytes(); | |
ByteBuffer byteBuffer = ByteBuffer.allocate(DEFAULT_BUFFER_SIZE); | |
byteBuffer.put(bytes); | |
byteBuffer.flip(); | |
ResultCallback<Integer> resultCallback = new ResultCallback<>(); | |
WriteStreamMock writeStreamMock = new WriteStreamMock(); | |
GridFSOutputStream outputStream = GridFSOutputStream.create(writeStreamMock); | |
outputStream.write(byteBuffer, resultCallback); | |
Assert.assertTrue(resultCallback.succeeded()); | |
Assert.assertEquals(bytes.length, resultCallback.getResult(), 0); | |
Assert.assertTrue(Arrays.equals(writeStreamMock.buffer.getBytes(), bytes)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment