@ParametersFactory
  public static Iterable<Object[]> parameters() {
    class Parameter {
      private final FileSystem fileSystem;
      private final Function<String, Path> temp;

      public Parameter(FileSystem fileSystem, String root) {
        this(
            fileSystem,
            s -> {
              try {
                return Files.createTempDirectory(fileSystem.getPath(root), s);
              } catch (IOException e) {
                throw new RuntimeException(e);
              }
            });
      }

      public Parameter(FileSystem fileSystem, Function<String, Path> temp) {
        this.fileSystem = fileSystem;
        this.temp = temp;
      }
    }
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(new Parameter(Jimfs.newFileSystem(Configuration.windows()), "c:\\"));
    parameters.add(new Parameter(Jimfs.newFileSystem(toPosix(Configuration.osX())), "/"));
    parameters.add(new Parameter(Jimfs.newFileSystem(toPosix(Configuration.unix())), "/"));
    parameters.add(new Parameter(PathUtils.getDefaultFileSystem(), LuceneTestCase::createTempDir));
    return parameters
        .stream()
        .map(p -> new Object[] {p.fileSystem, p.temp})
        .collect(Collectors.toList());
  }
 @SuppressForbidden(reason = "sets java.io.tmpdir")
 public InstallPluginCommandTests(FileSystem fs, Function<String, Path> temp) {
   this.fs = fs;
   this.temp = temp;
   this.isPosix = fs.supportedFileAttributeViews().contains("posix");
   this.isReal = fs == PathUtils.getDefaultFileSystem();
   PathUtilsForTesting.installMock(fs);
   javaIoTmpdir = System.getProperty("java.io.tmpdir");
   System.setProperty("java.io.tmpdir", temp.apply("tmpdir").toString());
 }
  @BeforeClass
  public static void installMockUsableSpaceFS() throws Exception {
    // Necessary so when Environment.clinit runs, to gather all FileStores, it sees ours:
    origFileSystem = FileSystems.getDefault();

    Field field = PathUtils.class.getDeclaredField("DEFAULT");
    field.setAccessible(true);
    FileSystem mock =
        new MockUsableSpaceFileSystemProvider().getFileSystem(getBaseTempDirForTestClass().toUri());
    field.set(null, mock);
    assertEquals(mock, PathUtils.getDefaultFileSystem());
  }