Package com.mongodb

Examples of com.mongodb.DefaultDBEncoder$DefaultFactory


   
    @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)));
        assertTrue(result instanceof WriteResult);
        DBObject b = testCollection.findOne("testInsertBsonString");
        assertNotNull("No record with 'testInsertBsonString' _id", b);
    }
View Full Code Here


   
    @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)));
        assertTrue(result instanceof WriteResult);
        DBObject b = testCollection.findOne("testInsertBsonString");
        assertNotNull("No record with 'testInsertBsonString' _id", b);
    }
View Full Code Here

        return a == b;
    }

    public static long calculateSize(BSONObject document) {
        return new DefaultDBEncoder().encode(document).length;
    }
View Full Code Here

  @Test @Ignore
  public void testFullBSONSerialization() {
    final MyEntity entity = new MyEntity(1l, new A(2));
    final DBObject dbObject = morphia.toDBObject(entity);

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

    final DBObject decoded = new DefaultDBDecoder().decode(data,
        (DBCollection) null);
    // fails with a
    // com.github.jmkgreen.morphia.mapping.MappingException: No usable
View Full Code Here

    @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(MyEntity.class, decoded);
        assertEquals(entity, actual);
    }
View Full Code Here

TOP

Related Classes of com.mongodb.DefaultDBEncoder$DefaultFactory

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.