### Question:
QueryExpirationBean { @Schedule(hour = "*", minute = "*", second = "*/30", persistent = false) public void removeIdleOrExpired() { if (log.isDebugEnabled()) { log.debug("@Schedule - removeIdleOrExpired"); } long now = System.currentTimeMillis(); clearQueries(now); qlCache.clearQueryLogics(now, conf.getCallTimeInMS()); }  @PostConstruct void init(); @PreDestroy void close(); @Schedule(hour = "*", minute = "*", second = "*/30", persistent = false) void removeIdleOrExpired();  }### Answer:
@Test public void testRemoveIdleOrExpired() throws Exception { QueryExpirationBean bean = createBean(0); RunningQuery query = createRunningQuery(); bean.init(); String qid = query.getSettings().getId().toString(); queryCache.put(qid, query); qlCache.add(qid, "test", query.getLogic(), null); Assert.assertTrue("Query Cache doesn't contain query", queryCache.containsKey(qid)); Assert.assertTrue("Query Logic Cache doesn't contain query logic", qlCache.snapshot().containsKey(qid)); bean.removeIdleOrExpired(); Assert.assertFalse("Query Cache still contains query", queryCache.containsKey(qid)); Assert.assertFalse("Query Logic Cache still contains query logic", qlCache.snapshot().containsKey(qid)); for (int i = 0; i < 5; i++) { RunningQuery runningQuery = createRunningQuery(); String key = runningQuery.getSettings().getId().toString(); queryCache.put(key, runningQuery); qlCache.add(key, key, runningQuery.getLogic(), null); } int queryCacheSize = Whitebox.getInternalState(queryCache, Cache.class).asMap().size(); Assert.assertEquals(5, queryCacheSize); Assert.assertEquals(5, qlCache.snapshot().size()); bean.close(); qlCache.shutdown(); queryCacheSize = Whitebox.getInternalState(queryCache, Cache.class).asMap().size(); Assert.assertEquals("Query Cache is not empty: " + queryCacheSize, 0, queryCacheSize); Assert.assertEquals("Query Logic Cache is not empty: " + qlCache.snapshot().size(), 0, qlCache.snapshot().size()); }