@Test
public void testCalculateBaseURL() throws Exception {

    List<DavResource> resources = new ArrayList<DavResource>(2);
    final DavResource baseResource = Mockito.mock(DavResource.class);
    Mockito.when(baseResource.getPath()).thenReturn("/webdav/");
    final DavResource otherResource = Mockito.mock(DavResource.class);
    Mockito.when(otherResource.getPath()).thenReturn("/webdav/metadata.xml");
    resources.add(baseResource);
    resources.add(otherResource);
    final String baseURL = WebDavRetriever.calculateBaseURL(new AtomicBoolean(), "http://geonetwork.net/webdav/", resources);
    assertEquals("http://geonetwork.net", baseURL);
    assertEquals(1, resources.size());
    assertFalse(resources.contains(baseResource));
    assertTrue(resources.contains(otherResource));
}