String wikiTextFileUrl = pageUrl + "/wiki.txt";
String wikiXMLFileUrl = pageUrl + "/wiki.xml";
String newContent = "New Content";
DeleteMethod deleteMethod = new DeleteMethod();
deleteMethod.setDoAuthentication(true);
MkcolMethod mkColMethod = new MkcolMethod();
mkColMethod.setDoAuthentication(true);
PutMethod putMethod = new PutMethod();
putMethod.setDoAuthentication(true);
GetMethod getMethod = new GetMethod();
getMethod.setDoAuthentication(true);
try {
deleteMethod.setPath(spaceUrl);
assertEquals(DavServletResponse.SC_NO_CONTENT, getHttpClient().executeMethod(deleteMethod));
mkColMethod.setPath(spaceUrl);
assertEquals(DavServletResponse.SC_CREATED, getHttpClient().executeMethod(mkColMethod));
mkColMethod.setPath(pageUrl);
assertEquals(DavServletResponse.SC_CREATED, getHttpClient().executeMethod(mkColMethod));
putMethod.setPath(wikiTextFileUrl);
putMethod.setRequestEntity(new InputStreamRequestEntity(new ByteArrayInputStream(newContent.getBytes())));
// Already existing resource, in which case SC_NO_CONTENT will be the return status.
assertEquals(DavServletResponse.SC_NO_CONTENT, getHttpClient().executeMethod(putMethod));