コード例 #1
0
  @Test
  public void objectNotSavedUntilFlush() throws Exception {
    writer.writeField("number", 1023);
    writer.writeField("string", "testing");

    final DBCollection instances = testDb.getCollection(SPEC_NAME);
    assertEquals(0, instances.getCount());
  }
コード例 #2
0
  @Test
  public void writeFields() throws Exception {
    // writer.writeObjectType(SPEC_NAME);
    writer.writeOid(RootOidDefault.deString(SPEC_NAME + ":" + "D01", new OidMarshaller()));
    writer.writeField("number", 1023);
    writer.writeField("string", "testing");
    writer.flush();

    final DBCollection instances = testDb.getCollection(SPEC_NAME);
    assertEquals(1, instances.getCount());
    final DBObject object = instances.findOne();
    assertEquals(SPEC_NAME + ":" + "D01", object.get("_oid"));
    assertEquals("1023", object.get("number"));
    assertEquals("testing", object.get("string"));
  }