LogMessageCacheUpdater implements RepositoryChangeListener { public void update(final RevisionUpdate revisionUpdate) { final RepositoryName repositoryName = revisionUpdate.getRepositoryName(); final List<LogEntry> revisions = revisionUpdate.getRevisions(); LOGGER.info("Listener got [" + revisions.size() + "] updated revision(s) for repository: " + repositoryName); final StopWatch stopWatch = new StopWatch(); stopWatch.start(); try { final LogMessageCache logMessageCache = logMessageCacheManager.getCache(repositoryName); if (revisionUpdate.isClearCacheBeforeUpdate()) { LOGGER.info("Clearing cache before population"); logMessageCache.clear(); } updateInternal(logMessageCache, revisions); } catch (final Exception ex) { LOGGER.warn("Could not update cache instance [" + repositoryName + "]", ex); } stopWatch.stop(); LOGGER.info("Update completed in [" + stopWatch.getTotalTimeSeconds() + "] seconds"); } LogMessageCacheUpdater(final LogMessageCacheManager logMessageCacheManager); void update(final RevisionUpdate revisionUpdate);  }
@Test public void testUpdate() throws Exception { final LogMessageCache cache = new CompassLogMessageCache(new File("test"), false); cache.init(); final List<LogEntry> logEntries = new ArrayList<LogEntry>(); logEntries.add(TestUtils.createLogEntry(123, null, null, "Log message for revision 123.")); logEntries.add(TestUtils.createLogEntry(124, null, null, "Log message for revision 124.")); assertEquals(0, cache.getSize()); final LogMessageCacheUpdater logMessageCacheUpdater = new LogMessageCacheUpdater(null); logMessageCacheUpdater.updateInternal(cache, logEntries); assertEquals(2, cache.find("revision").size()); }