@Override
 protected void setUp() throws Exception {
   super.setUp();
   testdir = new File("build/TestDirPluginScanner");
   FileUtils.deleteDir(testdir);
   testdir.mkdirs();
 }
예제 #2
0
 /** Remove any cache dir for the file */
 private synchronized boolean removeScriptPluginCache() {
   final File fileExpandedDir = getFileCacheDir();
   if (null != fileExpandedDir && fileExpandedDir.exists()) {
     debug("removeScriptPluginCache: " + fileExpandedDir);
     return FileUtils.deleteDir(fileExpandedDir);
   }
   return true;
 }
예제 #3
0
 /**
  * Creates a single cached version of the pluginJar located within pluginJarCacheDirectory
  * deleting all existing versions of pluginJar
  *
  * @param jarName
  */
 protected File createCachedJar(final File dir, final String jarName) throws PluginException {
   File cachedJar;
   try {
     cachedJar = new File(dir, jarName);
     cachedJar.deleteOnExit();
     FileUtils.fileCopy(pluginJar, cachedJar, true);
   } catch (IOException e) {
     throw new PluginException(e);
   }
   return cachedJar;
 }
예제 #4
0
  JarPluginScanner(
      final File extdir,
      final File cachedir,
      final FileCache<ProviderLoader> filecache,
      final int rescanInterval) {
    super(extdir, filecache, rescanInterval);
    this.cachedir = cachedir;
    this.pluginJarCacheDirectory =
        new File(Constants.getBaseTempDirectory() + Constants.FILE_SEP + JAR_SCRATCH_DIRECTORY);

    // Clean up old caches on startup.
    log.info(String.format("Deleting plugin jar cache at %s", pluginJarCacheDirectory));
    if (pluginJarCacheDirectory.exists() && !FileUtils.deleteDir(pluginJarCacheDirectory)) {
      log.warn("Could not delete plugin jar cache");
    }
    log.info(String.format("Deleting plugin lib dependency directory at %s", this.cachedir));
    if (this.cachedir.exists() && !FileUtils.deleteDir(this.cachedir)) {
      log.warn("Could not delete plugin lib dependency directory");
    }

    // Create the directories
    this.cachedir.mkdirs();
    this.pluginJarCacheDirectory.mkdirs();
  }
예제 #5
0
  public void setUp() {
    super.setUp();

    final Framework frameworkInstance = getFrameworkInstance();
    final FrameworkProject frameworkProject =
        frameworkInstance.getFrameworkProjectMgr().createFrameworkProject(PROJ_NAME);
    File resourcesfile = new File(frameworkProject.getNodesResourceFilePath());
    // copy test nodes to resources file
    try {
      FileUtils.copyFileStreams(
          new File("src/test/resources/com/dtolabs/rundeck/core/common/test-nodes1.xml"),
          resourcesfile);
    } catch (IOException e) {
      throw new RuntimeException("Caught Setup exception: " + e.getMessage(), e);
    }
  }
예제 #6
0
 /** Expire the loader cache item */
 public void expire() {
   debug("expire jar provider loader for: " + pluginJar);
   removeScriptPluginCache();
   classCache.clear();
   this.cachedJar = null;
   // close loaders
   for (File file : classLoaders.keySet()) {
     try {
       debug("expire classLoaders for: " + file);
       classLoaders.remove(file).close();
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
   // remove cache files
   for (File file : cachedFiles) {
     debug("remove cache dir: " + file);
     FileUtils.deleteDir(file);
   }
 }
예제 #7
0
 public void tearDown() throws Exception {
   super.tearDown();
   File projectdir = new File(getFrameworkProjectsBase(), PROJ_NAME);
   FileUtils.deleteDir(projectdir);
 }
  protected void tearDown() throws Exception {
    super.tearDown();

    File projectdir = new File(getFrameworkProjectsBase(), TEST_PROJECT);
    FileUtils.deleteDir(projectdir);
  }
 @Override
 protected void tearDown() throws Exception {
   super.tearDown();
   FileUtils.deleteDir(testdir);
 }