use of javax.jcr.ItemVisitor in project jackrabbit by apache.
the class NodeTypesInContentTest method testDefaultValues.
/**
* Test for <a href="https://issues.apache.org/jira/browse/JCR-1964">JCR-1964</a>
*
* @throws javax.jcr.RepositoryException If an exception occurs.
*/
public void testDefaultValues() throws RepositoryException {
ItemVisitor visitor = new TraversingItemVisitor.Default() {
public void visit(Property property) throws RepositoryException {
if (JcrConstants.JCR_DEFAULTVALUES.equals(property.getName())) {
int type = property.getType();
Value[] vs = property.getValues();
for (int i = 0; i < vs.length; i++) {
assertEquals("Property type must match the value(s) type", type, vs[i].getType());
}
}
}
};
Node start = (Node) superuser.getItem("/jcr:system/jcr:nodeTypes");
visitor.visit(start);
}
use of javax.jcr.ItemVisitor in project jackrabbit by apache.
the class NodeReadMethodsTest method testAccept.
/**
*/
public void testAccept() throws RepositoryException {
final Node n = testRootNode;
ItemVisitor itemVisitor = new ItemVisitor() {
public void visit(Property property) {
fail("Wrong accept method executed.");
}
public void visit(Node node) throws RepositoryException {
assertTrue("Visited node is not the same as the one passed in method visit(Node)", n.isSame(node));
}
};
n.accept(itemVisitor);
}
use of javax.jcr.ItemVisitor in project jackrabbit by apache.
the class PropertyReadMethodsTest method testAccept.
/**
* Tests if a Property calls the correct visit method on an {@link
* ItemVisitor}.
*/
public void testAccept() throws RepositoryException {
final Property p = property;
ItemVisitor itemVisitor = new ItemVisitor() {
public void visit(Property property) throws RepositoryException {
assertTrue("Visited Property is not the same as the one returned by visit(Property).", p.isSame(property));
}
public void visit(Node node) {
fail("Wrong accept method executed.");
}
};
p.accept(itemVisitor);
}
use of javax.jcr.ItemVisitor in project jackrabbit by apache.
the class AbstractDeepTreeTest method beforeSuite.
@Override
protected void beforeSuite() throws Exception {
adminSession = getRepository().login(getCredentials());
String name = getClass().getSimpleName();
Node rn = adminSession.getRootNode();
if (!rn.hasNode(name)) {
testRoot = adminSession.getRootNode().addNode(name, "nt:unstructured");
InputStream in = getClass().getClassLoader().getResourceAsStream("deepTree.xml");
adminSession.importXML(testRoot.getPath(), in, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
adminSession.save();
} else {
testRoot = rn.getNode(name);
}
final List<String> paths = new ArrayList<String>();
ItemVisitor v = new TraversingItemVisitor.Default() {
@Override
protected void entering(Node node, int i) throws RepositoryException {
paths.add(node.getPath());
super.entering(node, i);
}
@Override
protected void entering(Property prop, int i) throws RepositoryException {
paths.add(prop.getPath());
super.entering(prop, i);
}
};
v.visit(testRoot);
allPaths = paths;
System.out.println("All paths: " + allPaths.size());
}
Aggregations