Search in sources :

Example 6 with BsonTimestamp

use of org.bson.BsonTimestamp in project mongo-java-driver by mongodb.

the class JsonWriterTest method testTimestampShell.

@Test
public void testTimestampShell() {
    writer = new JsonWriter(stringWriter, JsonWriterSettings.builder().outputMode(JsonMode.SHELL).build());
    writer.writeStartDocument();
    writer.writeTimestamp("timestamp", new BsonTimestamp(1000, 1));
    writer.writeEndDocument();
    String expected = "{ \"timestamp\" : Timestamp(1000, 1) }";
    assertEquals(expected, stringWriter.toString());
}
Also used : BsonTimestamp(org.bson.BsonTimestamp) Test(org.junit.Test)

Example 7 with BsonTimestamp

use of org.bson.BsonTimestamp in project mongo-java-driver by mongodb.

the class JsonReaderTest method testTimestampStrict.

@Test
public void testTimestampStrict() {
    String json = "{ \"$timestamp\" : { \"t\" : 1234, \"i\" : 1 } }";
    bsonReader = new JsonReader(json);
    assertEquals(BsonType.TIMESTAMP, bsonReader.readBsonType());
    assertEquals(new BsonTimestamp(1234, 1), bsonReader.readTimestamp());
    assertEquals(AbstractBsonReader.State.DONE, bsonReader.getState());
}
Also used : BsonTimestamp(org.bson.BsonTimestamp) Test(org.junit.Test)

Aggregations

BsonTimestamp (org.bson.BsonTimestamp)7 Test (org.junit.Test)6 BsonDocument (org.bson.BsonDocument)2 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Date (java.util.Date)1 List (java.util.List)1 SingleMapReaderImpl (org.apache.drill.exec.vector.complex.impl.SingleMapReaderImpl)1 BsonDocumentReader (org.bson.BsonDocumentReader)1 BsonRegularExpression (org.bson.BsonRegularExpression)1 Document (org.bson.Document)1 Binary (org.bson.types.Binary)1 Code (org.bson.types.Code)1 CodeWithScope (org.bson.types.CodeWithScope)1 MaxKey (org.bson.types.MaxKey)1 MinKey (org.bson.types.MinKey)1 ObjectId (org.bson.types.ObjectId)1