@Test(expected = TimeoutException.class)
public void testResetThrowsExceptionWhenReadersAreNotClosed() throws Exception {

    GeonetworkDataDirectory datadir = Mockito.mock(GeonetworkDataDirectory.class);
    Mockito.when(datadir.getLuceneDir()).thenReturn(folder.getRoot().toPath());
    FSDirectoryFactory directoryFactory = new FSDirectoryFactory();
    LuceneConfig luceneConfig = Mockito.mock(LuceneConfig.class);
    Mockito.when(luceneConfig.commitInterval()).thenReturn(1L);
    Mockito.when(luceneConfig.useNRTManagerReopenThread()).thenReturn(false);
    Mockito.when(luceneConfig.getTaxonomyConfiguration()).thenReturn(new FacetsConfig());
    final ConfigurableApplicationContext applicationContext = Mockito.mock(ConfigurableApplicationContext.class);
    ApplicationContextHolder.set(applicationContext);
    Mockito.when(applicationContext.getBean(GeonetworkDataDirectory.class)).thenReturn(datadir);
    Mockito.when(applicationContext.getBean(DirectoryFactory.class)).thenReturn(directoryFactory);
    Mockito.when(applicationContext.getBean(LuceneConfig.class)).thenReturn(luceneConfig);
    final LuceneIndexLanguageTracker tracker = new LuceneIndexLanguageTracker();
    addDocumentAndAssertCorrectlyAdded(tracker);
    tracker.reset(500);
}