use of javax.jcr.Property in project jackrabbit by apache.
the class PropertyTypeTest method typeCheckChildren.
private void typeCheckChildren(Node parentNode) throws RepositoryException {
NodeIterator nodes = parentNode.getNodes();
while (nodes.hasNext()) {
Node node = nodes.nextNode();
PropertyIterator props = node.getProperties();
while (props.hasNext()) {
Property prop = props.nextProperty();
int reqType = prop.getDefinition().getRequiredType();
int type = PropertyType.UNDEFINED;
boolean isEmptyMultipleArray = false;
if (prop.getDefinition().isMultiple()) {
if (prop.getValues().length > 0) {
type = prop.getValues()[0].getType();
} else {
isEmptyMultipleArray = true;
}
} else {
type = prop.getValue().getType();
}
if (!isEmptyMultipleArray && reqType != PropertyType.UNDEFINED) {
assertFalse("The type of a property must not " + "be UNDEFINED", type == PropertyType.UNDEFINED);
assertEquals("The type of a property has to match " + "the type of the property definition.", type, reqType);
}
}
typeCheckChildren(node);
}
}
use of javax.jcr.Property in project jackrabbit by apache.
the class PropertyTest method testIsSameMustNotCompareStates.
/**
* Tests if <code>Item.isSame(Item otherItem)</code> will return true when
* two <code>Property</code> objects representing the same actual repository
* item have been retrieved through two different sessions and one has been
* modified.
*
* @since JCR 2.0
*/
public void testIsSameMustNotCompareStates() throws RepositoryException {
// create a node, add a property and save it
Node testNode1 = testRootNode.addNode(nodeName1, testNodeType);
Property prop1 = testNode1.setProperty(propertyName1, "value1");
testRootNode.getSession().save();
// accuire the same property through a different session
Session session = getHelper().getSuperuserSession();
try {
Property prop2 = session.getProperty(prop1.getPath());
// change the value of prop2
prop2.setValue("value2");
assertTrue("Two references of same property must return true for " + "property1.isSame(property2)", prop1.isSame(prop2));
} finally {
session.logout();
}
}
use of javax.jcr.Property in project jackrabbit by apache.
the class PropertyItemIsModifiedTest method testTransientPropertyItemIsModified.
/**
* Test if Item.isModified() returns true for an already existing and modified
* PropertyItem (modifications aren't saved (transient)).
*
* @see javax.jcr.Item#isModified()
*/
public void testTransientPropertyItemIsModified() throws RepositoryException {
Property testProperty = testNode.setProperty(propertyName1, "test1");
testNode.save();
testProperty.setValue("test2");
Item testPropertyItem = superuser.getItem(testProperty.getPath());
// check testPropertyItem.isModified() before save
assertTrue("Item.isModified() must return true directly after an existing Property is modified (before current node is saved)", testPropertyItem.isModified());
}
use of javax.jcr.Property in project jackrabbit by apache.
the class PropertyItemIsModifiedTest method testTransientNewPropertyItemIsModified.
/**
* Test if Item.isModified() returns false after a new PropertyItem is set
* (before node is saved (transient). That means the PropertyItem don't exists
* persistent).
*
* @see javax.jcr.Item#isModified()
*/
public void testTransientNewPropertyItemIsModified() throws RepositoryException {
Property testProperty = testNode.setProperty(propertyName1, "test");
Item testPropertyItem = superuser.getItem(testProperty.getPath());
// check testPropertyItem.isModified() for a new PropertyItem before save
assertFalse("Item.isModified() must return false directly after a new PropertyItem is set (before current node is saved)", testPropertyItem.isModified());
}
use of javax.jcr.Property in project jackrabbit by apache.
the class PropertyItemIsModifiedTest method testPersistentNewPropertyItemIsModified.
/**
* Test if Item.isModified() returns false after a new PropertyItem is set
* and saved (persistent). That means the PropertyItem exists persistently but
* isn't modified after save.
* This is equivalent to the test if Item.isModified() returns false for an
* already exixting and not modified PropertyItem.
*
* @see javax.jcr.Item#isModified()
*/
public void testPersistentNewPropertyItemIsModified() throws RepositoryException {
Property testProperty = testNode.setProperty(propertyName1, "test");
testNode.save();
Item testPropertyItem = superuser.getItem(testProperty.getPath());
// check testPropertyItem.isModified() for a new PropertyItem after save
assertFalse("Item.isModified() must return false after a new PropertyItem is set and current node is saved", testPropertyItem.isModified());
}
Aggregations