Skip to content
Browse files

Update BsonDocumentsTest

Add new test readFrom_singleByteBuffer_withMultipleDocuments, which asserts
that multiple documents can be read from a ByteBuffer if it contains multiple
documents.
  • Loading branch information...
1 parent a4e908e commit e123eb8a316c9e50295a8b02a092ba824d9cf669 @kohanyirobert committed Nov 24, 2012
Showing with 20 additions and 0 deletions.
  1. +20 −0 src/test/java/com/github/kohanyirobert/ebson/BsonDocumentsTest.java
View
20 src/test/java/com/github/kohanyirobert/ebson/BsonDocumentsTest.java
@@ -8,6 +8,7 @@
import org.junit.Test;
+import java.nio.ByteBuffer;
import java.util.Map;
@SuppressWarnings("static-method")
@@ -91,4 +92,23 @@ public void of_multipleKeyValuePairs_withNullKey() {
public void of_multipleKeyValuePairs_withDuplicateKeys() {
BsonDocuments.of(KEY1, null, KEY1, null, KEY3, null);
}
+
+ @Test
+ public void readFrom_singleByteBuffer_withMultipleDocuments() {
+ BsonDocument document1 = BsonDocuments.of(KEY1, null);
+ BsonDocument document2 = BsonDocuments.of(KEY2, null);
+ BsonDocument document3 = BsonDocuments.of(KEY3, null);
+
+ ByteBuffer buffer = BUFFER.get();
+
+ BsonDocuments.writeTo(buffer, document1);
+ BsonDocuments.writeTo(buffer, document3);
+ BsonDocuments.writeTo(buffer, document2);
+
+ buffer.flip();
+
+ assertEquals(BsonDocuments.readFrom(buffer), document1);
+ assertEquals(BsonDocuments.readFrom(buffer), document3);
+ assertEquals(BsonDocuments.readFrom(buffer), document2);
+ }
}

0 comments on commit e123eb8

Please sign in to comment.
Something went wrong with that request. Please try again.