Search in sources :

Example 1 with DirContext

use of org.apache.solr.core.DirectoryFactory.DirContext in project lucene-solr by apache.

the class RAMDirectoryFactoryTest method dotestOpenReturnsTheSameForSamePath.

private void dotestOpenReturnsTheSameForSamePath() throws IOException {
    final Directory directory = new RAMDirectory();
    RAMDirectoryFactory factory = new RAMDirectoryFactory() {

        @Override
        protected Directory create(String path, LockFactory lockFactory, DirContext dirContext) {
            return directory;
        }
    };
    String path = "/fake/path";
    Directory dir1 = factory.get(path, DirContext.DEFAULT, DirectoryFactory.LOCK_TYPE_SINGLE);
    Directory dir2 = factory.get(path, DirContext.DEFAULT, DirectoryFactory.LOCK_TYPE_SINGLE);
    assertEquals("RAMDirectoryFactory should not create new instance of RefCntRamDirectory " + "every time open() is called for the same path", dir1, dir2);
    factory.release(dir1);
    factory.release(dir2);
    factory.close();
}
Also used : LockFactory(org.apache.lucene.store.LockFactory) DirContext(org.apache.solr.core.DirectoryFactory.DirContext) RAMDirectory(org.apache.lucene.store.RAMDirectory) Directory(org.apache.lucene.store.Directory) RAMDirectory(org.apache.lucene.store.RAMDirectory)

Aggregations

Directory (org.apache.lucene.store.Directory)1 LockFactory (org.apache.lucene.store.LockFactory)1 RAMDirectory (org.apache.lucene.store.RAMDirectory)1 DirContext (org.apache.solr.core.DirectoryFactory.DirContext)1