Search in sources :

Example 21 with NotExecutableException

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

the class DerefQueryLevel1Test method testDerefMultiPropWithNodeStar.

/**
     * Test a deref query on a multi valued reference property with a '*' node.
     * @throws NotExecutableException if the workspace does not have sufficient
     *  content.
     */
public void testDerefMultiPropWithNodeStar() throws RepositoryException, NotExecutableException {
    Property refProp = PropertyUtil.searchMultivalProp(testRootNode, PropertyType.REFERENCE);
    if (refProp == null) {
        throw new NotExecutableException("Workspace does not contain a node with a multivalue reference property.");
    }
    Value[] targets = refProp.getValues();
    Node[] targetNodes = new Node[targets.length];
    for (int i = 0; i < targets.length; i++) {
        targetNodes[i] = session.getNodeByUUID(targets[i].getString());
    }
    if (targetNodes.length == 0) {
        throw new NotExecutableException("Reference property does not contain a value");
    }
    String xpath = createStatement(refProp, "*");
    executeDerefQuery(session, xpath, targetNodes);
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Node(javax.jcr.Node) Value(javax.jcr.Value) Property(javax.jcr.Property)

Example 22 with NotExecutableException

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

the class DerefQueryLevel1Test method testDerefSinglePropWithNodeStar.

/**
     * Test a deref query on a single valued reference property with a '*' node
     * test.
     * @throws NotExecutableException if the workspace does not have sufficient
     *  content.
     */
public void testDerefSinglePropWithNodeStar() throws RepositoryException, NotExecutableException {
    Property refProp = PropertyUtil.searchProp(session, testRootNode, PropertyType.REFERENCE, Boolean.FALSE);
    if (refProp == null) {
        throw new NotExecutableException("Workspace does not contain a node with a reference property.");
    }
    Node target = refProp.getNode();
    String xpath = createStatement(refProp, "*");
    executeDerefQuery(session, xpath, new Node[] { target });
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Node(javax.jcr.Node) Property(javax.jcr.Property)

Example 23 with NotExecutableException

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

the class GetLanguageTest method testSQL.

/**
     * Tests if a SQL query returns {@link Query#SQL} when calling
     * {@link Query#getLanguage()}.
     */
public void testSQL() throws RepositoryException, NotExecutableException {
    if (isSupportedLanguage(qsSQL)) {
        String stmt = "select * from " + testNodeType;
        Query q = session.getWorkspace().getQueryManager().createQuery(stmt, qsSQL);
        assertEquals("Query returns wrong language.", qsSQL, q.getLanguage());
    } else {
        throw new NotExecutableException("SQL not supported");
    }
}
Also used : Query(javax.jcr.query.Query) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException)

Example 24 with NotExecutableException

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

the class TextNodeTest method testTextNodeTestWithPosition.

/**
     * Tests text() node test with various position predicates: position(),
     * first(), last().
     * @throws NotExecutableException if the repository does not support queries
     *  with position inidex.
     */
public void testTextNodeTestWithPosition() throws RepositoryException, NotExecutableException {
    if (!isSupported(Repository.QUERY_XPATH_POS_INDEX)) {
        throw new NotExecutableException("Repository does not support position index");
    }
    Node text1 = testRootNode.addNode(jcrXMLText);
    text1.setProperty(jcrXMLCharacters, "foo");
    if (!text1.getDefinition().allowsSameNameSiblings()) {
        throw new NotExecutableException("Node at path: " + testRoot + " does not allow same name siblings with name: " + jcrXMLText);
    }
    testRootNode.addNode(nodeName1, testNodeType);
    Node text2 = testRootNode.addNode(jcrXMLText);
    text2.setProperty(jcrXMLCharacters, "foo");
    testRootNode.getSession().save();
    String xpath = "/" + jcrRoot + testRoot + "/text()[2]";
    executeXPathQuery(superuser, xpath, new Node[] { text2 });
    xpath = "/" + jcrRoot + testRoot + "/text()[last()]";
    executeXPathQuery(superuser, xpath, new Node[] { text2 });
    xpath = "/" + jcrRoot + testRoot + "/text()[position() = 2]";
    executeXPathQuery(superuser, xpath, new Node[] { text2 });
    xpath = "/" + jcrRoot + testRoot + "/text()[first()]";
    executeXPathQuery(superuser, xpath, new Node[] { text1 });
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Node(javax.jcr.Node)

Example 25 with NotExecutableException

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

the class QueryResultNodeIteratorTest method testGetSize.

/**
     * Tests if {@link javax.jcr.NodeIterator#getSize()} returns the correct
     * size.
     *
     * @throws org.apache.jackrabbit.test.NotExecutableException
     *          if getSize() returns -1 (unavailable).
     */
public void testGetSize() throws RepositoryException, NotExecutableException {
    NodeIterator it = execute(xpathRoot + "//*", qsXPATH).getNodes();
    long size = testRootNode.getNodes().getSize();
    if (size != -1) {
        long count = 0;
        while (it.hasNext()) {
            it.nextNode();
            count++;
        }
        assertEquals("NodeIterator.getSize does not return correct number.", size, count);
    } else {
        throw new NotExecutableException("NodeIterator.getSize() does not return size information.");
    }
}
Also used : NodeIterator(javax.jcr.NodeIterator) 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