@Test
  public void testFileStoreReport() throws Exception {
    Path targetPath = detectTargetFolder().toPath();
    Path lclSftp =
        Utils.resolve(
            targetPath,
            SftpConstants.SFTP_SUBSYSTEM_NAME,
            getClass().getSimpleName(),
            getCurrentTestName());
    Path parentPath = targetPath.getParent();
    FileStore store = Files.getFileStore(lclSftp.getRoot());
    final String queryPath = Utils.resolveRelativeRemotePath(parentPath, lclSftp);
    final SpaceAvailableExtensionInfo expected = new SpaceAvailableExtensionInfo(store);
    sshd.setSubsystemFactories(
        Arrays.<NamedFactory<Command>>asList(
            new SftpSubsystemFactory() {
              @Override
              public Command create() {
                return new SftpSubsystem(
                    getExecutorService(), isShutdownOnExit(), getUnsupportedAttributePolicy()) {
                  @Override
                  protected SpaceAvailableExtensionInfo doSpaceAvailable(int id, String path)
                      throws IOException {
                    if (!queryPath.equals(path)) {
                      throw new StreamCorruptedException(
                          "Mismatched query paths: expected=" + queryPath + ", actual=" + path);
                    }

                    return expected;
                  }
                };
              }
            }));

    try (SshClient client = SshClient.setUpDefaultClient()) {
      client.start();

      try (ClientSession session =
          client
              .connect(getCurrentTestName(), "localhost", port)
              .verify(7L, TimeUnit.SECONDS)
              .getSession()) {
        session.addPasswordIdentity(getCurrentTestName());
        session.auth().verify(5L, TimeUnit.SECONDS);

        try (SftpClient sftp = session.createSftpClient()) {
          SpaceAvailableExtension ext = assertExtensionCreated(sftp, SpaceAvailableExtension.class);
          SpaceAvailableExtensionInfo actual = ext.available(queryPath);
          assertEquals("Mismatched information", expected, actual);
        }
      } finally {
        client.stop();
      }
    }
  }
  @Test
  public void testGitPgm() throws Exception {
    Path targetParent = detectTargetFolder().getParent();
    Path serverDir = getTempTargetRelativeFile(getClass().getSimpleName());

    //
    // TODO: the GitpgmCommandFactory is kept in the test tree
    // TODO: because it's quite limited for now
    //

    try (SshServer sshd = setupTestServer()) {
      sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystemFactory()));
      sshd.setCommandFactory(
          new GitPgmCommandFactory(Utils.resolveRelativeRemotePath(targetParent, serverDir)));
      sshd.start();

      int port = sshd.getPort();
      try {
        Utils.deleteRecursive(serverDir);

        try (SshClient client = setupTestClient()) {
          client.start();

          try (ClientSession session =
              client
                  .connect(getCurrentTestName(), SshdSocketAddress.LOCALHOST_IP, port)
                  .verify(7L, TimeUnit.SECONDS)
                  .getSession()) {
            session.addPasswordIdentity(getCurrentTestName());
            session.auth().verify(5L, TimeUnit.SECONDS);

            Path repo = serverDir.resolve(getCurrentTestName());
            Git.init().setDirectory(repo.toFile()).call();
            Git git = Git.open(repo.toFile());
            git.commit()
                .setMessage("First Commit")
                .setCommitter(getCurrentTestName(), "*****@*****.**")
                .call();

            Path readmeFile = Files.createFile(repo.resolve("readme.txt"));
            String commandPrefix = "git --git-dir " + repo.getFileName();
            execute(session, commandPrefix + " add " + readmeFile.getFileName());
            execute(session, commandPrefix + " commit -m \"readme\"");
          } finally {
            client.stop();
          }
        }
      } finally {
        sshd.stop();
      }
    }
  }