Search in sources :

Example 66 with NotExecutableException

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

the class DescendantNodeTest method testDescendantNodesDoNotMatchSelector.

public void testDescendantNodesDoNotMatchSelector() throws RepositoryException, NotExecutableException {
    testRootNode.addNode(nodeName1, testNodeType);
    superuser.save();
    NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
    NodeTypeIterator it = ntMgr.getPrimaryNodeTypes();
    NodeType testNt = ntMgr.getNodeType(testNodeType);
    while (it.hasNext()) {
        NodeType nt = it.nextNodeType();
        if (!testNt.isNodeType(nt.getName())) {
            // perform test
            QueryObjectModel qom = qf.createQuery(qf.selector(nt.getName(), "s"), qf.descendantNode("s", testRoot), null, null);
            checkQOM(qom, new Node[] {});
            return;
        }
    }
    throw new NotExecutableException("No suitable node type found to " + "perform test against '" + testNodeType + "' nodes");
}
Also used : NodeTypeManager(javax.jcr.nodetype.NodeTypeManager) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) NodeType(javax.jcr.nodetype.NodeType) NodeTypeIterator(javax.jcr.nodetype.NodeTypeIterator) QueryObjectModel(javax.jcr.query.qom.QueryObjectModel)

Example 67 with NotExecutableException

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

the class ChildNodeTest method testChildNodesDoNotMatchSelector.

public void testChildNodesDoNotMatchSelector() throws RepositoryException, NotExecutableException {
    testRootNode.addNode(nodeName1, testNodeType);
    superuser.save();
    NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
    NodeTypeIterator it = ntMgr.getPrimaryNodeTypes();
    NodeType testNt = ntMgr.getNodeType(testNodeType);
    while (it.hasNext()) {
        NodeType nt = it.nextNodeType();
        if (!testNt.isNodeType(nt.getName())) {
            // perform test
            QueryObjectModel qom = qf.createQuery(qf.selector(nt.getName(), "s"), qf.childNode("s", testRoot), null, null);
            checkQOM(qom, new Node[] {});
            return;
        }
    }
    throw new NotExecutableException("No suitable node type found to " + "perform test against '" + testNodeType + "' nodes");
}
Also used : NodeTypeManager(javax.jcr.nodetype.NodeTypeManager) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) NodeType(javax.jcr.nodetype.NodeType) NodeTypeIterator(javax.jcr.nodetype.NodeTypeIterator) QueryObjectModel(javax.jcr.query.qom.QueryObjectModel)

Example 68 with NotExecutableException

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

the class UserTest method testChangePassword.

public void testChangePassword() throws RepositoryException, NotExecutableException {
    String oldPw = getHelper().getProperty("javax.jcr.tck.superuser.pwd");
    if (oldPw == null) {
        // missing property
        throw new NotExecutableException();
    }
    User user = getTestUser(superuser);
    try {
        user.changePassword("pw");
        save(superuser);
        // make sure the user can login with the new pw
        Session s = getHelper().getRepository().login(new SimpleCredentials(user.getID(), "pw".toCharArray()));
        s.logout();
    } finally {
        user.changePassword(oldPw);
        save(superuser);
    }
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Session(javax.jcr.Session) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Example 69 with NotExecutableException

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

the class UserTest method testChangePasswordWithOldPassword2.

public void testChangePasswordWithOldPassword2() throws RepositoryException, NotExecutableException {
    String oldPw = getHelper().getProperty("javax.jcr.tck.superuser.pwd");
    if (oldPw == null) {
        // missing property
        throw new NotExecutableException();
    }
    User user = getTestUser(superuser);
    try {
        user.changePassword("pw", oldPw);
        save(superuser);
        Session s = getHelper().getRepository().login(new SimpleCredentials(user.getID(), oldPw.toCharArray()));
        s.logout();
        fail("superuser pw has changed. login must fail.");
    } catch (LoginException e) {
    // success
    } finally {
        user.changePassword(oldPw);
        save(superuser);
    }
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) LoginException(javax.jcr.LoginException) Session(javax.jcr.Session) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Example 70 with NotExecutableException

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

the class UserManagerTest method testGetAuthorizableByPath.

public void testGetAuthorizableByPath() throws RepositoryException, NotExecutableException {
    String uid = superuser.getUserID();
    Authorizable a = userMgr.getAuthorizable(uid);
    if (a == null) {
        throw new NotExecutableException();
    }
    try {
        String path = a.getPath();
        Authorizable a2 = userMgr.getAuthorizableByPath(path);
        assertNotNull(a2);
        assertEquals(a.getID(), a2.getID());
    } catch (UnsupportedRepositoryOperationException e) {
        throw new NotExecutableException();
    }
}
Also used : UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException)

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