protected void print() throws RepositoryException { print(session().getRootNode(), true); }
protected void assertNoNode( String path ) throws RepositoryException { // Verify that the parent node does exist now ... assertThat("Did not expect to find '" + path + "'", session().getRootNode().hasNode(relativePath(path)), is(false)); try { session().getNode(path); fail("Did not expect to find node at \"" + path + "\""); } catch (PathNotFoundException e) { // expected } }
protected Node assertNode( String path ) throws RepositoryException { if (print && !session().getRootNode().hasNode(path)) { // We won't find the node, so print out the information ... Node parent = session().getRootNode(); for (Segment segment : path(path)) { if (!parent.hasNode(asString(segment))) { System.out.println("Unable to find '" + path + "'; lowest node is '" + parent.getPath() + "'"); break; } parent = parent.getNode(asString(segment)); } } Node node = session().getNode(path); assertThat(node, is(notNullValue())); // Verify that the path can be found via navigating ... if (path.trim().length() == 0) { // This is the root path, so of course it exists ... assertThat(session().getRootNode(), is(notNullValue())); } else { } return node; }
protected void addMixinRecursively( String path, String... nodeTypes ) throws RepositoryException { Node node = session().getRootNode().getNode(relativePath(path)); addMixin(node, true, nodeTypes); }
protected Node addMixin( String path, String... nodeTypes ) throws RepositoryException { Node node = session().getRootNode().getNode(relativePath(path)); return addMixin(node, false, nodeTypes); }
protected void navigate( String path ) throws RepositoryException { Node node = session().getRootNode().getNode(relativePath(path)); navigate(node, true); }
protected Path path( String path ) { return session().context().getValueFactories().getPathFactory().create(path); }
protected String asString( Object value ) { return session().context().getValueFactories().getStringFactory().create(value); }
protected Name name( String name ) { return session().context().getValueFactories().getNameFactory().create(name); }
protected AccessControlList acl( String path ) throws Exception { AccessControlManager acm = session().getAccessControlManager(); AccessControlPolicyIterator it = acm.getApplicablePolicies(path); if (it.hasNext()) { return (AccessControlList)it.nextAccessControlPolicy(); } return (AccessControlList)acm.getPolicies(path)[0]; }
protected QueryResult assertJcrSql2Query( String sql, long expectedRowCount ) throws RepositoryException { Query query = session().getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2); QueryResult results = query.execute(); printMessage(query.getStatement()); ValidateQuery.validateQuery().printDetail(print).rowCount(expectedRowCount).validate(query, results); return results; }