use of org.apache.jackrabbit.webdav.client.methods.MkColMethod in project lobcder by skoulouzis.
the class Utils method createCollection.
public void createCollection(String resource, boolean mustSucceed) throws IOException {
MkColMethod mkcol = new MkColMethod(resource);
int status = this.client.executeMethod(mkcol);
if (mustSucceed) {
assertEquals(HttpStatus.SC_CREATED, status);
}
// PutMethod put = new PutMethod(this.root + testResourceId + "/file1");
// put.setRequestEntity(new StringRequestEntity("foo", "text/plain", "UTF-8"));
// status = this.client.executeMethod(put);
// assertEquals(HttpStatus.SC_CREATED, status);
// //Are you sure it's there ????
// GetMethod get = new GetMethod(this.root + testResourceId + "/file1");
// status = client.executeMethod(get);
// assertEquals(HttpStatus.SC_OK, status);
// assertEquals("foo", get.getResponseBodyAsString());
// put = new PutMethod(this.root + "testResourceId/file2");
// put.setRequestEntity(new StringRequestEntity("foo", "text/plain", "UTF-8"));
// status = this.client.executeMethod(put);
// assertEquals(HttpStatus.SC_CREATED, status);
}
use of org.apache.jackrabbit.webdav.client.methods.MkColMethod in project lobcder by skoulouzis.
the class TestWebWAVFS method testCopy.
@Test
public void testCopy() throws VlException, IOException {
System.err.println("testCopy");
String testFileURI1 = this.uri.toASCIIString() + TestSettings.TEST_FILE_NAME1 + ".txt";
String testcol = root + "testResourceId/";
try {
PutMethod put = new PutMethod(testFileURI1);
put.setRequestEntity(new StringRequestEntity(TestSettings.TEST_DATA, "text/plain", "UTF-8"));
int status = client1.executeMethod(put);
assertTrue(status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED);
GetMethod get = new GetMethod(testFileURI1);
status = client1.executeMethod(get);
assertEquals(HttpStatus.SC_OK, status);
String cont = get.getResponseBodyAsString();
assertEquals(TestSettings.TEST_DATA, cont);
MkColMethod mkcol = new MkColMethod(testcol);
status = client1.executeMethod(mkcol);
assertEquals(HttpStatus.SC_CREATED, status);
String targetURL = testcol + TestSettings.TEST_FILE_NAME1 + ".txt";
CopyMethod cp = new CopyMethod(testFileURI1, targetURL, true);
status = client1.executeMethod(cp);
assertTrue(status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED);
get = new GetMethod(targetURL);
status = client1.executeMethod(get);
assertEquals(HttpStatus.SC_OK, status);
cont = get.getResponseBodyAsString();
System.out.println(cont);
assertEquals(TestSettings.TEST_DATA, cont);
} finally {
utils.deleteResource(testcol, false);
utils.deleteResource(testFileURI1, false);
}
}
Aggregations