public static MockDirectoryWrapper newMockDirectory(Random r) { return (MockDirectoryWrapper) wrapDirectory(r, newDirectoryImpl(r, TEST_DIRECTORY), false); }
public static MockDirectoryWrapper newMockDirectory(Random r, LockFactory lf) { return (MockDirectoryWrapper) wrapDirectory(r, newDirectoryImpl(r, TEST_DIRECTORY, lf), false); }
/** * Returns a new Directory instance, using the specified random. * See {@link #newDirectory()} for more information. */ public static BaseDirectoryWrapper newDirectory(Random r) { return wrapDirectory(r, newDirectoryImpl(r, TEST_DIRECTORY), rarely(r)); }
/** * Returns a new Directory instance, using the specified random. * See {@link #newDirectory()} for more information. */ public static BaseDirectoryWrapper newDirectory(Random r, LockFactory lf) { return wrapDirectory(r, newDirectoryImpl(r, TEST_DIRECTORY, lf), rarely(r)); }
/** * Returns a new Directory instance, using the specified random * with contents copied from the provided directory. See * {@link #newDirectory()} for more information. */ public static BaseDirectoryWrapper newDirectory(Random r, Directory d) throws IOException { Directory impl = newDirectoryImpl(r, TEST_DIRECTORY); for (String file : d.listAll()) { if (file.startsWith(IndexFileNames.SEGMENTS) || IndexFileNames.CODEC_FILE_PATTERN.matcher(file).matches()) { impl.copyFrom(d, file, file, newIOContext(r)); } } return wrapDirectory(r, impl, rarely(r)); }
private static BaseDirectoryWrapper newFSDirectory(Path f, LockFactory lf, boolean bare) { String fsdirClass = TEST_DIRECTORY; if (fsdirClass.equals("random")) { fsdirClass = RandomPicks.randomFrom(random(), FS_DIRECTORIES); } Class<? extends FSDirectory> clazz; try { try { clazz = CommandLineUtil.loadFSDirectoryClass(fsdirClass); } catch (ClassCastException e) { // TEST_DIRECTORY is not a sub-class of FSDirectory, so draw one at random fsdirClass = RandomPicks.randomFrom(random(), FS_DIRECTORIES); clazz = CommandLineUtil.loadFSDirectoryClass(fsdirClass); } Directory fsdir = newFSDirectoryImpl(clazz, f, lf); BaseDirectoryWrapper wrapped = wrapDirectory(random(), fsdir, bare); return wrapped; } catch (Exception e) { Rethrow.rethrow(e); throw null; // dummy to prevent compiler failure } }