Search in sources :

Example 96 with Property

use of javax.jcr.Property in project jackrabbit by apache.

the class ExternalModificationTest method testExternalRemoval3.

public void testExternalRemoval3() throws RepositoryException, NotExecutableException {
    Node childN = refNode.addNode(nodeName3);
    Property p = childN.setProperty(propertyName1, "anyvalue");
    refNode.save();
    String uuid = refNode.getUUID();
    Node refNode2 = testSession.getNodeByUUID(uuid);
    Node c2 = (Node) testSession.getItem(childN.getPath());
    Property p2 = (Property) testSession.getItem(p.getPath());
    // transiently modify  -> test effect of external removal.
    p2.setValue("changedValue");
    String srcPath = refNode.getPath();
    String destPath = destParentNode.getPath() + "/" + nodeName2;
    superuser.move(srcPath, destPath);
    superuser.save();
    try {
        refNode2.refresh(true);
        Node parent = refNode2.getParent();
    } catch (InvalidItemStateException e) {
    }
    assertItemStatus(refNode2, Status.REMOVED);
    assertItemStatus(c2, Status.REMOVED);
    assertItemStatus(p2, Status.STALE_DESTROYED);
    assertEquals("changedValue", p2.getString());
}
Also used : InvalidItemStateException(javax.jcr.InvalidItemStateException) Node(javax.jcr.Node) Property(javax.jcr.Property)

Example 97 with Property

use of javax.jcr.Property in project jackrabbit by apache.

the class ExternalModificationTest method testNewItemsUponStaleDestroyed.

public void testNewItemsUponStaleDestroyed() throws RepositoryException, NotExecutableException {
    String uuid = refNode.getUUID();
    Node refNode2 = (Node) testSession.getItem(refNode.getPath());
    refNode2.addMixin(mixLockable);
    Node childN = refNode2.addNode(nodeName3);
    String childNPath = childN.getPath();
    Property childP = refNode2.setProperty(propertyName2, "someValue");
    String childPPath = childP.getPath();
    String destPath = destParentNode.getPath() + "/" + nodeName2;
    superuser.move(refNode.getPath(), destPath);
    superuser.save();
    testSession.refresh(true);
    testSession.getItem(destPath);
    assertItemStatus(refNode2, Status.STALE_DESTROYED);
    assertItemStatus(refNode2.getProperty(jcrMixinTypes), Status.STALE_DESTROYED);
    assertItemStatus(childN, Status.NEW);
    assertItemStatus(childP, Status.NEW);
    assertItemStatus(childN.getProperty(jcrPrimaryType), Status.NEW);
    assertTrue(testSession.itemExists(childNPath));
    assertTrue(childN.isSame(testSession.getItem(childNPath)));
    assertTrue(testSession.itemExists(childPPath));
    assertTrue(childP.isSame(testSession.getItem(childPPath)));
    testSession.refresh(false);
    assertItemStatus(childN, Status.REMOVED);
    assertItemStatus(childP, Status.REMOVED);
    assertFalse(testSession.itemExists(childNPath));
    assertFalse(testSession.itemExists(childPPath));
}
Also used : Node(javax.jcr.Node) Property(javax.jcr.Property)

Example 98 with Property

use of javax.jcr.Property in project jackrabbit by apache.

the class GetPropertyTest method testGetDeepRefNodeProperties.

public void testGetDeepRefNodeProperties() throws RepositoryException, NotExecutableException {
    Node n = testRootNode.getNode(nodeName1);
    n.addMixin(mixReferenceable);
    Node n2 = n.addNode(nodeName2);
    Property p3 = n2.setProperty(propertyName1, "test");
    testRootNode.save();
    // other session directly accesses p3.
    // consequently n1 is not yet resolved
    Property prop3 = (Property) readOnly.getItem(p3.getPath());
    // now try to access properties below n1 -> should be existing although
    // n1 has not yet been resolved.
    assertTrue(readOnly.itemExists(prop2Path));
    Property p1 = (Property) readOnly.getItem(prop2Path);
    Node node1 = readOnly.getNodeByUUID(n.getUUID());
    assertTrue(p1.isSame(node1.getProperty(Text.getName(prop2Path))));
}
Also used : Node(javax.jcr.Node) Property(javax.jcr.Property)

Example 99 with Property

use of javax.jcr.Property in project jackrabbit by apache.

the class IsSameTest method testIsSameProperty2.

public void testIsSameProperty2() throws RepositoryException {
    Node n = testRootNode.addNode(nodeName1, testNodeType);
    Property p = n.setProperty(propertyName1, "anyvalue");
    testRootNode.save();
    // add transient modification to the property:
    p.setValue("someOtherValue");
    // access same property through different session
    Session otherSession = getHelper().getReadOnlySession();
    try {
        Property otherProperty = (Property) otherSession.getItem(p.getPath());
        assertTrue(p.isSame(otherProperty));
    } finally {
        otherSession.logout();
    }
}
Also used : Node(javax.jcr.Node) Property(javax.jcr.Property) Session(javax.jcr.Session)

Example 100 with Property

use of javax.jcr.Property in project jackrabbit by apache.

the class AddPropertyTest method testAddingProperty.

public void testAddingProperty() throws RepositoryException, NotExecutableException {
    Property p1 = testNode.setProperty(propertyName2, "value1");
    p1.remove();
    Property p2 = testNode.setProperty(propertyName2, "value2");
    p2.remove();
    Property p3 = testNode.setProperty(propertyName2, "value3");
    testNode.save();
    assertTrue(testNode.hasProperty(propertyName2));
    assertItemStatus(p1, Status.REMOVED);
    assertItemStatus(p2, Status.REMOVED);
    assertItemStatus(p3, Status.EXISTING);
}
Also used : Property(javax.jcr.Property)

Aggregations

Property (javax.jcr.Property)445 Node (javax.jcr.Node)252 Value (javax.jcr.Value)99 Test (org.junit.Test)87 Session (javax.jcr.Session)78 PropertyIterator (javax.jcr.PropertyIterator)68 RepositoryException (javax.jcr.RepositoryException)64 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)47 JackrabbitNode (org.apache.jackrabbit.api.JackrabbitNode)37 ValueFormatException (javax.jcr.ValueFormatException)34 QValue (org.apache.jackrabbit.spi.QValue)29 ArrayList (java.util.ArrayList)24 NodeIterator (javax.jcr.NodeIterator)24 QValueValue (org.apache.jackrabbit.spi.commons.value.QValueValue)23 PropertyDefinition (javax.jcr.nodetype.PropertyDefinition)20 Item (javax.jcr.Item)19 PathNotFoundException (javax.jcr.PathNotFoundException)17 InvalidItemStateException (javax.jcr.InvalidItemStateException)16 Version (javax.jcr.version.Version)16 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)15