/**
   * Runs the console installer against a script with an alternative uninstaller name and path,
   * verifying that the correct uninstall JAR and registry value are created.
   *
   * @throws Exception for any error
   */
  @Test
  @InstallFile("samples/windows/consoleinstall_alt_uninstall.xml")
  public void testNonDefaultUninstaller() throws Exception {
    Assume.assumeTrue(
        "This test must be run as administrator, or with Windows UAC turned off",
        !skipTests && isAdminUser);

    assertFalse(registryKeyExists(handler, DEFAULT_UNINSTALL_KEY));

    TestConsole console = installer.getConsole();
    console.addScript("CheckedHelloPanel", "1");
    console.addScript("InfoPanel", "1");
    console.addScript("TargetPanel", "\n", "O", "1");

    // run installer and check that default uninstaller doesn't exist
    InstallData installData = getInstallData();
    checkInstall(installer, installData, false);

    // check that uninstaller exists as specified in install spec
    String installPath = installData.getInstallPath();
    assertTrue(new File(installPath, "/uninstallme.jar").exists());

    // check that the registry key has the correct value
    assertTrue(registryKeyExists(handler, DEFAULT_UNINSTALL_KEY));
    String command =
        "\""
            + installData.getVariable("JAVA_HOME")
            + "\\bin\\javaw.exe\" -jar \""
            + installPath
            + "\\uninstallme.jar\"";
    registryValueStringEquals(handler, DEFAULT_UNINSTALL_KEY, UNINSTALL_CMD_VALUE, command);
  }
예제 #2
0
  private Map<String, Pack> loadInstallationInformation(boolean modifyInstallation) {
    Map<String, Pack> installedpacks = new HashMap<String, Pack>();
    if (!modifyInstallation) {
      return installedpacks;
    }

    // installation shall be modified
    // load installation information
    ObjectInputStream oin = null;
    try {
      FileInputStream fin =
          new FileInputStream(
              new File(
                  installData.getInstallPath()
                      + File.separator
                      + InstallData.INSTALLATION_INFORMATION));
      oin = new ObjectInputStream(fin);
      List<Pack> packsinstalled = (List<Pack>) oin.readObject();
      for (Pack installedpack : packsinstalled) {
        installedpacks.put(installedpack.getName(), installedpack);
      }
      this.removeAlreadyInstalledPacks(installData.getSelectedPacks());
      logger.fine("Found " + packsinstalled.size() + " installed packs");

      Properties variables = (Properties) oin.readObject();

      for (Object key : variables.keySet()) {
        installData.setVariable((String) key, (String) variables.get(key));
      }
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } finally {
      if (oin != null) {
        try {
          oin.close();
        } catch (IOException e) {
        }
      }
    }
    return installedpacks;
  }