Examples of storeAsNode()


Examples of javax.jcr.query.Query.storeAsNode()

        /* test if resource path does not exist -> thus indicating that
        the query must be made persistent by calling Query.save(String) */
        if (!getRepositorySession().itemExists(itemPath)) {
            try {
                q.storeAsNode(itemPath);
            } catch (RepositoryException e) {
                // ItemExistsException should never occur.
                new JcrDavException(e);
            }
        }
View Full Code Here

Examples of javax.jcr.query.Query.storeAsNode()

        String statement = "Some query syntax";

        QueryManager queryManager = workspace.getQueryManager();
        Query query = queryManager.createQuery(statement, Query.XPATH);

        Node node = query.storeAsNode("/storedQuery");
        assertThat(node, is(notNullValue()));
        assertThat(node.getPrimaryNodeType().getName(), is("nt:query"));
        assertThat(node.getProperty("jcr:language").getString(), is(Query.XPATH));
        assertThat(node.getProperty("jcr:statement").getString(), is(statement));
    }
View Full Code Here

Examples of javax.jcr.query.Query.storeAsNode()

        String statement = "Some query syntax";

        QueryManager queryManager = workspace.getQueryManager();
        Query query = queryManager.createQuery(statement, Query.XPATH);

        Node node = query.storeAsNode("/storedQuery");

        Query loaded = queryManager.getQuery(node);

        assertThat(loaded, is(notNullValue()));
        assertThat(loaded.getLanguage(), is(Query.XPATH));
View Full Code Here

Examples of javax.jcr.query.Query.storeAsNode()

     * @throws NotExecutableException if nt:query is not supported.
     */
    public void testSave() throws RepositoryException, NotExecutableException {
        checkNtQuery();
        Query query = superuser.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
        query.storeAsNode(testRoot + "/" + nodeName1);

        assertTrue("Node has not been stored", testRootNode.hasNode(nodeName1));

        Node queryNode = testRootNode.getNode(nodeName1);
        assertTrue("Query node is not of type nt:query", queryNode.isNodeType(ntQuery));
View Full Code Here

Examples of javax.jcr.query.Query.storeAsNode()

     * @throws NotExecutableException if nt:query is not supported.
     */
    public void testItemExistsException() throws RepositoryException, NotExecutableException {
        checkNtQuery();
        Query query = superuser.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
        Node qNode = query.storeAsNode(testRoot + "/" + nodeName1);

        // create another one
        query = superuser.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
        try {
            query.storeAsNode(testRoot + "/" + nodeName1);
View Full Code Here

Examples of javax.jcr.query.Query.storeAsNode()

     */
    public void testPathNotFoundException() throws RepositoryException, NotExecutableException {
        checkNtQuery();
        Query query = superuser.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
        try {
            query.storeAsNode(testRoot + "/" + nodeName1 + "/" + nodeName1);
            fail("Query.storeAsNode() must throw PathNotFoundException on invalid path");
        } catch (PathNotFoundException e) {
            // expected behaviour
        }
    }
View Full Code Here

Examples of javax.jcr.query.Query.storeAsNode()

        }
        testRootNode.save();
        versionable.checkin();

        try {
            query.storeAsNode(testRoot + "/" + nodeName1 + "/" + nodeName2);
            fail("Query.storeAsNode() must throw VersionException, parent node is checked in.");
        } catch (VersionException e) {
            // expected behaviour
        }
    }
View Full Code Here

Examples of javax.jcr.query.Query.storeAsNode()

    public void testConstraintViolationException() throws RepositoryException, NotExecutableException {
        checkNtQuery();
        Query query = superuser.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
        testRootNode.addNode(nodeName1, testNodeType);
        try {
            query.storeAsNode(testRoot + "/" + nodeName1 + "/" + nodeName2);
            fail("Query.storeAsNode() must throw ConstraintViolationException, parent node does not allow child nodes.");
        } catch (ConstraintViolationException e) {
            // expected behaviour
        }
    }
View Full Code Here

Examples of javax.jcr.query.Query.storeAsNode()

        lockable.lock(false, true);

        Session readWrite = helper.getReadWriteSession();
        try {
            Query query = readWrite.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
            query.storeAsNode(testRoot + "/" + nodeName1 + "/" + nodeName2);
            fail("Query.storeAsNode() must throw LockException, parent node is locked.");
        } catch (LockException e) {
            // expected behaviour
        } finally {
            readWrite.logout();
View Full Code Here

Examples of javax.jcr.query.Query.storeAsNode()

     */
    public void testRepositoryException() throws RepositoryException, NotExecutableException {
        checkNtQuery();
        Query query = superuser.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
        try {
            query.storeAsNode(testRoot + "/invalid[path");
            fail("Query.storeAsNode() must throw RepositoryException on malformed path.");
        } catch (RepositoryException e) {
            // expected behaviour
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.