@Test
  public void testJre7OnMac() throws Exception {
    if (!SystemInfo.isMac) return;

    File standardJdkLocationDirectory = new File(STANDARD_JDK_LOCATION_ON_MAC_OS_X);
    File[] jre7Files = findJdkInDirectory(standardJdkLocationDirectory, "1.7.0");

    if (jre7Files == null || jre7Files.length == 0) return;

    boolean hasJre7 = false;
    for (File file : jre7Files) {
      if (!new File(file, "Contents/Home/lib/tools.jar").exists()) {
        hasJre7 = true;
        break;
      }
    }

    if (!hasJre7) return;

    JdkBundleList jdkBundleList = new JdkBundleList();
    jdkBundleList.addBundlesFromLocation(
        STANDARD_JDK_LOCATION_ON_MAC_OS_X, JDK7_VERSION, JDK7_VERSION);

    ArrayList<JdkBundle> bundles = jdkBundleList.toArrayList();

    for (JdkBundle bundle : bundles) {
      assertTrue(
          "jre \"" + bundle.getAbsoluteLocation().getAbsolutePath() + "\" found among jdk bundles",
          new File(bundle.getAbsoluteLocation(), "Contents/Home/lib/tools.jar").exists());
    }
  }
  @Test
  public void testCreateBoot() throws Exception {
    File homeJDK = new File(System.getProperty("java.home")).getParentFile();

    if (!new File(homeJDK, "lib/tools.jar").exists()) return; // Skip pure jre

    File bootJDK = SystemInfo.isMac ? homeJDK.getParentFile().getParentFile() : homeJDK;
    String verStr = System.getProperty("java.version");

    boolean macNonStandardJDK = SystemInfo.isMac && !new File(bootJDK, "Contents/Home").exists();
    JdkBundle bundle =
        macNonStandardJDK
            ? JdkBundle.createBoot(false)
            : // the test is run under jdk with non-standard layout
            JdkBundle.createBoot();

    assertNotNull(bundle);
    assertTrue(bundle.isBoot());
    assertFalse(bundle.isBundled());

    assertTrue(
        FileUtil.filesEqual(bundle.getAbsoluteLocation(), macNonStandardJDK ? homeJDK : bootJDK));
    Pair<Version, Integer> verUpdate = bundle.getVersionUpdate();

    assertNotNull(verUpdate);

    final String evalVerStr = verUpdate.first.toString() + "_" + verUpdate.second.toString();
    assertTrue(evalVerStr + " is not the same with " + verStr, verStr.contains(evalVerStr));
  }
  @Test
  public void testJdk6OnMac() throws Exception {
    if (!SystemInfo.isMac) return;

    boolean testPassed;

    File[] jdk6Files = null;

    File standardJdk6LocationDirectory = new File(STANDARD_JDK_6_LOCATION_ON_MAC_OS_X);

    if (standardJdk6LocationDirectory.exists()) {
      jdk6Files = findJdkInDirectory(standardJdk6LocationDirectory, "1.6.0");
    }

    if (jdk6Files == null || jdk6Files.length == 0) {
      File standardJdkLocationDirectory = new File(STANDARD_JDK_LOCATION_ON_MAC_OS_X);
      jdk6Files = findJdkInDirectory(standardJdkLocationDirectory, "1.6.0");
    }

    if (jdk6Files == null || jdk6Files.length == 0) {
      // We have not found any jdk6 installation. Nothing to test.
      return;
    }

    JdkBundleList jdkBundleList = new JdkBundleList();
    jdkBundleList.addBundlesFromLocation(
        STANDARD_JDK_6_LOCATION_ON_MAC_OS_X, JDK6_VERSION, JDK6_VERSION);
    jdkBundleList.addBundlesFromLocation(
        STANDARD_JDK_LOCATION_ON_MAC_OS_X, JDK6_VERSION, JDK6_VERSION);

    ArrayList<JdkBundle> bundles = jdkBundleList.toArrayList();

    for (File file : jdk6Files) {
      testPassed = false;
      for (JdkBundle bundle : bundles) {
        if (FileUtil.filesEqual(bundle.getAbsoluteLocation(), file)) {
          testPassed = true;
          break;
        }
      }
      assertTrue(file.getAbsolutePath() + " has not been found among jdk bundles.", testPassed);
    }
  }