RemoteWikiBroker rwb = RemoteWikiBroker.getInstance();
String uniqueId = getUniqueString();
String title = "testing-update-" + uniqueId;
//explicitly check that page does not exist - XXX not sure we're testing this right in conf4
XmlRpcClient client = new XmlRpcClient("http://" + confSettings.url + "/rpc/xmlrpc");
Vector paramsVector = new Vector();
String loginToken = rwb.getLoginToken(confSettings);
paramsVector.add(loginToken);
paramsVector.add(confSettings.spaceKey);
paramsVector.add(title);
Hashtable retpage = null;
try {
retpage = (Hashtable) client.execute("confluence1.getPage", paramsVector);
fail();
} catch (XmlRpcException e) {}
//create page first time
PageForXmlRpc page = new PageForXmlRpc();
page.setTitle(title);
String content1 = "this is some content " + uniqueId;
page.setContent(content1);
rwb.storeNewOrUpdatePage(confSettings, confSettings.spaceKey, page);
try {
retpage = (Hashtable) client.execute("confluence1.getPage", paramsVector);
assertNotNull(retpage);
assertEquals(title, (String) retpage.get("title"));
assertEquals(content1, (String) retpage.get("content")); //not allowed as of Conf 4
} catch (XmlRpcException e) {
try {
retpage = (Hashtable) client.execute("confluence1.getPageSummary", paramsVector);
assertNotNull(retpage);
assertEquals(title, (String) retpage.get("title"));
//assertEquals(content1, (String) retpage.get("content")); //not allowed as of Conf 4
} catch (XmlRpcException e1) {
fail();
}
}
//update page
page = new PageForXmlRpc();
page.setTitle(title);
String content2 = "this is some UPDATED content " + uniqueId;
page.setContent(content2);
rwb.storeNewOrUpdatePage(confSettings, confSettings.spaceKey, page);
try {
retpage = (Hashtable) client.execute("confluence1.getPage", paramsVector);
assertNotNull(retpage);
assertEquals(title, (String) retpage.get("title"));
assertEquals(content2, (String) retpage.get("content"));
} catch (XmlRpcException e) {
try { //XXX not sure how to test this in conf4
retpage = (Hashtable) client.execute("confluence1.getPageSummary", paramsVector);
assertNotNull(retpage);
assertEquals(title, (String) retpage.get("title"));
//assertEquals(content1, (String) retpage.get("content")); //not allowed as of Conf 4
} catch (XmlRpcException e1) {
fail();