Search in sources :

Example 86 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class PropertyReadMethodsTest method testGetValueCopyStoredValues.

/**
     * Tests if <code>Property.getValues()</code> returns an array that is a copy
     * of the stored values, so changes to it are not reflected in internal storage.
     */
public void testGetValueCopyStoredValues() throws NotExecutableException, RepositoryException {
    Property prop = PropertyUtil.searchMultivalProp(testRootNode);
    if (prop == null) {
        throw new NotExecutableException("No multivalued property found.");
    }
    // acquire the values of the property and change the zeroth value
    Value[] values = prop.getValues();
    if (values.length == 0) {
        throw new NotExecutableException("No testable property found.");
    }
    values[0] = null;
    // re-acquire the values and check if nulled value still exists
    Value[] values2 = prop.getValues();
    assertNotNull("Changes on the array returned by Property.getValues() must " + "not be reflected in the internal storage.", values2[0]);
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Value(javax.jcr.Value) Property(javax.jcr.Property)

Example 87 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class ReferenceableRootNodesTest method testReferenceableRootNode.

/**
     * A repository implementation may make its workspace root nodes
     * mix:referenceable. If so, then the root node of all workspaces must be
     * referenceable, and all must have the same UUID.
     */
public void testReferenceableRootNode() throws RepositoryException, NotExecutableException {
    // compare UUID of default workspace and a second workspace
    Node rootNode = session.getRootNode();
    if (rootNode.isNodeType(mixReferenceable)) {
        // check if root node in second workspace is referenceable too
        Node rootNodeW2 = sessionW2.getRootNode();
        if (!rootNodeW2.isNodeType(mixReferenceable)) {
            fail("Root node in second workspace is not referenceable.");
        }
        // check if all root nodes have the same UUID
        assertEquals("Referenceable root nodes of different workspaces must have same UUID.", rootNode.getUUID(), rootNodeW2.getUUID());
    } else {
        throw new NotExecutableException("Root node is not referenceable");
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Node(javax.jcr.Node)

Example 88 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class SessionReadMethodsTest method testGetNodeByUUID.

/**
     * Tests session.getNodeByUUID() using a valid uuid of a referenceable node
     */
public void testGetNodeByUUID() throws RepositoryException, NotExecutableException {
    Node referenced = findReferenceable(testRootNode);
    if (referenced == null) {
        throw new NotExecutableException("Workspace does not contain a referenceable node.");
    }
    String uuid = referenced.getProperty(jcrUUID).getString();
    Node node = session.getNodeByUUID(uuid);
    assertTrue("Node retrieved with session.getNodeByUUID is not the same " + "as the node having the given uuid.", referenced.isSame(node));
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Node(javax.jcr.Node)

Example 89 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class HoldTest method testPropertyPath.

public void testPropertyPath() throws RepositoryException, NotExecutableException {
    String propPath = null;
    for (PropertyIterator it = testRootNode.getProperties(); it.hasNext(); ) {
        String path = it.nextProperty().getPath();
        if (!superuser.nodeExists(path)) {
            propPath = path;
            break;
        }
    }
    if (propPath == null) {
        throw new NotExecutableException();
    }
    try {
        retentionMgr.getHolds(propPath);
        fail("Accessing holds from non-existing node must throw PathNotFoundException.");
    } catch (PathNotFoundException e) {
    // success
    }
    try {
        retentionMgr.addHold(propPath, getHoldName(), true);
        fail("Adding a hold for a non-existing node must throw PathNotFoundException.");
    } catch (PathNotFoundException e) {
    // success
    }
    try {
        Hold h = retentionMgr.addHold(testNodePath, getHoldName(), true);
        retentionMgr.removeHold(propPath, h);
        fail("Removing a hold at a non-existing node must throw PathNotFoundException.");
    } catch (PathNotFoundException e) {
    // success
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) PropertyIterator(javax.jcr.PropertyIterator) PathNotFoundException(javax.jcr.PathNotFoundException) Hold(javax.jcr.retention.Hold)

Example 90 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class RestoreTest method testRestoreWithUUIDConflictJcr2_2.

/**
     * Tests if restoring the <code>Version</code> of an existing node throws an
     * <code>ItemExistsException</code> if removeExisting is set to FALSE.
     */
public void testRestoreWithUUIDConflictJcr2_2() throws RepositoryException, NotExecutableException {
    try {
        Node naa = createVersionableNode(versionableNode, nodeName4, versionableNodeType);
        // Verify that nodes used for the test have proper opv behaviour
        NodeDefinition nd = naa.getDefinition();
        if (nd.getOnParentVersion() != OnParentVersionAction.COPY && nd.getOnParentVersion() != OnParentVersionAction.VERSION) {
            throw new NotExecutableException("Child nodes must have OPV COPY or VERSION in order to be able to test Node.restore with uuid conflict.");
        }
        Version v = versionManager.checkin(versionableNode.getPath());
        versionManager.checkout(versionableNode.getPath());
        superuser.move(naa.getPath(), versionableNode2.getPath() + "/" + naa.getName());
        superuser.save();
        versionManager.restore(v, false);
        fail("Node.restore( Version, boolean ): An ItemExistsException must be thrown if the node to be restored already exsits and removeExisting was set to false.");
    } catch (ItemExistsException e) {
    // success
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Version(javax.jcr.version.Version) ItemExistsException(javax.jcr.ItemExistsException) Node(javax.jcr.Node) NodeDefinition(javax.jcr.nodetype.NodeDefinition)

Aggregations

NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)381 Node (javax.jcr.Node)149 NodeType (javax.jcr.nodetype.NodeType)84 Value (javax.jcr.Value)81 RepositoryException (javax.jcr.RepositoryException)64 PropertyDefinition (javax.jcr.nodetype.PropertyDefinition)61 Session (javax.jcr.Session)59 Property (javax.jcr.Property)47 NodeDefinition (javax.jcr.nodetype.NodeDefinition)29 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)28 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)25 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)23 AccessControlPolicyIterator (javax.jcr.security.AccessControlPolicyIterator)22 Test (org.junit.Test)22 AccessControlPolicy (javax.jcr.security.AccessControlPolicy)21 User (org.apache.jackrabbit.api.security.user.User)19 Principal (java.security.Principal)18 NodeIterator (javax.jcr.NodeIterator)18 UserManager (org.apache.jackrabbit.api.security.user.UserManager)17 ItemExistsException (javax.jcr.ItemExistsException)16