{
public void testTwoRestores() throws Exception
{
{
SessionImpl sessionWS1 = (SessionImpl)repository.login(credentials, "ws1");
sessionWS1.getRootNode().addNode("asdasdasda", "nt:unstructured").setProperty("data", "data_1");
sessionWS1.save();
// 1-st export
File f1 = new File("target/1.xml");
sessionWS1.exportWorkspaceSystemView(new FileOutputStream(f1), false, false);
// 1-st import
WorkspaceEntry ws1_restore_1 =
makeWorkspaceEntry("ws1_restore_1", isMultiDB(session) ? "jdbcjcr2export1" : "jdbcjcr", f1);
repository.configWorkspace(ws1_restore_1);
repository.createWorkspace(ws1_restore_1.getName());
// check
SessionImpl back1 = (SessionImpl)repository.login(credentials, "ws1_restore_1");
assertNotNull(back1.getRootNode().getNode("asdasdasda").getProperty("data"));
// add date to restored workspace
back1.getRootNode().addNode("gdfgrghfhf", "nt:unstructured").setProperty("data", "data_2");
back1.save();
}
{
// 2-st export
SessionImpl back1 = (SessionImpl)repository.login(credentials, "ws1_restore_1");
File f2 = new File("target/2.xml");
back1.exportWorkspaceSystemView(new FileOutputStream(f2), false, false);
// 2-st import
WorkspaceEntry ws1_restore_2 =
makeWorkspaceEntry("ws1_restore_2", isMultiDB(session) ? "jdbcjcr2export2" : "jdbcjcr", f2);
repository.configWorkspace(ws1_restore_2);
repository.createWorkspace(ws1_restore_2.getName());
// check
SessionImpl back2 = (SessionImpl)repository.login(credentials, "ws1_restore_2");
assertNotNull(back2.getRootNode().getNode("gdfgrghfhf").getProperty("data"));
}
}