Examples of BasicBSONDecoder


Examples of org.bson.BasicBSONDecoder

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        for ( int i=0; i<n; i++ )
            out.write( b );
       
        ByteArrayInputStream in = new ByteArrayInputStream( out.toByteArray() );
        BSONDecoder d = new BasicBSONDecoder();
        for ( int i=0; i<n; i++ ){
            BSONObject x = d.readObject( in );
            assertEquals( orig , x );
        }
        assertEquals( -1 , in.read() );
    }
View Full Code Here

Examples of org.bson.BasicBSONDecoder

        OutputBuffer buf = new BasicOutputBuffer();

        encoder.writeObject(buf, o);

        DefaultDBCallback cb = new DefaultDBCallback( null );
        BSONDecoder decoder = new BasicBSONDecoder();
        decoder.decode( buf.toByteArray() , cb );
        DBObject read = cb.dbget();

        assertEquals("{\"!\":{\"$ref\":\"hello\",\"$id\":\"world\"}}", read.toString().replaceAll( " +" , "" ));
    }
View Full Code Here

Examples of org.bson.BasicBSONDecoder

    om.writeValue(baos, m);

    byte[] r = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(r);

    BSONDecoder decoder = new BasicBSONDecoder();
    BSONObject bo = decoder.readObject(bais);
   
    return bo.get("data");
  }
View Full Code Here

Examples of org.bson.BasicBSONDecoder

    assertTrue(baos.size() > DynamicOutputBuffer.DEFAULT_BUFFER_SIZE * 3);
  }
 
  private void assertRaw(byte[] r) throws Exception {
    ByteArrayInputStream bais = new ByteArrayInputStream(r);
    BSONDecoder decoder = new BasicBSONDecoder();
    BSONObject obj = decoder.readObject(bais);
    byte[] o = (byte[])obj.get("Test");
    CharBuffer buf = ByteBuffer.wrap(o).order(ByteOrder.LITTLE_ENDIAN).asCharBuffer();
    assertEquals(2, buf.remaining());
    char a = buf.get();
    char b = buf.get();
View Full Code Here

Examples of org.bson.BasicBSONDecoder

    gen.writeEndObject();
    gen.close();
   
    byte[] r = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(r);
    BSONDecoder decoder = new BasicBSONDecoder();
    BSONObject obj = decoder.readObject(bais);
    byte[] o = (byte[])obj.get("Test");
    assertEquals(2, o.length);
    assertEquals((byte)1, o[0]);
    assertEquals((byte)2, o[1]);
  }
View Full Code Here

Examples of org.bson.BasicBSONDecoder

    gen.writeString("a\u20AC\u00A2\u00A2bb");
    gen.writeEndObject();
    gen.close();
   
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    BSONDecoder decoder = new BasicBSONDecoder();
    BSONObject obj = decoder.readObject(bais);
    String s = (String)obj.get("a\u20AC\u00A2\u00A2bb");
    assertEquals("a\u20AC\u00A2\u00A2bb", s);
  }
View Full Code Here

Examples of org.bson.BasicBSONDecoder

    om.writeValue(baos, data);

    byte[] r = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(r);

    BSONDecoder decoder = new BasicBSONDecoder();
    return decoder.readObject(bais);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.