use of org.apache.jackrabbit.webdav.client.methods.CopyMethod 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