@Test
 public void testCreateNode() {
   final Transaction tx = restAPI.beginTx();
   Node n1 = restAPI.createNode(map("name", "node1"));
   Node n2 = restAPI.createNode(map("name", "node2"));
   final int count = countExistingNodes();
   assertEquals("only reference node", 1, count);
   tx.success();
   tx.finish();
   assertEquals("node1", n1.getProperty("name"));
   assertEquals("node1", loadRealNode(n1).getProperty("name"));
   assertEquals("node2", n2.getProperty("name"));
 }
  @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"));
  }
 @Test
 @Transactional
 public void testCreateNodeTypeWithProperties() throws Exception {
   Node person = neo4jTemplate.createNodeAs(Node.class, map("name", "name"));
   assertNotNull("created node", person);
   assertEquals("property created", "name", person.getProperty("name"));
 }
  @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());
  }
 private void assertTestPropertySet(Node node, String testName) {
   assertEquals(testName, node.getProperty("test", "not set"));
 }