* Test that a new TFC is only calculated and placed in memory (by two
* threads who want it at the same time) only once.
*/
@Test
public void testMemoryCacheSynchronization() throws Exception {
SlowRAMDirectory indexDir = new SlowRAMDirectory(-1, null);
SlowRAMDirectory taxoDir = new SlowRAMDirectory(-1, null);
// Write index using 'normal' directories
IndexWriter w = new IndexWriter(indexDir, new IndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)));
DirectoryTaxonomyWriter tw = new DirectoryTaxonomyWriter(taxoDir);
DefaultFacetIndexingParams iParams = new DefaultFacetIndexingParams();
// Add documents and facets
for (int i = 0; i < 1000; i++) {
addFacets(iParams, w, tw, "facet", Integer.toString(i));
}
w.close();
tw.close();
indexDir.setSleepMillis(1);
taxoDir.setSleepMillis(1);
IndexReader r = IndexReader.open(indexDir);
DirectoryTaxonomyReader tr = new DirectoryTaxonomyReader(taxoDir);
// Create and start threads. Thread1 should lock the cache and calculate