@Override
  public String getCommandName() {
    return COMMAND_NAME;
  }
@Test
  public void linuxCmdExecuted()
          throws IOException, AlluxioException, NoSuchFieldException, IllegalAccessException {
    CollectEnvCommand cmd = new CollectEnvCommand(FileSystemContext.create());

    // Write to temp dir
    File targetDir = InfoCollectorTestUtils.createTemporaryDirectory();
    CommandLine mockCommandLine = mock(CommandLine.class);
    String[] mockArgs = new String[]{cmd.getCommandName(), targetDir.getAbsolutePath()};
    when(mockCommandLine.getArgs()).thenReturn(mockArgs);

    // Replace commands to execute
    Field f = cmd.getClass().getSuperclass().getDeclaredField("mCommands");
    f.setAccessible(true);

    ShellCommand mockCommand = mock(ShellCommand.class);
    when(mockCommand.runWithOutput()).thenReturn(new CommandReturn(0, "nothing happens"));
    when(mockCommandLine.getOptionValue("output-dir", ""))
            .thenReturn(targetDir.getAbsolutePath());
    Map<String, ShellCommand> mockCommandMap = new HashMap<>();
    mockCommandMap.put("mockCommand", mockCommand);
    f.set(cmd, mockCommandMap);

    int ret = cmd.run(mockCommandLine);
    assertEquals(0, ret);

    // Verify the command has been run
    verify(mockCommand).runWithOutput();

    // Files will be copied to sub-dir of target dir
    File subDir = new File(Paths.get(targetDir.getAbsolutePath(), cmd.getCommandName()).toString());
    assertEquals(new String[]{"collectEnv.txt"}, subDir.list());

    // Verify the command output is found
    String fileContent = new String(Files.readAllBytes(subDir.listFiles()[0].toPath()));
    assertTrue(fileContent.contains("nothing happens"));
  }