throws SiteException, DocumentException, PublicationException {
DocumentFactory factory = getFactory();
Publication pub = factory.getPublication("test");
Area authoring = pub.getArea("authoring");
SiteNode sourceNode = authoring.getSite().getNode(sourcePath);
NodeSet nodes = SiteUtil.getSubSite(getManager(), sourceNode);
Document[] docs = nodes.getDocuments();
Map doc2path = new HashMap();
String sourceBase = sourcePath.substring(0, sourcePath.lastIndexOf("/"));
String targetBase = targetPath.substring(0, targetPath.lastIndexOf("/"));
for (int i = 0; i < docs.length; i++) {
doc2path.put(docs[i], docs[i].getPath().substring(sourceBase.length()));
}
docManager.copyAll(authoring, sourcePath, authoring, targetPath);
for (int i = 0; i < docs.length; i++) {
assertTrue(docs[i].hasLink());
String oldPath = (String) doc2path.get(docs[i]);
String newPath = targetBase + oldPath;
assertTrue(authoring.getSite().contains(newPath));
SiteNode newNode = authoring.getSite().getNode(newPath);
Document newDoc = newNode.getLink(docs[i].getLanguage()).getDocument();
assertEquals(newDoc.getContentLength(), docs[i].getContentLength());
assertFalse(newDoc.getUUID().equals(docs[i].getUUID()));
}
String[] sourceNames = getChildNames(sourceNode);
SiteNode targetNode = authoring.getSite().getNode(targetPath);
String[] targetNames = getChildNames(targetNode);
assertEquals(StringUtil.join(sourceNames, ","), StringUtil.join(targetNames, ","));
}