/** Removes the lock file (which normally gets removed on exit), to enable multiple installs. */
 private void removeLock() {
   String appName = getInstallData().getInfo().getAppName();
   File file = FileUtil.getLockFile(appName);
   if (file.exists()) {
     assertTrue(file.delete());
   }
 }
Пример #2
0
 /**
  * Verifies that a file exists with the specified content.
  *
  * @param name the file name
  * @param content the expected file content
  * @return the file
  * @throws IOException for any I/O error
  */
 private File checkContains(String name, String content) throws IOException {
   checkExists(name);
   File file = new File(temporaryFolder.getRoot(), name);
   List<String> fileContent = FileUtil.getFileContent(file.getPath());
   assertEquals(1, fileContent.size());
   assertEquals(content, StringUtils.trim(fileContent.get(0)));
   return file;
 }
  /**
   * Sets up the test case.
   *
   * @throws Exception for any error
   */
  @Override
  public void setUp() throws Exception {
    Assume.assumeTrue(
        "This test must be run as administrator, or with Windows UAC turned off",
        !skipTests && isAdminUser);

    super.setUp();
    String appName = getInstallData().getInfo().getAppName();
    assertNotNull(appName);
    File file = FileUtil.getLockFile(appName);
    if (file.exists()) {
      assertTrue(file.delete());
    }

    destroyRegistryEntries();
  }
Пример #4
0
  /** Write the data referenced by URL to primary jar. */
  protected void writeInstallerResources() throws IOException {
    sendMsg("Copying " + installerResourceURLMap.size() + " files into installer");

    for (Map.Entry<String, URL> stringURLEntry : installerResourceURLMap.entrySet()) {
      URL url = stringURLEntry.getValue();
      InputStream in = url.openStream();

      org.apache.tools.zip.ZipEntry newEntry =
          new org.apache.tools.zip.ZipEntry(RESOURCES_PATH + stringURLEntry.getKey());
      long dateTime = FileUtil.getFileDateTime(url);
      if (dateTime != -1) {
        newEntry.setTime(dateTime);
      }
      primaryJarStream.putNextEntry(newEntry);

      IoHelper.copyStream(in, primaryJarStream);
      primaryJarStream.closeEntry();
      in.close();
    }
  }