String fzr = zr + "!/test.txt";
String fzd = zr + "!/dir/";
String fzr2 = fzd + "test2.txt";
// Write the text to file
ClientResource r = new ClientResource(fzr);
r.put(new StringRepresentation(text));
assertTrue(r.getStatus().equals(Status.SUCCESS_CREATED));
// Get the text and compare to the original
r.get();
assertTrue(r.getStatus().equals(Status.SUCCESS_OK));
assertEquals(r.getResponseEntity().getText(), text);
r.release();
// Write the text to file
ClientResource r2 = new ClientResource(fzr2);
r2.put(new StringRepresentation(text2));
assertTrue(r2.getStatus().equals(Status.SUCCESS_OK));
// Checking first one was not overwritten
r.get();
assertTrue(r.getStatus().equals(Status.SUCCESS_OK));
assertEquals(r.getResponseEntity().getText(), text);
r.release();
// Put a directory
ClientResource rd = new ClientResource(fzd);
rd.put(new EmptyRepresentation());
assertTrue(rd.getStatus().equals(Status.SUCCESS_OK));
rd.get();
assertTrue(rd.getStatus().equals(Status.SUCCESS_OK));
// Checking second one was output
r2.get();
assertTrue("Could not get " + fzr2, r2.getStatus().equals(
Status.SUCCESS_OK));
assertEquals(r2.getResponseEntity().getText(), text2);
ClientResource rTest2 = new ClientResource(zr + "!test2");
rTest2.get();
assertFalse(rTest2.getStatus().equals(Status.SUCCESS_OK));
// Try to replace file by directory
ClientResource r2d = new ClientResource(fzr2 + "/");
r2d.put(new EmptyRepresentation());
assertFalse(r2d.getStatus().equals(Status.SUCCESS_OK));
}