MongoDBIpBasedQueue extends AbstractIpAddressBasedQueue { @Override protected void deleteUris(InetAddress ipAddress, List<CrawleableUri> uris) { Document query = new Document(); query.put("ipAddress", ipAddress.getHostAddress()); query.put("type", DEFAULT_TYPE); for (CrawleableUri uri : uris) { query.put("_id", uri.getUri().hashCode()); mongoDB.getCollection(COLLECTION_URIS).deleteMany(query); } query.remove("_id"); if (mongoDB.getCollection(COLLECTION_URIS).find(query).first() == null) { mongoDB.getCollection(COLLECTION_QUEUE) .deleteMany(query); } } MongoDBIpBasedQueue(String hostName, Integer port, boolean includeDepth);  MongoDBIpBasedQueue(String hostName, Integer port, Serializer serializer, boolean includeDepth); void purge(); long length(); @Override void close(); @Override void open(); boolean queueTableExists(); @SuppressWarnings("unchecked") @Override List<CrawleableUri> getUris(InetAddress address); Document getUriDocument(CrawleableUri uri); Document getIpDocument(InetAddress address); @Deprecated List<String> getIpAddressTypeKey(CrawleableUri uri); @Deprecated List<String> packTuple(String str_1, String str_2); @Override boolean isEmpty();  }
@Test public void deleteUris() throws Exception { mongodbQueue.open(); mongodbQueue.purge(); mongodbQueue.addUri(uris.get(1)); List<CrawleableUri> retrievedUris = mongodbQueue.getNextUris(); assertEquals(1, retrievedUris.size()); assertTrue(uris.get(1).equals(retrievedUris.get(0))); mongodbQueue.addUri(uris.get(2)); assertNull(mongodbQueue.getNextUris()); mongodbQueue.markUrisAsAccessible(retrievedUris); assertEquals(1, mongodbQueue.length()); retrievedUris = mongodbQueue.getNextUris(); assertEquals(1, retrievedUris.size()); assertTrue(uris.get(2).equals(retrievedUris.get(0))); mongodbQueue.markUrisAsAccessible(retrievedUris); assertEquals(0, mongodbQueue.length()); mongodbQueue.close(); }