@Override public Binary createBinary(byte type, byte[] data) { return new Binary(type, data); }
@Override public Binary createBinary(byte type, byte[] data) { return new Binary(type, data); }
@Test public void shouldRoundTripSimpleBsonObjectWithBinary1() { byte[] data = new byte[] {0x16, 0x00, 0x00, 0x00, 0x02, 0x68, 0x65, 0x6c}; input = new BasicDocument("foo", new Binary(data)); assertRoundtrip(input); }
@Test //Fix-For MODE-1575 public void shouldRoundTripSimpleBsonObjectWithBinary2() throws Exception { ByteArrayOutputStream bos = new ByteArrayOutputStream(); InputStream is = getClass().getClassLoader().getResourceAsStream("binary"); assertNotNull(is); try { byte[] buff = new byte[1024]; int read; while ((read = is.read(buff)) != -1) { bos.write(buff, 0, read); } } finally { bos.close(); is.close(); } input = new BasicDocument("foo", new Binary(bos.toByteArray())); assertRoundtrip(input); }
@Test public void shouldCorrectlyWriteBinaryValue() { byte[] data = new byte[] {0x00, 0x01, 0x02, 0x03, 0x04, 0x05}; @SuppressWarnings( "deprecation" ) Binary binary = new Binary(Bson.BinaryType.BINARY, data); String expected = "{ \"$type\" : 2 , \"$base64\" : \"AAECAwQF\" }"; String actual = writer.write(binary); // print =true; assertSame(expected, actual); }
@Test public void shouldParseDocumentWithBinary() throws Exception { byte[] bytes = new byte[] {0x13, 0x22, 0x53, 0x00}; Binary obj = new Binary(Bson.BinaryType.MD5, bytes); value = parser(writer.write(obj)).parseValue(); assertEquals(obj, value); }
org.modeshape.jcr.value.BinaryValue binary = (org.modeshape.jcr.value.BinaryValue)value; if (binary instanceof InMemoryBinaryValue) { return new Binary(((InMemoryBinaryValue)binary).getBytes());
org.modeshape.jcr.value.BinaryValue binary = (org.modeshape.jcr.value.BinaryValue)value; if (binary instanceof InMemoryBinaryValue) { return new Binary(((InMemoryBinaryValue)binary).getBytes());