示例#1
0
 public boolean exportFile(String path, OutputStream out) throws IOException {
   for (FS fs : systems) {
     if (fs.exportFile(path, out)) {
       return true;
     }
   }
   return false;
 }
示例#2
0
 public Object[] getFileInfo(String path) throws IOException {
   for (FS fs : systems) {
     Object[] res = fs.getFileInfo(path);
     if (res != null) {
       return res;
     }
   }
   return null;
 }
示例#3
0
 @Test
 public void testCreateSymlink() throws IOException {
   FS fs = FS.DETECTED;
   try {
     fs.createSymLink(new File(trash, "x"), "y");
   } catch (IOException e) {
     if (fs.supportsSymlinks())
       fail("FS claims to support symlinks but attempt to create symlink failed");
     return;
   }
   assertTrue(fs.supportsSymlinks());
   String target = fs.readSymLink(new File(trash, "x"));
   assertEquals("y", target);
 }
示例#4
0
  /**
   * Get the unique testing directory while ensuring that it is empty (if not).
   *
   * @return the unique testing directory, created, and empty.
   */
  public File getEmptyDir() {
    if (dir.exists()) {
      FS.ensureEmpty(dir);
      return dir;
    }

    Assert.assertTrue("Creating testing dir", dir.mkdirs());
    return dir;
  }
  /**
   * Obtain a testing directory reference in maven <code>
   * ${basedir}/target/tests/${condensed-classname}/${methodname}</code> path that uses an condensed
   * directory name based on the testclass and subdirectory based on the testmethod being run.
   *
   * <p>Note: the &#064;Rule {@link TestingDir} is a better choice in most cases.
   *
   * @param testclass the class for the test case
   * @param testmethodname the test method name
   * @return the File path to the testname specific testing directory underneath the <code>
   *     ${basedir}/target/tests/</code> sub directory
   * @see FS
   * @see TestingDir
   */
  public static Path getTargetTestingPath(final Class<?> testclass, final String testmethodname) {
    String classname = testclass.getName();
    String methodname = testmethodname;

    classname = StringMangler.condensePackageString(classname);

    if (OS.IS_WINDOWS) {
      /* Condense the directory names to make them more friendly for the
       * 255 character pathname limitations that exist on windows.
       */
      methodname = StringMangler.maxStringLength(30, methodname);
    }

    Path testdir = getTargetTestingPath().resolve(methodname);
    FS.ensureDirExists(testdir);
    return testdir;
  }
示例#6
0
 public FileBasedConfig openUserConfig() {
   final File home = FS.userHome();
   return new FileBasedConfig(new File(home, ".gitconfig"));
 }
示例#7
0
 /**
  * Ensure that the test directory is empty.
  *
  * <p>Useful for repeated testing without using the maven <code>clean</code> goal (such as within
  * Eclipse).
  */
 public void ensureEmpty() {
   FS.ensureEmpty(dir);
 }