[
http://issues.apache.org/jira/browse/JCR-535?page=comments#action_12444170 ]
Jukka Zitting commented on JCR-535:
-----------------------------------
> Here is the test case, but you need to check both export to make sure the
> root node has been correcly replaced.
I was rather thinking about something like this:
public void testRootNodeImport() throws Exception {
session.getRootNode().addNode("a");
session.save();
assertTrue(session.hasItem("/jcr:system"));
assertTrue(session.hasItem("/a"));
assertFalse(session.hasItem("/b"));
String xml = "<jcr:root xmlns:jcr=\"http://www.jcp.org/jcr/1.0\"
jcr:uuid=\"...\"><b/></jcr:root>";
InputStream in = new ByteArrayInputStream(xml.getBytes("UTF-8"));
session.importXML("/", in,
ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
session.save();
assertTrue(session.hasItem("/jcr:system"));
assertFalse(session.hasItem("/a"));
assertTrue(session.hasItem("/b"));
}
(+ whatever setup and cleanup code is needed. Note especially that the jcr:uuid
property of the root node needs to be exposed somehow.)
The point of an automated unit test is that the test case contains the
assertions used to verify that the executed statements actually produced the
desired results. Without the assertions the unit test is little good, as you
would always need to manually check the results.
Also, you should place the test class in src/test/java rather than in
src/main/java.
> Ignore root node when importing through sysView
> -----------------------------------------------
>
> Key: JCR-535
> URL: http://issues.apache.org/jira/browse/JCR-535
> Project: Jackrabbit
> Issue Type: Improvement
> Components: core
> Reporter: Nicolas Toper
> Priority: Minor
> Attachments: patch-1-Ignore-root-node.txt,
> patch-WorkspaceImporter-231006-2.txt, patch-WorkspaceImporter-231006.txt,
> patch-WorkspaceImporterTest-231006.txt
>
>
> When importing through a sysView, we should ignore the root node. It is in
> the sysView to provide a root XML node, but the importer is going to attach
> it to the repository"s root node... Which would create another root node and
> often raise exception. This is a know issue
> I needed this behavior to change for the backup tool, since I use the
> sysView. Therefore, I havce slightly updated the WorkspaceImporter. Maybe I
> should update too the SessionImporter so we have a consistant behavior. What
> do you think?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira