// first create the local structure where the content is completely serialized inside the .content.xml file
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/mapping/.content.xml"),
getClass().getResourceAsStream("sling-mapping-with-folder-child.xml"));
final RepositoryAccessor repo = new RepositoryAccessor(config);
Poller poller = new Poller();
// wait until the structure is published
poller.pollUntil(new Callable<Node>() {
@Override
public Node call() throws RepositoryException {
return repo.getNode("/content/test-root/mapping/jcr:content/par");
}
}, hasPrimaryType("nt:unstructured"));
// now create the folder and its associated .content.xml file ; this will cause
// intermediate folders to be created whose serialization data is present in the
// parent's .content.xml file
project.createOrUpdateFile(
Path.fromPortableString("jcr_root/content/test-root/mapping/_jcr_content/par/folder/.content.xml"),
getClass().getResourceAsStream("sling-folder-nodetype.xml"));
// first wait until the sling:Folder child node is created, to ensure that all changes are processed
poller.pollUntil(new Callable<Node>() {
@Override
public Node call() throws RepositoryException {
return repo.getNode("/content/test-root/mapping/jcr:content/par/folder");
}
}, hasPrimaryType("sling:Folder"));
// then, verify that the nt:unstructured node is correctly written
poller.pollUntil(new Callable<Node>() {
@Override
public Node call() throws RepositoryException {
return repo.getNode("/content/test-root/mapping/jcr:content/par");
}
}, hasPrimaryType("nt:unstructured"));
}