Package org.apache.sling.commons.testing.jcr

Examples of org.apache.sling.commons.testing.jcr.MockNodeIterator


    public Node getNode(String relPath) {
        return nodes.get(relPath);
    }

    public NodeIterator getNodes() {
        return new MockNodeIterator(nodeArray);
    }
View Full Code Here


import 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 {
View Full Code Here

    }

    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());
View Full Code Here

        String pathBase = "/parent/path/node/";
        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();
View Full Code Here

        MockNode node1 = new MockNode("/node1");
        MockNode node2 = new MockNode("/node2");
        node1.addNode("node3");
        node1.setProperty("name", "node1");
        node2.setProperty("name", "node2");
        final NodeIterator it = new MockNodeIterator(new Node[]{node1, node2});
        final StringWriter sw = new StringWriter();
        writer.dump(it, sw);
        Pattern testPattern = Pattern.compile("\\{(.[^\\}]*)\\}"); // Pattern to look for a {...}
        Matcher matcher = testPattern.matcher(sw.toString());
        assertTrue("Did not produce a JSON object", matcher.find()); // Find first JSON object
View Full Code Here

TOP

Related Classes of org.apache.sling.commons.testing.jcr.MockNodeIterator

Copyright © 2018 www.massapicom. 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.