@Test
  public void testSetNodeProperties() {
    final Transaction tx = restAPI.beginTx();

    Node n1 = restAPI.createNode(map("name", "node1"));
    n1.setProperty("test", "true");
    n1.setProperty("test2", "stilltrue");
    tx.success();
    tx.finish();
    assertEquals("node1", n1.getProperty("name"));
    assertEquals("true", n1.getProperty("test"));
    assertEquals("stilltrue", n1.getProperty("test2"));
    assertEquals("true", loadRealNode(n1).getProperty("test"));
    assertEquals("stilltrue", loadRealNode(n1).getProperty("test2"));
  }
 @FixFor("MODE-1254")
 @Test
 public void shouldNotIncludeBinaryContentsInToString() throws Exception {
   altima = cache.findJcrNode(null, path("/Cars/Hybrid/Nissan Altima"));
   Node node = rootNode.addNode("nodeWithBinaryProperty", "nt:unstructured");
   String value = "This is the string value";
   Binary binaryValue =
       cache.session().getValueFactory().createBinary(new ByteArrayInputStream(value.getBytes()));
   node.setProperty("binProp", binaryValue);
   String toString = node.toString();
   assertThat(toString.indexOf("**binary-value") > 0, is(true));
 }
  @FixFor("MODE-1308")
  @Test
  public void shouldAllowAnyBinaryImplementation() throws Exception {
    Node node = rootNode.addNode("nodeWithBinaryProperty", "nt:unstructured");
    final String stringValue = "This is the string stringValue";
    Binary binaryValue =
        new Binary() {
          public InputStream getStream() throws RepositoryException {
            return new ByteArrayInputStream(stringValue.getBytes());
          }

          public int read(byte[] b, long position) throws IOException, RepositoryException {
            byte[] content = stringValue.getBytes();
            int length =
                b.length + position < content.length ? b.length : (int) (content.length - position);
            System.arraycopy(content, (int) position, b, 0, length);
            return length;
          }

          public long getSize() throws RepositoryException {
            return stringValue.getBytes().length;
          }

          public void dispose() {}
        };
    node.setProperty("binProp", binaryValue);
    Binary nodeValue = node.getProperty("binProp").getBinary();
    assertNotNull(nodeValue);
    assertEquals(stringValue.getBytes().length, nodeValue.getSize());
    byte[] buffer = new byte[100];
    int available;
    InputStream inputStream = nodeValue.getStream();
    ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
    while ((available = inputStream.read(buffer)) != -1) {
      byteOut.write(buffer, 0, available);
    }
    assertArrayEquals(stringValue.getBytes(), byteOut.toByteArray());
  }