Search in sources :

Example 1 with PDRIDesc

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();
    }
}
Also used : VRL(nl.uva.vlet.vrl.VRL) VFSClient(nl.uva.vlet.vfs.VFSClient) PDRIDesc(nl.uva.cs.lobcder.tests.TestREST.PDRIDesc)

Example 2 with PDRIDesc

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);
    }
}
Also used : StringRequestEntity(org.apache.commons.httpclient.methods.StringRequestEntity) PDRIDesc(nl.uva.cs.lobcder.tests.TestREST.PDRIDesc) GetMethod(org.apache.commons.httpclient.methods.GetMethod) PutMethod(org.apache.jackrabbit.webdav.client.methods.PutMethod) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) VlException(nl.uva.vlet.exception.VlException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

PDRIDesc (nl.uva.cs.lobcder.tests.TestREST.PDRIDesc)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 VlException (nl.uva.vlet.exception.VlException)1 VFSClient (nl.uva.vlet.vfs.VFSClient)1 VRL (nl.uva.vlet.vrl.VRL)1 GetMethod (org.apache.commons.httpclient.methods.GetMethod)1 StringRequestEntity (org.apache.commons.httpclient.methods.StringRequestEntity)1 PutMethod (org.apache.jackrabbit.webdav.client.methods.PutMethod)1 Test (org.junit.Test)1