|
26 | 26 | import org.bson.types.ObjectId;
|
27 | 27 | import org.junit.Test;
|
28 | 28 |
|
| 29 | +import java.util.Date; |
| 30 | + |
29 | 31 | import static org.junit.Assert.assertArrayEquals;
|
30 | 32 | import static org.junit.Assert.assertEquals;
|
| 33 | +import static org.junit.Assert.assertTrue; |
31 | 34 |
|
32 | 35 |
|
33 | 36 | public class JsonReaderTest {
|
@@ -704,22 +707,43 @@ public void testDateTimeConstructorWithNew() {
|
704 | 707 |
|
705 | 708 | @Test
|
706 | 709 | public void testEmptyDateTimeConstructorWithNew() {
|
| 710 | + long currentTime = new Date().getTime(); |
707 | 711 | String json = "new Date()";
|
708 | 712 | bsonReader = new JsonReader(json);
|
709 | 713 | assertEquals(BsonType.DATE_TIME, bsonReader.readBsonType());
|
710 |
| - bsonReader.readDateTime(); |
| 714 | + assertTrue(bsonReader.readDateTime() >= currentTime); |
711 | 715 | assertEquals(AbstractBsonReader.State.DONE, bsonReader.getState());
|
712 | 716 | }
|
713 | 717 |
|
714 | 718 | @Test
|
715 | 719 | public void testEmptyDateTimeConstructor() {
|
| 720 | + long currentTime = new Date().getTime(); |
716 | 721 | String json = "Date()";
|
717 | 722 | bsonReader = new JsonReader(json);
|
718 | 723 | assertEquals(BsonType.DATE_TIME, bsonReader.readBsonType());
|
719 |
| - bsonReader.readDateTime(); |
| 724 | + assertTrue(bsonReader.readDateTime() >= currentTime); |
| 725 | + assertEquals(AbstractBsonReader.State.DONE, bsonReader.getState()); |
| 726 | + } |
| 727 | + |
| 728 | + @Test |
| 729 | + public void testEmptyISODateTimeConstructorWithNew() { |
| 730 | + long currentTime = new Date().getTime(); |
| 731 | + String json = "new ISODate()"; |
| 732 | + bsonReader = new JsonReader(json); |
| 733 | + assertEquals(BsonType.DATE_TIME, bsonReader.readBsonType()); |
| 734 | + assertTrue(bsonReader.readDateTime() >= currentTime); |
720 | 735 | assertEquals(AbstractBsonReader.State.DONE, bsonReader.getState());
|
721 | 736 | }
|
722 | 737 |
|
| 738 | + @Test |
| 739 | + public void testEmptyISODateTimeConstructor() { |
| 740 | + long currentTime = new Date().getTime(); |
| 741 | + String json = "ISODate()"; |
| 742 | + bsonReader = new JsonReader(json); |
| 743 | + assertEquals(BsonType.DATE_TIME, bsonReader.readBsonType()); |
| 744 | + assertTrue(bsonReader.readDateTime() >= currentTime); |
| 745 | + assertEquals(AbstractBsonReader.State.DONE, bsonReader.getState()); |
| 746 | + } |
723 | 747 |
|
724 | 748 | @Test
|
725 | 749 | public void testRegExp() {
|
|
0 commit comments