use of nl.uva.cs.lobcder.tests.TestREST.PDRIDesc in project lobcder by skoulouzis.
the class TestWebWAVFS method deletePhysicalData.
private void deletePhysicalData(Set<PDRIDesc> pdris) throws VlException {
String endpoint = "";
for (PDRIDesc p : pdris) {
VFSClient cli = getVFSClient(p.resourceUrl, p.username, p.password);
if (p.resourceUrl.startsWith("/")) {
endpoint = "file:///" + p.resourceUrl;
} else {
endpoint = p.resourceUrl;
}
VRL vrl = new VRL(endpoint).append("LOBCDER-REPLICA-vTEST").append(p.name);
// VRL vrl = new VRL(endpoint).append(p.name);
System.err.println("Deleting: " + vrl);
cli.openLocation(vrl).delete();
}
}
use of nl.uva.cs.lobcder.tests.TestREST.PDRIDesc in project lobcder by skoulouzis.
the class TestWebWAVFS method testInconsistency.
@Test
public void testInconsistency() throws VlException, IOException {
System.err.println("testInconsistency");
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);
Set<PDRIDesc> pdris = null;
// Wait for replication
utils.waitForReplication(testFileURI1);
pdris = getPdris(TestSettings.TEST_FILE_NAME1 + ".txt");
// Delete the physical data
deletePhysicalData(pdris);
GetMethod get = new GetMethod(testFileURI1);
status = client1.executeMethod(get);
String cont = get.getResponseBodyAsString();
// There is no offical status to get from this but confilct seems apropriate:
// Status code (409) indicating that the request could not be
// completed due to a conflict with the current state of the resource.
// Meaning at this time we have no physical data
assertEquals(HttpStatus.SC_CONFLICT, status);
} catch (Exception ex) {
Logger.getLogger(TestWebWAVFS.class.getName()).log(Level.SEVERE, null, ex);
fail(ex.getMessage());
} finally {
utils.deleteResource(testFileURI1, false);
}
}
Aggregations