Examples of JcrNodeResourceIterator


Examples of org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResourceIterator

    public Iterator<Resource> findResources(String query, String language)
            throws SlingException {
        try {
            QueryResult res = JcrResourceUtil.query(getSession(), query,
                language);
            return new JcrNodeResourceIterator(this, res.getNodes(), rootProvider.getResourceTypeProviders());
        } catch (javax.jcr.query.InvalidQueryException iqe) {
            throw new QuerySyntaxException(iqe.getMessage(), query, language,
                iqe);
        } catch (RepositoryException re) {
            throw new SlingException(re.getMessage(), re);
View Full Code Here

Examples of org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResourceIterator

    public Iterator<Resource> findResources(String query, String language)
            throws SlingException {
        try {
            QueryResult res = JcrResourceUtil.query(getSession(), query,
                language);
            return new JcrNodeResourceIterator(this, res.getNodes(),
                rootProvider.getResourceTypeProviders());
        } catch (javax.jcr.query.InvalidQueryException iqe) {
            throw new QuerySyntaxException(iqe.getMessage(), query, language,
                iqe);
        } catch (RepositoryException re) {
View Full Code Here

Examples of org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResourceIterator

public class JcrNodeResourceIteratorTest extends TestCase {

    public void testEmpty() {
        NodeIterator ni = new MockNodeIterator(null);
        JcrNodeResourceIterator ri = new JcrNodeResourceIterator(null, ni, null);

        assertFalse(ri.hasNext());

        try {
            ri.next();
            fail("Expected no element in the iterator");
        } catch (NoSuchElementException nsee) {
            // expected
        }
    }
View Full Code Here

Examples of org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResourceIterator

    public void testSingle() throws RepositoryException {
        String path = "/parent/path/node";
        Node node = new MockNode(path);
        NodeIterator ni = new MockNodeIterator(new Node[] { node });
        JcrNodeResourceIterator ri = new JcrNodeResourceIterator(null, ni, null);

        assertTrue(ri.hasNext());
        Resource res = ri.next();
        assertEquals(path, res.getPath());
        assertEquals(node.getPrimaryNodeType().getName(), res.getResourceType());

        assertFalse(ri.hasNext());

        try {
            ri.next();
            fail("Expected no element in the iterator");
        } catch (NoSuchElementException nsee) {
            // expected
        }
    }
View Full Code Here

Examples of org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResourceIterator

        Node[] nodes = new Node[numNodes];
        for (int i=0; i < nodes.length; i++) {
            nodes[i] = new MockNode(pathBase + i, "some:type" + i);
        }
        NodeIterator ni = new MockNodeIterator(nodes);
        JcrNodeResourceIterator ri = new JcrNodeResourceIterator(null, ni, null);

        for (int i=0; i < nodes.length; i++) {
            assertTrue(ri.hasNext());
            Resource res = ri.next();
            assertEquals(pathBase + i, res.getPath());
            assertEquals(nodes[i].getPrimaryNodeType().getName(), res.getResourceType());
        }

        assertFalse(ri.hasNext());

        try {
            ri.next();
            fail("Expected no element in the iterator");
        } catch (NoSuchElementException nsee) {
            // expected
        }
    }
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.