LuceneIndexForPartitionedRegion extends LuceneIndexImpl { @Override protected RepositoryManager createRepositoryManager(LuceneSerializer luceneSerializer) { LuceneSerializer mapper = luceneSerializer; if (mapper == null) { mapper = new HeterogeneousLuceneSerializer(); } PartitionedRepositoryManager partitionedRepositoryManager = new PartitionedRepositoryManager(this, mapper, this.waitingThreadPoolFromDM); return partitionedRepositoryManager; } LuceneIndexForPartitionedRegion(String indexName, String regionPath, InternalCache cache); @Override boolean isIndexingInProgress(); PartitionedRegion getFileAndChunkRegion(); FileSystemStats getFileSystemStats(); String createFileRegionName(); void close(); @Override void dumpFiles(final String directory); @Override void destroy(boolean initiator); @Override boolean isIndexAvailable(int id); static final String FILES_REGION_SUFFIX; }
@Test public void createRepositoryManagerWithNotNullSerializer() { String name = "indexName"; String regionPath = "regionName"; InternalCache cache = Fakes.cache(); LuceneSerializer serializer = mock(LuceneSerializer.class); LuceneIndexForPartitionedRegion index = new LuceneIndexForPartitionedRegion(name, regionPath, cache); index = spy(index); index.setupRepositoryManager(serializer); verify(index).createRepositoryManager(eq(serializer)); }
@Test public void createRepositoryManagerWithNullSerializer() { String name = "indexName"; String regionPath = "regionName"; String fields[] = {"field1", "field2"}; InternalCache cache = Fakes.cache(); ArgumentCaptor<LuceneSerializer> serializerCaptor = ArgumentCaptor.forClass(LuceneSerializer.class); LuceneIndexForPartitionedRegion index = new LuceneIndexForPartitionedRegion(name, regionPath, cache); index = spy(index); when(index.getFieldNames()).thenReturn(fields); index.setupRepositoryManager(null); verify(index).createRepositoryManager(serializerCaptor.capture()); LuceneSerializer serializer = serializerCaptor.getValue(); assertNull(serializer); }