private static void loadPlatformZipPropertiesFromFile() {
   File installLocation = getInstallLocation();
   if (installLocation != null) {
     // parent will be "eclipse" and the parent's parent will be "eclipse-testing"
     File parent = installLocation.getParentFile();
     if (parent != null) {
       parent = parent.getParentFile();
       if (parent != null) {
         File propertiesFile = new File(parent, "equinoxp2tests.properties");
         if (!propertiesFile.exists()) return;
         archiveAndRepositoryProperties = new Properties();
         try {
           InputStream is = null;
           try {
             is = new BufferedInputStream(new FileInputStream(propertiesFile));
             archiveAndRepositoryProperties.load(is);
           } finally {
             is.close();
           }
         } catch (IOException e) {
           return;
         }
       }
     }
   }
 }
 protected static int run(String message, String[] commandArray, File outputFile) {
   PrintStream out = System.out;
   PrintStream err = System.err;
   PrintStream fileStream = null;
   try {
     outputFile.getParentFile().mkdirs();
     fileStream = new PrintStream(new FileOutputStream(outputFile));
     System.setErr(fileStream);
     System.setOut(fileStream);
     return run(message, commandArray);
   } catch (FileNotFoundException e) {
     return -1;
   } finally {
     System.setOut(out);
     System.setErr(err);
     if (fileStream != null) fileStream.close();
   }
 }
 /*
  * Create a link file in the links folder. Point it to the given extension location.
  */
 public void createLinkFile(String message, String filename, String extensionLocation) {
   File file = new File(output, getRootFolder() + "links/" + filename + ".link");
   file.getParentFile().mkdirs();
   Properties properties = new Properties();
   properties.put("path", extensionLocation);
   OutputStream stream = null;
   try {
     stream = new BufferedOutputStream(new FileOutputStream(file));
     properties.store(stream, null);
   } catch (IOException e) {
     fail(message, e);
   } finally {
     try {
       if (stream != null) stream.close();
     } catch (IOException e) {
       // ignore
     }
   }
 }
  /*
   * Return a file handle pointing to the platform binary zip. Method never returns null because
   * it will fail an assert before that.
   */
  private File getPlatformZip() {
    String property = null;
    File file = null;
    if (propertyToPlatformArchive != null) {
      property = getValueFor(propertyToPlatformArchive);
      String message =
          "Need to set the "
              + "\""
              + propertyToPlatformArchive
              + "\" system property with a valid path to the platform binary drop or copy the archive to be a sibling of the install folder.";
      if (property == null) {
        fail(message);
      }
      file = new File(property);
      assertNotNull(message, file);
      assertTrue(message, file.exists());
      assertTrue("File is zero length: " + file.getAbsolutePath(), file.length() > 0);
      return file;
    }

    property = getValueFor("org.eclipse.equinox.p2.reconciler.tests.platform.archive");
    if (property == null) {
      // the releng test framework copies the zip so let's look for it...
      // it will be a sibling of the eclipse/ folder that we are running
      File installLocation = getInstallLocation();
      if (Platform.getWS().equals(Platform.WS_COCOA))
        installLocation = installLocation.getParentFile().getParentFile();

      if (installLocation != null) {
        // parent will be "eclipse" and the parent's parent will be "eclipse-testing"
        File parent = installLocation.getParentFile();
        if (parent != null) {
          parent = parent.getParentFile();
          if (parent != null) {
            File[] children =
                parent.listFiles(
                    new FileFilter() {
                      public boolean accept(File pathname) {
                        String name = pathname.getName();
                        return name.startsWith("eclipse-platform-");
                      }
                    });
            if (children != null && children.length == 1) file = children[0];
          }
        }
      }
    } else {
      file = new File(property);
    }
    StringBuffer detailedMessage = new StringBuffer(600);
    detailedMessage
        .append(" propertyToPlatformArchive was ")
        .append(propertyToPlatformArchive == null ? " not set " : propertyToPlatformArchive)
        .append('\n');
    detailedMessage
        .append(" org.eclipse.equinox.p2.reconciler.tests.platform.archive was ")
        .append(property == null ? " not set " : property)
        .append('\n');
    detailedMessage.append(" install location is ").append(getInstallLocation()).append('\n');
    String message =
        "Need to set the \"org.eclipse.equinox.p2.reconciler.tests.platform.archive\" system property with a valid path to the platform binary drop or copy the archive to be a sibling of the install folder.";
    assertNotNull(message + "\n" + detailedMessage, file);
    assertTrue(message, file.exists());
    assertTrue("File is zero length: " + file.getAbsolutePath(), file.length() > 0);
    return file;
  }