### Question:
ConcurrentQueryLoader implements Closeable { public void add(MonitorQuery mq) throws InterruptedException { if (shutdown) throw new IllegalStateException("ConcurrentQueryLoader has been shutdown, cannot add new queries"); this.queue.put(mq); } ConcurrentQueryLoader(Monitor monitor, List<QueryError> errors);  ConcurrentQueryLoader(Monitor monitor, List<QueryError> errors, int threads, int queueSize); void add(MonitorQuery mq); @Override void close(); static final int DEFAULT_QUEUE_SIZE; }### Answer:
@Test public void testLoading() throws Exception { try (Monitor monitor = new Monitor(new LuceneQueryParser("f"), new MatchAllPresearcher())) { List<QueryError> errors = new ArrayList<>(); try (ConcurrentQueryLoader loader = new ConcurrentQueryLoader(monitor, errors)) { for (int i = 0; i < 2000; i++) { loader.add(new MonitorQuery(Integer.toString(i), "\"test " + i + "\"")); } assertThat(errors).isEmpty(); } assertThat(monitor.getQueryCount()).isEqualTo(2000); } }
@Test public void testErrorHandling() throws Exception { try (Monitor monitor = new Monitor(new LuceneQueryParser("f"), new MatchAllPresearcher())) { List<QueryError> errors = new ArrayList<>(); try (ConcurrentQueryLoader loader = new ConcurrentQueryLoader(monitor, errors)) { for (int i = 0; i < 2000; i++) { String query = "test" + i; if (i % 200 == 0) query += " ["; loader.add(new MonitorQuery(Integer.toString(i), query)); } } assertThat(errors).hasSize(10); assertThat(monitor.getQueryCount()).isEqualTo(1990); } }