[
https://issues.apache.org/jira/browse/SLING-4588?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Radu Cotescu closed SLING-4588.
-------------------------------
> JcrNodeResourceIterator : wrong paths generated when the parent resource is
> the root node.
> ------------------------------------------------------------------------------------------
>
> Key: SLING-4588
> URL: https://issues.apache.org/jira/browse/SLING-4588
> Project: Sling
> Issue Type: Bug
> Components: ResourceResolver
> Affects Versions: JCR Resource 2.5.0
> Reporter: Guillaume Douillet
> Assignee: Carsten Ziegeler
> Fix For: JCR Resource 2.5.2
>
>
> It seems the new versioning feature introduced by SLING-848 breaks the
> JcrNodeResourceIterator when the parent resource is the repository root (/).
> This is due to this line in {{JcrNodeResourceIterator.getPath(Node node)}} :
> {code}
> path = String.format("%s/%s", parentPath, node.getName());
> {code}
> When parentPath is {{/}} and the node name {{apps}}, then the generated
> path is {{//apps}}.
> This test case illustrates the wrong behavior :
> {code:title=JcrNodeResourceIteratorTest.java}
> public void testRoot() throws RepositoryException {
> String path = "/child";
> Node node = new MockNode(path);
> NodeIterator ni = new MockNodeIterator(new Node[] { node });
> JcrNodeResourceIterator ri = new JcrNodeResourceIterator(null, "/",
> null, ni, null, new PathMapperImpl());
> 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
> }
> }
> {code}
> This test currently fails with {code}expected:</[]child> but
> was:</[/]child>{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)