/** * Returns a new Directory instance, with contents copied from the * provided directory. See {@link #newDirectory()} for more * information. */ public static BaseDirectoryWrapper newDirectory(Directory d) throws IOException { return newDirectory(random(), d); }
/** * Returns a new Directory instance. Use this when the test does not * care about the specific Directory implementation (most tests). * <p> * The Directory is wrapped with {@link BaseDirectoryWrapper}. * this means usually it will be picky, such as ensuring that you * properly close it and all open files in your test. It will emulate * some features of Windows, such as not allowing open files to be * overwritten. */ public static BaseDirectoryWrapper newDirectory() { return newDirectory(random()); }
/** Like {@link #newDirectory} except randomly the {@link VirusCheckingFS} may be installed */ public static BaseDirectoryWrapper newMaybeVirusCheckingDirectory() { if (random().nextInt(5) == 4) { Path path = addVirusChecker(createTempDir()); return newFSDirectory(path); } else { return newDirectory(random()); } }
Directory dir; if (useMockDirectoryWrapper) dir = LuceneTestCase.newMockDirectory(); else dir = LuceneTestCase.newDirectory(); // we ignore the given lock factory