@@ -49,20 +49,29 @@ public void tearDown() {
49
49
writer .close ();
50
50
}
51
51
52
- @ Test ( expected = BsonSerializationException . class )
52
+ @ Test
53
53
public void shouldThrowWhenMaxDocumentSizeIsExceeded () {
54
- writer .writeStartDocument ();
55
- writer .writeBinaryData ("b" , new BsonBinary (new byte [1024 ]));
56
- writer .writeEndDocument ();
54
+ try {
55
+ writer .writeStartDocument ();
56
+ writer .writeBinaryData ("b" , new BsonBinary (new byte [1024 ]));
57
+ writer .writeEndDocument ();
58
+ fail ();
59
+ } catch (BsonSerializationException e ) {
60
+ assertEquals ("Document size of 1037 is larger than maximum of 1024." , e .getMessage ());
61
+ }
57
62
}
58
63
59
- @ Test ( expected = BsonSerializationException . class )
64
+ @ Test
60
65
public void shouldThrowIfAPushedMaxDocumentSizeIsExceeded () {
61
- writer .writeStartDocument ();
62
- writer .pushMaxDocumentSize (10 );
63
- writer .writeStartDocument ("doc" );
64
- writer .writeString ("s" , "123456789" );
65
- writer .writeEndDocument ();
66
+ try {
67
+ writer .writeStartDocument ();
68
+ writer .pushMaxDocumentSize (10 );
69
+ writer .writeStartDocument ("doc" );
70
+ writer .writeString ("s" , "123456789" );
71
+ writer .writeEndDocument ();
72
+ } catch (BsonSerializationException e ) {
73
+ assertEquals ("Document size of 22 is larger than maximum of 10." , e .getMessage ());
74
+ }
66
75
}
67
76
68
77
@ Test
0 commit comments