use of org.apache.jackrabbit.webdav.client.methods.PutMethod in project lobcder by skoulouzis.
the class TestWebWAVFS method testCreateAndDeleteFile.
@Test
public void testCreateAndDeleteFile() throws IOException, DavException {
System.err.println("testCreateAndDeleteFile");
// Make sure it's deleted
String testFileURI1 = uri.toASCIIString() + TestSettings.TEST_FILE_NAME1;
DeleteMethod del = new DeleteMethod(testFileURI1);
int status = client1.executeMethod(del);
testFileURI1 = uri.toASCIIString() + TestSettings.TEST_FILE_NAME1;
PutMethod put = new PutMethod(testFileURI1);
put.setRequestEntity(new StringRequestEntity(TestSettings.TEST_DATA, "text/plain", "UTF-8"));
status = client1.executeMethod(put);
assertEquals(HttpStatus.SC_CREATED, status);
String testFileURI2 = uri.toASCIIString() + TestSettings.TEST_TXT_FILE_NAME;
put = new PutMethod(testFileURI2);
put.setRequestEntity(new StringRequestEntity(TestSettings.TEST_DATA, "text/plain", "UTF-8"));
status = client1.executeMethod(put);
assertEquals(HttpStatus.SC_CREATED, status);
utils.deleteResource(testFileURI1, true);
utils.deleteResource(testFileURI2, true);
}
use of org.apache.jackrabbit.webdav.client.methods.PutMethod in project lobcder by skoulouzis.
the class TestWebWAVFS method testPutGet.
// @Test
// public void testUpDownloadFileWithSpace() throws IOException, DavException {
// System.err.println("testUpDownloadFileWithSpace");
// String testFileURI1 = uri.toASCIIString() + "file with spaces";
//
// utils.createFile(testFileURI1, true);
//
// GetMethod get = new GetMethod(testFileURI1);
// int status = client1.executeMethod(get);
// assertEquals(HttpStatus.SC_OK, status);
// assertEquals(TestSettings.TEST_DATA, get.getResponseBodyAsString());
//
// utils.deleteResource(testFileURI1, false);
// }
@Test
public void testPutGet() throws VlException, IOException {
System.err.println("testPutGet");
String testFileURI1 = uri.toASCIIString() + TestSettings.TEST_FILE_NAME1 + ".txt";
try {
PutMethod put = new PutMethod(testFileURI1);
put.setRequestEntity(new StringRequestEntity(TestSettings.TEST_DATA, "text/plain", "UTF-8"));
int status = client1.executeMethod(put);
assertEquals(HttpStatus.SC_CREATED, status);
GetMethod get = new GetMethod(testFileURI1);
client1.executeMethod(get);
status = get.getStatusCode();
assertEquals(HttpStatus.SC_OK, status);
String content = get.getResponseBodyAsString();
assertEquals(TestSettings.TEST_DATA.length(), content.length());
assertTrue(content.equals(TestSettings.TEST_DATA));
} finally {
utils.deleteResource(testFileURI1, false);
}
}
use of org.apache.jackrabbit.webdav.client.methods.PutMethod in project lobcder by skoulouzis.
the class TestWebWAVFS method testSetGetPropertySet.
@Test
public void testSetGetPropertySet() throws IOException, DavException {
System.err.println("testSetGetPropertySet");
String testFileURI1 = this.uri.toASCIIString() + TestSettings.TEST_FILE_NAME1 + ".txt";
PutMethod put = new PutMethod(testFileURI1);
put.setRequestEntity(new StringRequestEntity(TestSettings.TEST_DATA, "text/plain", "UTF-8"));
int status = client1.executeMethod(put);
assertEquals(HttpStatus.SC_CREATED, status);
PropFindMethod propFind = new PropFindMethod(testFileURI1, DavConstants.PROPFIND_ALL_PROP_INCLUDE, DavConstants.DEPTH_0);
status = client1.executeMethod(propFind);
assertEquals(HttpStatus.SC_MULTI_STATUS, status);
MultiStatus multiStatus = propFind.getResponseBodyAsMultiStatus();
MultiStatusResponse[] responses = multiStatus.getResponses();
assertEquals(HttpStatus.SC_OK, responses[0].getStatus()[0].getStatusCode());
DavPropertySet allProp = utils.getProperties(responses[0]);
// DavPropertyIterator iter = allProp.iterator();
// while (iter.hasNext()) {
// DavProperty<?> p = iter.nextProperty();
// System.out.println("P: " + p.getName() + " " + p.getValue());
// }
String isCollStr = (String) allProp.get(DavPropertyName.ISCOLLECTION).getValue();
Boolean isCollection = Boolean.getBoolean(isCollStr);
assertFalse(isCollection);
String lenStr = (String) allProp.get(DavPropertyName.GETCONTENTLENGTH).getValue();
assertEquals(Long.valueOf(lenStr), Long.valueOf(TestSettings.TEST_DATA.length()));
String contentType = (String) allProp.get(DavPropertyName.GETCONTENTTYPE).getValue();
assertEquals("text/plain; charset=UTF-8", contentType);
utils.deleteResource(testFileURI1, true);
}
Aggregations