Java 类com.mongodb.DefaultDBDecoder 实例源码

项目:dropwizard-mongodb    文件:MongoClientFactoryTest.java   
public void correctlyExtractsMongoClientFromConfiguration() throws Exception {
    final Example example = factory.build(testFile);
    final MongoClient client = example.getMongoClient().build(environment);

    assertThat(client.getAddress().getHost()).isIn("localhost", "127.0.0.1");
    assertThat(client.getAddress().getPort()).isEqualTo(ServerAddress.defaultPort());
    assertThat(client.getCredentialsList()).isEmpty();

    final MongoClientOptions options = client.getMongoClientOptions();

    assertThat(options.getDbDecoderFactory()).isEqualTo(DefaultDBDecoder.FACTORY);
    assertThat(options.getDbEncoderFactory()).isEqualTo(DefaultDBEncoder.FACTORY);
    assertThat(options.getReadPreference()).isEqualTo(ReadPreference.primary());
    assertThat(options.getWriteConcern()).isEqualTo(WriteConcern.ACKNOWLEDGED);
    assertThat(options.getSocketFactory()).isEqualTo(SocketFactory.getDefault());
}
项目:morphia    文件:CustomConvertersTest.java   
/**
 * This test shows the full serialization, including bson encoding/decoding.
 */
@Test
public void testFullBSONSerialization() {
    final MyEntity entity = new MyEntity(1L, new ValueObject(2L));
    final DBObject dbObject = getMorphia().toDBObject(entity);

    final byte[] data = new DefaultDBEncoder().encode(dbObject);

    final DBObject decoded = new DefaultDBDecoder().decode(data, (DBCollection) null);
    final MyEntity actual = getMorphia().fromDBObject(getDs(), MyEntity.class, decoded);
    assertEquals(entity, actual);
}
项目:morphia    文件:DatastoreImpl.java   
@Override
public DBDecoderFactory getDecoderFact() {
    return decoderFactory != null ? decoderFactory : DefaultDBDecoder.FACTORY;
}