JcrTemplate extends JcrAccessor implements JcrOperations { protected String dumpNode(Node node) throws RepositoryException { StringBuffer buffer = new StringBuffer(); buffer.append(node.getPath()); PropertyIterator properties = node.getProperties(); while (properties.hasNext()) { Property property = properties.nextProperty(); buffer.append(property.getPath()).append("="); if (property.getDefinition().isMultiple()) { Value[] values = property.getValues(); for (int i = 0; i < values.length; i++) { if (i > 0) { buffer.append(","); } buffer.append(values[i].getString()); } } else { buffer.append(property.getString()); } buffer.append("\n"); } NodeIterator nodes = node.getNodes(); while (nodes.hasNext()) { Node child = nodes.nextNode(); buffer.append(dumpNode(child)); } return buffer.toString(); } JcrTemplate();  JcrTemplate(SessionFactory sessionFactory); @Override T execute(JcrCallback<T> action, boolean exposeNativeSession); @Override T execute(JcrCallback<T> callback); @Override void addLockToken(final String lock); @Override Object getAttribute(final String name); @Override String[] getAttributeNames(); @Override ContentHandler getImportContentHandler(final String parentAbsPath, final int uuidBehavior); @Override Item getItem(final String absPath); @Override String[] getLockTokens(); @Override String getNamespacePrefix(final String uri); @Override String[] getNamespacePrefixes(); @Override String getNamespaceURI(final String prefix); @Override @Deprecated Node getNodeByUUID(final String uuid); @Override Node getNodeByIdentifier(final String id); @Override Node getRootNode(); @Override String getUserID(); @Override ValueFactory getValueFactory(); @Override boolean hasPendingChanges(); @Override void importXML(final String parentAbsPath, final InputStream in, final int uuidBehavior); @Override void refresh(final boolean keepChanges); @Override void removeLockToken(final String lt); @Override void rename(final Node node, final String newName); @Override void setNamespacePrefix(final String prefix, final String uri); @Override boolean isLive(); @Override boolean itemExists(final String absPath); @Override void move(final String srcAbsPath, final String destAbsPath); @Override void save(); @Override String dump(final Node node); @Override QueryResult query(final Node node); @Override QueryResult query(final String statement); @Override QueryResult query(final String statement, final String language); @Override Map<String, QueryResult> query(final List<String> list); @Override Map<String, QueryResult> query(final List<String> list, final String language, final boolean ignoreErrors); boolean isAllowCreate(); void setAllowCreate(boolean allowCreate); boolean isExposeNativeSession(); void setExposeNativeSession(boolean exposeNativeSession);  }
@Test public void testDumpNode() throws RepositoryException { Node node = createNiceMock(Node.class); PropertyIterator iterator = createMock(PropertyIterator.class); NodeIterator iter = createMock(NodeIterator.class); expect(node.getPath()).andReturn("path"); expect(node.getProperties()).andReturn(iterator); expect(iterator.hasNext()).andReturn(false); expect(node.getNodes()).andReturn(iter); expect(iter.hasNext()).andReturn(false); expect(session.getRootNode()).andReturn(node); replay(session); replay(sessionFactory); replay(node); jcrTemplate.dump(null); verify(node); }