use of javax.jcr.Property in project jackrabbit by apache.
the class ItemStateHierarchyManagerDeadlockTest method retrieveNodesUnderInvRootNode.
public void retrieveNodesUnderInvRootNode() {
System.out.println("Start retrieveNodesUnderInvRootNode ");
Session session = null;
try {
session = login();
// start from the bottom of the tree and move up
Node inventoryRoot = getInvRootNode(session);
NodeIterator nodes = inventoryRoot.getNodes();
while (nodes.hasNext()) {
Node node = nodes.nextNode();
// System.out.println(" Node: " + node.getName());
PropertyIterator properties = node.getProperties();
while (properties.hasNext()) {
Property prop = properties.nextProperty();
// System.out.println(" Prop: " + prop.getName() + " - " + prop.getString());
}
}
session.save();
System.out.println("End retrieveNodesUnderInvRootNode");
} catch (Exception e) {
System.err.println("Exception in retrieveNodesUnderInvRootNode:" + e.getMessage());
} finally {
if (session != null)
session.logout();
}
}
use of javax.jcr.Property in project jackrabbit by apache.
the class ItemSequenceTest method checkTreeProperty.
private static void checkTreeProperty(Node root, int minChildren, int maxChildren, Comparator<String> order) throws RepositoryException {
int depth = -1;
for (Node node : new TreeTraverser(root)) {
String parentName = node.getName();
if (node.hasNodes()) {
int childCount = 0;
for (NodeIterator nodes = node.getNodes(); nodes.hasNext(); ) {
Node child = nodes.nextNode();
childCount++;
if (!root.isSame(node)) {
assertTrue("Mismatching order: node " + node + " contains child " + child, order.compare(parentName, child.getName()) <= 0);
}
}
if (!root.isSame(node)) {
assertTrue("Node " + node + " should have at least " + minChildren + " child nodes", minChildren <= childCount);
}
assertTrue("Node " + node + " should have no more than " + maxChildren + " child nodes", maxChildren >= childCount);
} else {
if (depth == -1) {
depth = node.getDepth();
} else {
assertEquals("Node " + node + " has depth " + node.getDepth() + " instead of " + depth, depth, node.getDepth());
}
int propCount = 0;
for (PropertyIterator properties = node.getProperties(); properties.hasNext(); ) {
Property property = properties.nextProperty();
String propertyName = property.getName();
if (!JcrConstants.JCR_PRIMARYTYPE.equals(propertyName)) {
propCount++;
assertTrue("Mismatching order: node " + node + " contains property " + property, order.compare(parentName, propertyName) <= 0);
}
}
if (propCount > 0) {
assertTrue("Node " + node + " should have at least " + minChildren + " properties", minChildren <= propCount);
assertTrue("Node" + node + " should have no more than " + maxChildren + " properties", maxChildren >= propCount);
}
}
}
}
use of javax.jcr.Property in project jackrabbit by apache.
the class ItemSequenceTest method testSingletonPropertySequence.
public void testSingletonPropertySequence() throws RepositoryException {
Comparator<String> order = Rank.<String>comparableComparator();
TreeManager treeManager = new BTreeManager(testNode, 2, 4, order, true);
PropertySequence properties = ItemSequence.createPropertySequence(treeManager, errorHandler);
ValueFactory vFactory = testNode.getSession().getValueFactory();
properties.addProperty("key", vFactory.createValue("key_"));
assertTrue(properties.hasItem("key"));
Iterator<Property> propertyIt = properties.iterator();
assertTrue(propertyIt.hasNext());
assertEquals("key", propertyIt.next().getName());
assertFalse(propertyIt.hasNext());
properties.removeProperty("key");
assertEmpty(properties);
}
use of javax.jcr.Property in project jackrabbit by apache.
the class GetOrNullTest method testGetItemOrNullExistingProperty.
public void testGetItemOrNullExistingProperty() throws RepositoryException {
JackrabbitSession js = (JackrabbitSession) superuser;
Item item = js.getItemOrNull(PATH_EXISTING_PROPERTY);
assertNotNull(item);
assertTrue(item instanceof Property);
assertEquals(item.getPath(), PATH_EXISTING_PROPERTY);
}
use of javax.jcr.Property in project jackrabbit by apache.
the class GetOrNullTest method testGetPropertyOrNullNonExisting.
public void testGetPropertyOrNullNonExisting() throws RepositoryException {
JackrabbitSession js = (JackrabbitSession) superuser;
Property property = js.getPropertyOrNull(PATH_NON_EXISTING_PROPERTY);
assertNull(property);
}
Aggregations