Package de.undercouch.bson4jackson.types

Examples of de.undercouch.bson4jackson.types.ObjectId


    o.put("Regex", p);
   
    Map<?, ?> data = parseBsonObject(o);
    assertEquals(new Timestamp(0xAABB, 0xCCDD), data.get("Timestamp"));
    assertEquals(new de.undercouch.bson4jackson.types.Symbol("Test"), data.get("Symbol"));
    ObjectId oid = (ObjectId)data.get("ObjectId");
    assertEquals(Integer.MAX_VALUE, oid.getTime());
    assertEquals(-2, oid.getMachine());
    assertEquals(Integer.MIN_VALUE, oid.getInc());
    Pattern p2 = (Pattern)data.get("Regex");
    assertEquals(p.flags(), p2.flags());
    assertEquals(p.pattern(), p2.pattern());
  }
View Full Code Here


   */
  protected ObjectId readObjectId() throws IOException {
    int time = ByteOrderUtil.flip(_in.readInt());
    int machine = ByteOrderUtil.flip(_in.readInt());
    int inc = ByteOrderUtil.flip(_in.readInt());
    return new ObjectId(time, machine, inc);
  }
View Full Code Here

   * Tests {@link BsonObjectIdSerializer}
   * @throws Exception if something goes wrong
   */
  @Test
  public void objectId() throws Exception {
    ObjectId id = new ObjectId(1, 2, 3);
    org.bson.types.ObjectId roid = (org.bson.types.ObjectId)generateAndParse(id);
    assertEquals(id.getTime(), roid.getTimeSecond());
    assertEquals(id.getMachine(), roid.getMachine());
    assertEquals(id.getInc(), roid.getInc());
  }
View Full Code Here

  }

  @Test
  public void objectIds() throws Exception {
    Map<String, Object> data = new LinkedHashMap<String, Object>();
    ObjectId objectId = new ObjectId((int) (System.currentTimeMillis() / 1000), new Random().nextInt(), 100);
    data.put("_id", objectId);

    BSONObject obj = generateAndParse(data);

    org.bson.types.ObjectId result = (org.bson.types.ObjectId) obj.get("_id");
    assertNotNull(result);
    assertEquals(objectId.getTime(), result.getTimeSecond());
    assertEquals(objectId.getMachine(), result.getMachine());
    assertEquals(objectId.getInc(), result.getInc());
  }
View Full Code Here

TOP

Related Classes of de.undercouch.bson4jackson.types.ObjectId

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.