本文整理汇总了Java中com.mongodb.DefaultDBEncoder类的典型用法代码示例。如果您正苦于以下问题:Java DefaultDBEncoder类的具体用法?Java DefaultDBEncoder怎么用?Java DefaultDBEncoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultDBEncoder类属于com.mongodb包,在下文中一共展示了DefaultDBEncoder类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: correctlyExtractsMongoClientFromConfiguration
import com.mongodb.DefaultDBEncoder; //导入依赖的package包/类
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());
}
开发者ID:acu-dev,项目名称:dropwizard-mongodb,代码行数:17,代码来源:MongoClientFactoryTest.java
示例2: testInsertBsonInputStream
import com.mongodb.DefaultDBEncoder; //导入依赖的package包/类
@Test
public void testInsertBsonInputStream() {
assertEquals(0, testCollection.count());
DefaultDBEncoder encoder = new DefaultDBEncoder();
BSONObject bsonObject = new BasicDBObject();
bsonObject.put("_id", "testInsertBsonString");
Object result = template.requestBody("direct:insertJsonString", new ByteArrayInputStream(encoder.encode(bsonObject)));
DBObject b = testCollection.find(new BasicDBObject("_id", "testInsertBsonString")).first();
assertNotNull("No record with 'testInsertBsonString' _id", b);
}
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:MongoDbConversionsTest.java
示例3: testFullBSONSerialization
import com.mongodb.DefaultDBEncoder; //导入依赖的package包/类
/**
* 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);
}
开发者ID:mongodb,项目名称:morphia,代码行数:15,代码来源:CustomConvertersTest.java
注:本文中的com.mongodb.DefaultDBEncoder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论