{
String title = "SomeOtherPage";
String content1 = "Content v1";
// add the page
Page p = new Page();
p.setSpace(this.spaceKey);
p.setTitle(title);
p.setContent(content1);
p.setParentId("Main.WebHome");
Page page1 = this.rpc.storePage(p);
// modify the page
String content2 = "Content v2";
p.setContent(content2);
p.setId(page1.getId());
p.setVersion(page1.getVersion());
Page page2 = this.rpc.storePage(p);
// modify the page again
String content3 = "Content v3";
p.setContent(content3);
p.setId(page2.getId());
p.setVersion(page2.getVersion());
Page page3 = this.rpc.storePage(p);
// get page history
List historyObjs = this.rpc.getPageHistory(page3.getId());
assertEquals(3, historyObjs.size());
PageHistorySummary phs1 = (PageHistorySummary) historyObjs.get(1);
assertEquals(page1.getVersion() + 1, phs1.getVersion());
// This ensures that getting the page from XmlRpc uses the date of the version, and not the current date
// See XWIKI-2821
Thread.sleep(2000);
Page p1 = this.rpc.getPage(phs1.getId());
assertEquals(page2.getVersion(), p1.getVersion());
assertEquals(page2.getContent(), p1.getContent());
assertEquals(page2.getCreated(), p1.getCreated());
assertEquals(page2.getCreator(), p1.getCreator());
assertEquals(page2.getModified(), p1.getModified());
assertEquals(page2.getModifier(), p1.getModifier());
assertEquals(page2.getParentId(), p1.getParentId());
assertEquals(page2.getSpace(), p1.getSpace());
assertEquals(page2.getTitle(), p1.getTitle());
// assertFalse(page2.getUrl().equals(p1.getUrl()));
PageHistorySummary phs2 = (PageHistorySummary) historyObjs.get(0);
// assertEquals(page3.getVersion(), phs2.getVersion());
Page p2 = this.rpc.getPage(phs2.getId());
// assertEquals(page3.getVersion(), p2.getVersion());
// assertEquals(page3.getContent(), p2.getContent());
// assertEquals(page3.getCreated(), p2.getCreated());
// assertEquals(page3.getCreator(), p2.getCreator());
// assertEquals(page3.getModified(), p2.getModified());
// assertEquals(page3.getModifier(), p2.getModifier());
// assertEquals(page3.getParentId(), p2.getParentId());
// assertEquals(page3.getSpace(), p2.getSpace());
// assertEquals(page3.getTitle(), p2.getTitle());
// assertFalse(page3.getUrl().equals(p2.getUrl()));
// get history of page from history
// confluence does not allow this
// ("This is not the most recent version of this page")
historyObjs = this.rpc.getPageHistory(p2.getId());
// assertEquals(1, historyObjs.size());
phs1 = (PageHistorySummary) historyObjs.get(0);
assertEquals(page1.getVersion(), phs1.getVersion());
p1 = this.rpc.getPage(phs1.getId());
assertEquals(page1.getVersion(), p1.getVersion());