29
29
30
30
import java .text .ParsePosition ;
31
31
import java .text .SimpleDateFormat ;
32
- import java .util .Arrays ;
33
32
import java .util .Date ;
34
33
import java .util .List ;
35
34
import java .util .Locale ;
36
35
36
+ import static java .util .Arrays .asList ;
37
37
import static org .junit .Assert .assertArrayEquals ;
38
38
import static org .junit .Assert .assertEquals ;
39
39
import static org .junit .Assert .assertTrue ;
@@ -262,7 +262,6 @@ public void testHexData() {
262
262
bsonReader = new JsonReader (json );
263
263
assertEquals (BsonType .BINARY , bsonReader .readBsonType ());
264
264
BsonBinary binary = bsonReader .readBinaryData ();
265
- byte [] bytes = binary .getData ();
266
265
assertArrayEquals (expectedBytes , binary .getData ());
267
266
assertEquals (AbstractBsonReader .State .DONE , bsonReader .getState ());
268
267
}
@@ -274,7 +273,6 @@ public void testHexDataWithNew() {
274
273
bsonReader = new JsonReader (json );
275
274
assertEquals (BsonType .BINARY , bsonReader .readBsonType ());
276
275
BsonBinary binary = bsonReader .readBinaryData ();
277
- byte [] bytes = binary .getData ();
278
276
assertArrayEquals (expectedBytes , binary .getData ());
279
277
assertEquals (AbstractBsonReader .State .DONE , bsonReader .getState ());
280
278
}
@@ -309,7 +307,7 @@ public void testNumberLongExtendedJson() {
309
307
310
308
@ Test
311
309
public void testNumberLong () {
312
- List <String > jsonTexts = Arrays . asList (
310
+ List <String > jsonTexts = asList (
313
311
"NumberLong(123)" ,
314
312
"NumberLong(\" 123\" )" ,
315
313
"new NumberLong(123)" ,
@@ -324,7 +322,7 @@ public void testNumberLong() {
324
322
325
323
@ Test
326
324
public void testNumberInt () {
327
- List <String > jsonTexts = Arrays . asList (
325
+ List <String > jsonTexts = asList (
328
326
"NumberInt(123)" ,
329
327
"NumberInt(\" 123\" )" ,
330
328
"new NumberInt(123)" ,
@@ -432,22 +430,30 @@ public void testJavaScriptWithScope() {
432
430
433
431
@ Test
434
432
public void testMaxKey () {
435
- String json = "{ \" $maxKey\" : 1 }" ;
436
- bsonReader = new JsonReader (json );
437
- assertEquals (BsonType .MAX_KEY , bsonReader .readBsonType ());
438
- bsonReader .readMaxKey ();
439
- assertEquals (AbstractBsonReader .State .DONE , bsonReader .getState ());
440
-
433
+ for (String maxKeyJson : asList ("{ \" $maxKey\" : 1 }" , "MaxKey" , "MaxKey()" , "new MaxKey" , "new MaxKey()" )) {
434
+ String json = "{ maxKey : " + maxKeyJson + " }" ;
435
+ bsonReader = new JsonReader (json );
436
+ bsonReader .readStartDocument ();
437
+ assertEquals ("maxKey" , bsonReader .readName ());
438
+ assertEquals (BsonType .MAX_KEY , bsonReader .getCurrentBsonType ());
439
+ bsonReader .readMaxKey ();
440
+ bsonReader .readEndDocument ();
441
+ assertEquals (AbstractBsonReader .State .DONE , bsonReader .getState ());
442
+ }
441
443
}
442
444
443
445
@ Test
444
446
public void testMinKey () {
445
- String json = "{ \" $minKey\" : 1 }" ;
446
- bsonReader = new JsonReader (json );
447
- assertEquals (BsonType .MIN_KEY , bsonReader .readBsonType ());
448
- bsonReader .readMinKey ();
449
- assertEquals (AbstractBsonReader .State .DONE , bsonReader .getState ());
450
-
447
+ for (String minKeyJson : asList ("{ \" $minKey\" : 1 }" , "MinKey" , "MinKey()" , "new MinKey" , "new MinKey()" )) {
448
+ String json = "{ minKey : " + minKeyJson + " }" ;
449
+ bsonReader = new JsonReader (json );
450
+ bsonReader .readStartDocument ();
451
+ assertEquals ("minKey" , bsonReader .readName ());
452
+ assertEquals (BsonType .MIN_KEY , bsonReader .getCurrentBsonType ());
453
+ bsonReader .readMinKey ();
454
+ bsonReader .readEndDocument ();
455
+ assertEquals (AbstractBsonReader .State .DONE , bsonReader .getState ());
456
+ }
451
457
}
452
458
453
459
@ Test
0 commit comments