public final void testDropResourceRoot() throws Exception { Collection author = this.dbColl.getChildCollection("vcl-data/author"); Collection vcoll = this.dbColl.getChildCollection("vcl-data/myvc"); int size = vcoll.getResourceCount(); Resource res = author.getResource("author.4.manuel.xml"); author.removeResource(res); assertEquals(size - 1, vcoll.getResourceCount()); }
public final void testDropResourceSubset() throws Exception { Collection article = this.dbColl.getChildCollection("vcl-data/article"); int size = article.getResourceCount(); Resource r = article.getResource("article.from.manuel.xml"); // Just do it if the resource exists. if (r != null) { article.removeResource(r); assertEquals(size - 1, article.getResourceCount()); } }
public final void testDropVirtualResourceFail() throws Exception { Collection vcoll = this.dbColl.getChildCollection("vcl-data/myvc"); String[] names = vcoll.listResources(); for (int i = 0; i < names.length; i++) { Resource res = vcoll.getResource(names[i]); assertTrue( "Expected instance of VirtualResource and not " + res.getClass(), res instanceof VirtualResource); try { vcoll.removeResource(res); assertTrue("Cannot delete a VirtualResource.", false); } catch (XMLDBException e) { assertTrue( "Expected errorCode.INVALID_COLLECTION", e.errorCode == ErrorCodes.INVALID_COLLECTION); } } }