// check that the page was added using getPages
List pages = this.rpc.getPages(this.spaceKey);
boolean found = false;
for (int i = 0; i < pages.size() && !found; i++) {
PageSummary summary = (PageSummary) pages.get(i);
if (summary.getTitle().equals(title)) {
found = true;
assertEquals(this.spaceKey, summary.getSpace());
}
}
assertTrue("Adding page failed. There should be a page entitled \"" + title + "\" in this space", found);
// also check that the page was added using getPage
Page page = this.rpc.getPage(id);
assertEquals(id, page.getId());
assertEquals(title, page.getTitle());
assertEquals(this.spaceKey, page.getSpace());
assertEquals(content, page.getContent());
// modify the page
String newContent = "Some Other Content";
resultPage.setContent(newContent);
Page modifiedPage = this.rpc.storePage(resultPage);
// check that the page was modified
assertEquals(id, modifiedPage.getId());
assertEquals(title, modifiedPage.getTitle());
assertEquals(this.spaceKey, modifiedPage.getSpace());
assertEquals(newContent, modifiedPage.getContent());
assertTrue(resultPage.getVersion() < modifiedPage.getVersion());
// check again in a different way
modifiedPage = this.rpc.getPage(id);
assertEquals(id, modifiedPage.getId());
assertEquals(title, modifiedPage.getTitle());
assertEquals(this.spaceKey, modifiedPage.getSpace());
assertEquals(newContent, modifiedPage.getContent());
assertTrue(resultPage.getVersion() < modifiedPage.getVersion());
// check page history
List oldVersions = this.rpc.getPageHistory(id);
assertEquals(2, oldVersions.size());
PageHistorySummary phs0 = (PageHistorySummary) oldVersions.get(0);
assertEquals(resultPage.getVersion(), phs0.getVersion());
assertNotNull(phs0.getModified());
assertNotNull(phs0.getId());
Page page0 = this.rpc.getPage(phs0.getId());
assertEquals(page.getContent(), page0.getContent());
assertEquals(page.getVersion(), page0.getVersion());
// search for the page
// List searchResults = rpc.search(title, 1);
// assertEquals(1, searchResults.size());
// SearchResult searchResult = (SearchResult)searchResults.get(0);
// assertEquals(id, searchResult.getId());
// assertNotNull(searchResult.getExcerpt());
// assertEquals(title, searchResult.getTitle());
// assertEquals("page", searchResult.getType());
// assertNotNull(searchResult.getUrl());
// remove the page
this.rpc.removePage(id);
// check that the page was really removed
pages = this.rpc.getPages(this.spaceKey);
found = false;
for (int i = 0; i < pages.size() && !found; i++) {
PageSummary summary = (PageSummary) pages.get(i);
assertFalse("Remove page failed. Page still present.", summary.getId().equals(id));
}
}