コード例 #1
1
  @Before
  public void setUp() throws Exception {
    String zpath =
        System.getProperty("java.io.tmpdir") + "/ZeppelinTest_" + System.currentTimeMillis();
    zeppelinDir = new File(zpath);
    zeppelinDir.mkdirs();
    new File(zeppelinDir, "conf").mkdirs();

    notebooksDir = Joiner.on(File.separator).join(zpath, "notebook");
    File notebookDir = new File(notebooksDir);
    notebookDir.mkdirs();

    String testNoteDir = Joiner.on(File.separator).join(notebooksDir, TEST_NOTE_ID);
    FileUtils.copyDirectory(
        new File(Joiner.on(File.separator).join("src", "test", "resources", TEST_NOTE_ID)),
        new File(testNoteDir));

    System.setProperty(ConfVars.ZEPPELIN_HOME.getVarName(), zeppelinDir.getAbsolutePath());
    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), notebookDir.getAbsolutePath());
    System.setProperty(
        ConfVars.ZEPPELIN_INTERPRETERS.getVarName(),
        "org.apache.zeppelin.interpreter.mock.MockInterpreter1,org.apache.zeppelin.interpreter.mock.MockInterpreter2");
    System.setProperty(
        ConfVars.ZEPPELIN_NOTEBOOK_STORAGE.getVarName(),
        "org.apache.zeppelin.notebook.repo.GitNotebookRepo");

    MockInterpreter1.register("mock1", "org.apache.zeppelin.interpreter.mock.MockInterpreter1");
    MockInterpreter2.register("mock2", "org.apache.zeppelin.interpreter.mock.MockInterpreter2");

    conf = ZeppelinConfiguration.create();
  }
コード例 #2
0
ファイル: DiagramExporter.java プロジェクト: qreal/qreal-web
  private void copyDefaultFiles(String taskId, String directoryPath, String targetPath)
      throws Exception {
    File taskMetaInfo = new File(String.format("%s/%s/metaInfo.xml", directoryPath, taskId));
    File targetMetaInfo = new File(String.format("%s/metaInfo.xml", targetPath));
    targetMetaInfo.createNewFile();
    FileUtils.copyFile(taskMetaInfo, targetMetaInfo);

    File taskLogicalSubprogramDiagrams =
        new File(
            String.format(
                "%s/%s/%s/SubprogramDiagram",
                directoryPath, taskId, PathConstants.PATH_TO_LOGICAL_PART));
    File taskGraphicalSubprogramDiagrams =
        new File(
            String.format(
                "%s/%s/%s/SubprogramDiagram",
                directoryPath, taskId, PathConstants.PATH_TO_GRAPHICAL_PART));
    if (taskLogicalSubprogramDiagrams.exists() && taskGraphicalSubprogramDiagrams.exists()) {
      File targetLogicalSubprogramDiagrams =
          new File(
              String.format(
                  "%s/%s/SubprogramDiagram", targetPath, PathConstants.PATH_TO_LOGICAL_PART));
      FileUtils.copyDirectory(taskLogicalSubprogramDiagrams, targetLogicalSubprogramDiagrams);

      File targetGraphicalSubprogramDiagrams =
          new File(
              String.format(
                  "%s/%s/SubprogramDiagram", targetPath, PathConstants.PATH_TO_GRAPHICAL_PART));
      FileUtils.copyDirectory(taskGraphicalSubprogramDiagrams, targetGraphicalSubprogramDiagrams);

      copySubprogramNodes(taskId, directoryPath, targetPath);
    }
  }
コード例 #3
0
  protected void open() throws Exception {
    // We expect to be run from the project directory.
    // (Both eclipse and maven run junit tests from there).
    String name = getSelfTestName();

    // Make sure the project directory contains a selftest profile
    // and content for the self test.
    File src = getTestDataDir();
    if (!src.exists()) {
      throw new Exception("No selftest directory for " + name);
    }

    // Create temporary directories for Heritrix to run in.
    File tmpDir = new File(getTmpDir(), "selftest");
    File tmpTestDir = new File(tmpDir, name);

    // If we have an old job lying around from a previous run, delete it.
    File tmpJobs = new File(tmpTestDir, "jobs");
    if (tmpJobs.exists()) {
      FileUtils.deleteDirectory(tmpJobs);
    }

    // Copy the selftest's profile in the project directory to the
    // default profile in the temporary Heritrix directory.
    File tmpDefProfile = new File(tmpJobs, "selftest-job");
    File profileTemplate = new File(src, "profile");
    if (profileTemplate.exists()) {
      org.apache.commons.io.FileUtils.copyDirectory(profileTemplate, tmpDefProfile);
    } else {
      org.archive.util.FileUtils.ensureWriteableDirectory(tmpDefProfile);
    }

    // Start up a Jetty that serves the selftest's content directory.
    startHttpServer();

    // Copy configuration for eg Logging over
    File tmpConfDir = new File(tmpTestDir, "conf");
    org.archive.util.FileUtils.ensureWriteableDirectory(tmpConfDir);
    File srcConf = new File(src.getParentFile(), "conf");
    FileUtils.copyDirectory(srcConf, tmpConfDir);

    String crawlerBeansText =
        FileUtils.readFileToString(new File(srcConf, "selftest-crawler-beans.cxml"));
    crawlerBeansText = changeGlobalConfig(crawlerBeansText);
    File crawlerBeans = new File(tmpDefProfile, "selftest-crawler-beans.cxml");
    FileWriter fw = new FileWriter(crawlerBeans);
    fw.write(crawlerBeansText);
    fw.close();

    startHeritrix(tmpTestDir.getAbsolutePath());

    waitForCrawlFinish();
  }
コード例 #4
0
 /** @throws java.lang.Exception */
 @Override
 @Before
 public void setUp() throws Exception {
   super.setUp();
   FileUtils.copyDirectory(getResourceFile("templates/jboss"), new File(nuxeoHome, "templates"));
   System.setProperty("jboss.home.dir", nuxeoHome.getPath());
 }
コード例 #5
0
  @Test
  public void testReindex() throws Exception {

    this.repositoryPath = new File(nexusWorkDir, "storage/" + this.getTestRepositoryId());
    logger.info("path: " + repositoryPath);
    File oldSnapshot = getTestFile("repo");

    // Copy artifact to avoid indexing
    FileUtils.copyDirectory(oldSnapshot, repositoryPath);

    // try to seach and fail
    List<NexusArtifact> search = getSearchMessageUtil().searchFor("nexus641");
    Assert.assertEquals(search.size(), 1, "The artifact was already indexed");

    // reindex
    ScheduledServicePropertyResource prop = new ScheduledServicePropertyResource();
    prop.setKey("repositoryId");
    prop.setValue(this.getTestRepositoryId());

    // reindex
    TaskScheduleUtil.runTask(UpdateIndexTaskDescriptor.ID, prop);

    // try to download again and success
    search = getSearchMessageUtil().searchFor("nexus641");
    Assert.assertEquals(search.size(), 2, "The artifact should be indexed");
  }
コード例 #6
0
ファイル: IO.java プロジェクト: sbryant1014/flashcard-app
  /**
   * @param srcFilename
   * @param dstFilename
   */
  public static void copyOrDie(String srcFilename, String dstFilename) {
    File src = new File(srcFilename);
    File dst = new File(dstFilename);

    System.out.printf("Copy or die: %s, %s\n", srcFilename, dstFilename);
    if (!src.exists()) {
      return;
    }

    // Ensure target file is non-existent.
    deleteOrDie(dstFilename);

    // Copy file.
    try {
      if (src.isDirectory()) {
        org.apache.commons.io.FileUtils.copyDirectory(src, dst);
      } else {
        Files.copy(src.toPath(), dst.toPath());
      }
    } catch (IOException ex) {
      throw new FatalError(
          "copyOrDie failed for '" + srcFilename + "' -> '" + dstFilename + "'", ex);
    }

    // Check if target exists.
    existsOrDie(dst);
  }
コード例 #7
0
 public static void copyDirectory(File srcDir, File destDir, FileFilter filter) {
   try {
     FileUtils.copyDirectory(srcDir, destDir, filter);
   } catch (IOException e) {
     throw new UncheckedIOException(e);
   }
 }
コード例 #8
0
ファイル: IPAT_FX.java プロジェクト: UWE-AI-GROUP/IPATFX
  @Override
  public void start(Stage stage) throws Exception {
    String contextPath = System.getProperty("user.dir") + "/web/";
    File logFile = new File(contextPath + "/log/log4j-IPAT.log");
    System.setProperty("rootPath", logFile.getAbsolutePath());

    Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();
    stage.setOnHiding(
        (WindowEvent event) -> {
          Platform.runLater(
              () -> {
                File src = new File(contextPath + "/Client Data");
                DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
                Date date = new Date();
                File dest = new File(contextPath + "/Saves/Ipat_" + dateFormat.format(date));
                if (!dest.exists()) {
                  dest.mkdirs();
                }
                try {
                  FileUtils.copyDirectory(src, dest);
                } catch (IOException ex) {
                  Logger.getLogger(IPAT_FX.class.getName()).log(Level.SEVERE, null, ex);
                }
                System.exit(0);
              });
        });
  }
コード例 #9
0
  @Override
  public FileSystemEntryDTO copyDiretory(String fullPath, String newParent, String newName)
      throws FileErrorException {
    File basePath = new File(path);

    File directory = new File(basePath, fullPath);
    ensureLocalRoot(basePath, directory);

    ensureLocalRoot(basePath, directory);

    File baseDir = new File(basePath, newParent);

    ensureLocalRoot(basePath, baseDir);

    File newDir = new File(baseDir, newParent);

    try {
      FileUtils.copyDirectory(directory, newDir);

      FileSystemEntryDTO dto = new FileSystemEntryDTO();

      dto.setFile(false);
      String absolutePath = newDir.getAbsolutePath();
      String tmpPath = absolutePath.substring(path.length(), absolutePath.length());
      dto.setFullPath(tmpPath);
      dto.setName(directory.getName());
      return dto;

    } catch (IOException e) {
      logger.log(Level.SEVERE, "can not copy directory", e);
      throw new FileErrorException(FileError.INVALID_STATE_ERR);
    }
  }
コード例 #10
0
  @Test
  public void testSingleShapefileDefaults() throws Exception {
    // copy the footprints mosaic over
    FileUtils.copyDirectory(footprintsSource, testMosaic);

    assertItalyFootprints();
  }
コード例 #11
0
  /** @throws java.lang.Exception */
  @BeforeClass
  public static void setUpBeforeClass() throws Exception {
    File file =
        new File(
            base
                + File.separatorChar
                + "target"
                + File.separatorChar
                + "test-classes"
                + File.separatorChar
                + "index"
                + File.separatorChar
                + "kmelia1");
    if (file.exists()) {
      FileUtils.forceDelete(file);
    }
    File fileDest = new File(TestDidYouMeanIndexer.originalIndexpath);
    File fileSrc =
        new File(
            base
                + File.separatorChar
                + "src"
                + File.separatorChar
                + "test"
                + File.separatorChar
                + "resources"
                + File.separatorChar
                + "index"
                + File.separatorChar
                + "kmelia1"
                + File.separatorChar
                + "index");

    FileUtils.copyDirectory(fileSrc, fileDest);
  }
コード例 #12
0
 public void buildScenes(String targetPath) {
   ProjectManager projectManager = facade.retrieveProxy(ProjectManager.NAME);
   String srcPath =
       projectManager.getCurrentWorkingPath()
           + "/"
           + projectManager.currentProjectVO.projectName
           + "/scenes";
   FileHandle scenesDirectoryHandle = Gdx.files.absolute(srcPath);
   File fileTarget = new File(targetPath + "/" + scenesDirectoryHandle.name());
   try {
     FileUtils.copyDirectory(scenesDirectoryHandle.file(), fileTarget);
   } catch (IOException e) {
     e.printStackTrace();
   }
   // copy project dt
   try {
     FileUtils.copyFile(
         new File(
             projectManager.getCurrentWorkingPath()
                 + "/"
                 + projectManager.currentProjectVO.projectName
                 + "/project.dt"),
         new File(targetPath + "/project.dt"));
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
コード例 #13
0
ファイル: SchemaTest.java プロジェクト: apache/lucene-solr
  @Before
  public void init() throws Exception {
    File tmpSolrHome = createTempDir().toFile();
    FileUtils.copyDirectory(
        new File(getFile("solrj/solr/collection1").getParent()), tmpSolrHome.getAbsoluteFile());

    final SortedMap<ServletHolder, String> extraServlets = new TreeMap<>();
    final ServletHolder solrRestApi = new ServletHolder("SolrSchemaRestApi", ServerServlet.class);
    solrRestApi.setInitParameter(
        "org.restlet.application", "org.apache.solr.rest.SolrSchemaRestApi");
    extraServlets.put(
        solrRestApi,
        "/schema/*"); // '/schema/*' matches '/schema', '/schema/', and '/schema/whatever...'

    System.setProperty("managed.schema.mutable", "true");
    System.setProperty("enable.update.log", "false");

    createJettyAndHarness(
        tmpSolrHome.getAbsolutePath(),
        "solrconfig-managed-schema.xml",
        "schema.xml",
        "/solr",
        true,
        extraServlets);
  }
コード例 #14
0
ファイル: Packager.java プロジェクト: aigamo/cloudify
 private static File createCopyDirectory(final File applicationDir) throws IOException {
   final File destApplicationFolder = File.createTempFile("gs_application_", "");
   FileUtils.forceDelete(destApplicationFolder);
   FileUtils.forceMkdir(destApplicationFolder);
   FileUtils.copyDirectory(applicationDir, destApplicationFolder, SVNFileFilter.getFilter());
   return destApplicationFolder;
 }
コード例 #15
0
ファイル: ResourceCopier.java プロジェクト: MIND-Tools/mindoc
  public static void copyResources(final File sourceDirectories[], final File targetDirectory) {
    // copy js, css and html resources
    final File htmlResourceDirectory = new File(Launcher.getMindRoot(), HTML_RESOURCES_DIR);

    if (!htmlResourceDirectory.canRead()) {
      logger.severe("Cannot read resource directory: " + htmlResourceDirectory.getPath());
      System.exit(1);
    }

    final FileFilter ff =
        new FileFilter() {
          public boolean accept(final File file) {
            return file.getName().endsWith(".css")
                || file.getName().endsWith(".html")
                || file.getName().endsWith(".js")
                || file.isDirectory();
          }
        };
    try {
      FileUtils.copyDirectory(htmlResourceDirectory, targetDirectory, ff);
    } catch (final IOException e) {
      logger.severe("Error while copying resources: " + e.getLocalizedMessage());
      System.exit(1);
    }

    // copy **/doc-files/*
    try {
      for (final File sourceDirectory : sourceDirectories) {
        DocFilesCopier.copy(sourceDirectory, targetDirectory);
      }
    } catch (final IOException e) {
      logger.severe("Error while copying resources: " + e.getLocalizedMessage());
      System.exit(1);
    }
  }
コード例 #16
0
  /**
   * Do actual dependency copying and update project's copy dependency path.
   *
   * @throws IOException
   */
  private boolean copyDependencies() throws IOException {
    boolean result = true;
    projectCopy.setResourceRoot("${projectDir}");
    List<ExternalDependency> dependencies = projectCopy.getExternalDependencies();
    for (ExternalDependency dependency : dependencies) {
      switch (dependency.getType()) {
        case FILE:
          File originalDependency = new File(dependency.getPath());
          if (originalDependency.exists()) {
            File targetDependency = new File(tmpDir, originalDependency.getName());
            FileUtils.copyFile(originalDependency, targetDependency);
            dependency.updatePath(targetDependency.getPath());
          } else {
            SoapUI.log.warn(
                "Do not exists on local file system [" + originalDependency.getPath() + "]");
          }
          break;
        case FOLDER:
          originalDependency = new File(dependency.getPath());
          File targetDependency = new File(tmpDir, originalDependency.getName());
          targetDependency.mkdir();
          FileUtils.copyDirectory(originalDependency, targetDependency, false);
          dependency.updatePath(targetDependency.getPath());
          break;
        default:
          break;
      }
    }

    return result;
  }
コード例 #17
0
  @BeforeClass
  public static void beforeTests() throws Exception {
    File testHome = createTempDir().toFile();
    FileUtils.copyDirectory(getFile("analysis-extras/solr"), testHome);
    initCore("solrconfig-icucollate.xml", "schema-folding-extra.xml", testHome.getAbsolutePath());

    int idx = 1;
    // ICUFoldingFilterFactory
    assertU(adoc("id", Integer.toString(idx++), "content_icufolding", "BadMagicICUFolding"));
    assertU(adoc("id", Integer.toString(idx++), "content_icufolding", "Ruß"));
    assertU(adoc("id", Integer.toString(idx++), "content_icufolding", "ΜΆΪΟΣ"));
    assertU(adoc("id", Integer.toString(idx++), "content_icufolding", "Μάϊος"));
    assertU(adoc("id", Integer.toString(idx++), "content_icufolding", "résumé"));
    assertU(adoc("id", Integer.toString(idx++), "content_icufolding", "re\u0301sume\u0301"));
    assertU(adoc("id", Integer.toString(idx++), "content_icufolding", "ELİF"));
    assertU(adoc("id", Integer.toString(idx++), "content_icufolding", "eli\u0307f"));

    // ICUNormalizer2FilterFactory

    assertU(adoc("id", Integer.toString(idx++), "content_icunormalizer2", "BadMagicICUFolding"));
    assertU(adoc("id", Integer.toString(idx++), "content_icunormalizer2", "Ruß"));
    assertU(adoc("id", Integer.toString(idx++), "content_icunormalizer2", "ΜΆΪΟΣ"));
    assertU(adoc("id", Integer.toString(idx++), "content_icunormalizer2", "Μάϊος"));
    assertU(adoc("id", Integer.toString(idx++), "content_icunormalizer2", "résumé"));
    assertU(adoc("id", Integer.toString(idx++), "content_icunormalizer2", "re\u0301sume\u0301"));
    assertU(adoc("id", Integer.toString(idx++), "content_icunormalizer2", "ELİF"));
    assertU(adoc("id", Integer.toString(idx++), "content_icunormalizer2", "eli\u0307f"));

    // ICUTransformFilterFactory
    assertU(adoc("id", Integer.toString(idx++), "content_icutransform", "Российская"));

    assertU(commit());
  }
コード例 #18
0
 public static void copyDirectory(File srcDir, File destDir, boolean preserveFileDate) {
   try {
     FileUtils.copyDirectory(srcDir, destDir, preserveFileDate);
   } catch (IOException e) {
     throw new UncheckedIOException(e);
   }
 }
コード例 #19
0
  /**
   * DOCUMENT ME!
   *
   * @throws MojoExecutionException DOCUMENT ME!
   */
  public void execute() throws MojoExecutionException {
    MavenLogWrapper.setLog(getLog());

    LogFactory.getFactory()
        .setAttribute(
            "org.apache.commons.logging.Log", "net.sourceforge.floggy.maven.MavenLogWrapper");

    Weaver weaver = new Weaver();

    try {
      List list = project.getCompileClasspathElements();
      File temp =
          new File(project.getBuild().getDirectory(), String.valueOf(System.currentTimeMillis()));
      FileUtils.forceMkdir(temp);
      weaver.setOutputFile(temp);
      weaver.setInputFile(input);
      weaver.setClasspath((String[]) list.toArray(new String[list.size()]));

      if (configurationFile == null) {
        Configuration configuration = new Configuration();
        configuration.setAddDefaultConstructor(addDefaultConstructor);
        configuration.setGenerateSource(generateSource);
        weaver.setConfiguration(configuration);
      } else {
        weaver.setConfigurationFile(configurationFile);
      }

      weaver.execute();
      FileUtils.copyDirectory(temp, output);
      FileUtils.forceDelete(temp);
    } catch (Exception e) {
      throw new MojoExecutionException(e.getMessage(), e);
    }
  }
コード例 #20
0
 @Test
 public void testInsetsBorder() throws Exception {
   // copy the footprints mosaic over
   FileUtils.copyDirectory(footprintsSource, testMosaic);
   Properties p = new Properties();
   p.put(MultiLevelROIProviderFactory.INSET_PROPERTY, "0.1");
   saveFootprintProperties(p);
   GridCoverage2D coverage = readCoverage();
   // check the footprints have been applied by pocking the output image
   byte[] pixel = new byte[3];
   // Close to San Marino, black if we have the insets
   coverage.evaluate(new DirectPosition2D(12.54, 44.03), pixel);
   assertEquals(0, pixel[0]);
   assertEquals(0, pixel[1]);
   assertEquals(0, pixel[2]);
   // Golfo di La Spezia, should be black
   coverage.evaluate(new DirectPosition2D(9.12, 44.25), pixel);
   assertEquals(0, pixel[0]);
   assertEquals(0, pixel[1]);
   assertEquals(0, pixel[2]);
   // Sardinia, not black
   coverage.evaluate(new DirectPosition2D(9, 40), pixel);
   assertTrue(pixel[0] + pixel[1] + pixel[2] > 0);
   // Piedmont, not black
   coverage.evaluate(new DirectPosition2D(8, 45), pixel);
   assertTrue(pixel[0] + pixel[1] + pixel[2] > 0);
   disposeCoverage(coverage);
 }
コード例 #21
0
ファイル: BaseTestEJB.java プロジェクト: yano2h/TESIS
 private static File prepareModuleDirectory() throws IOException {
   File result = new File(TARGET_DIR);
   FileUtils.copyDirectory(new File(TARGET_BUILD), result);
   FileUtils.copyFile(
       new File(PATH_RESOURCES_TEST + "test-persistence.xml"),
       new File(TARGET_DIR + "/META-INF/persistence.xml"));
   return result;
 }
コード例 #22
0
ファイル: MediaMoverIT.java プロジェクト: Ib01/MediaBeaver
  private void refreshTestDirs() {
    try {
      /*recreate destination dir*/
      FileUtils.deleteDirectory(new File("D:\\MediabeaverTests\\Destination"));
      FileUtils.copyDirectory(
          new File("D:\\MediabeaverTests\\Destination - Copy"),
          new File("D:\\MediabeaverTests\\Destination"));

      /*recreate source dir*/
      FileUtils.copyDirectory(
          new File("D:\\MediabeaverTests\\Source - Copy"),
          new File("D:\\MediabeaverTests\\Source"));

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
コード例 #23
0
 private static void copyFile(File outputDirectory, URL resourceDir) throws IOException {
   File dockerFileDir;
   try {
     dockerFileDir = new File(resourceDir.toURI());
   } catch (URISyntaxException e) {
     dockerFileDir = new File(resourceDir.getPath());
   }
   FileUtils.copyDirectory(dockerFileDir, outputDirectory);
 }
コード例 #24
0
  @Override
  public void execute() throws BuildException {
    checkMandatoryParameter("sourceDirectory", sourceDirectory);
    checkMandatoryParameter("outputDirectory", outputDirectory);

    ensureOutputExists();

    Asciidoctor asciidoctor = Asciidoctor.Factory.create(getClass().getClassLoader());

    AttributesBuilder attributesBuilder = buildAttributes();
    OptionsBuilder optionsBuilder = buildOptions();
    optionsBuilder.attributes(attributesBuilder.get());

    if (sourceDocumentName == null) {
      log(
          "Render asciidoc files from "
              + sourceDirectory
              + " to "
              + outputDirectory
              + " with backend="
              + backend);
      for (File file : scanSourceFiles()) {
        setDestinationPaths(optionsBuilder, file);
        asciidoctor.renderFile(file, optionsBuilder.get());
      }
    } else {
      log(
          "Render "
              + sourceDocumentName
              + " from "
              + sourceDirectory
              + " to "
              + outputDirectory
              + " with backend="
              + backend);
      File file = new File(sourceDirectory, sourceDocumentName);
      setDestinationPaths(optionsBuilder, file);
      asciidoctor.renderFile(file, optionsBuilder.get());
    }

    try {
      for (FileSet resource : resources) {
        File resourceDir = resource.getDir();
        String destPath =
            resourceDir
                .getCanonicalPath()
                .substring(new File(sourceDirectory).getCanonicalPath().length());
        File destResourceDir = new File(outputDirectory, destPath);
        destResourceDir.mkdirs();
        String[] includedFiles = resource.getDirectoryScanner(getProject()).getIncludedFiles();
        FileUtils.copyDirectory(
            resourceDir, destResourceDir, new ResourceFileFilter(includedFiles), false);
      }
    } catch (IOException e) {
      throw new BuildException("Error copying resources", e);
    }
  }
コード例 #25
0
ファイル: _.java プロジェクト: GoWarp/pysonar2
 public static void copyResourcesRecursively(URL originUrl, File destination) throws Exception {
     URLConnection urlConnection = originUrl.openConnection();
     if (urlConnection instanceof JarURLConnection) {
         copyJarResourcesRecursively(destination, (JarURLConnection) urlConnection);
     } else if (urlConnection instanceof FileURLConnection) {
         FileUtils.copyDirectory(new File(originUrl.getPath()), destination);
     } else {
         die("Unsupported URL type: " + urlConnection);
     }
 }
コード例 #26
0
  @Before
  public void setUpProject() throws IOException {
    orchestrator.resetData();
    orchestrator
        .getServer()
        .restoreProfile(FileLocation.ofClasspath("/duplication/xoo-duplication-profile.xml"));

    FileUtils.copyDirectory(ItUtils.projectDir(PROJECT_DIR), temp.getRoot());
    projectDir = temp.getRoot();
  }
コード例 #27
0
 private File copyProject(String path) throws Exception {
   File projectDir = temp.newFolder();
   File originalProjectDir =
       new File(IssueModeAndReportsMediumTest.class.getResource(path).toURI());
   FileUtils.copyDirectory(
       originalProjectDir,
       projectDir,
       FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter(".sonar")));
   return projectDir;
 }
コード例 #28
0
ファイル: TestCacheProvider.java プロジェクト: rnc/galley
 @Override
 public void copy(final ConcreteResource from, final ConcreteResource to) throws IOException {
   final File ff = getDetachedFile(from);
   final File tf = getDetachedFile(to);
   if (ff.isDirectory()) {
     FileUtils.copyDirectory(ff, tf);
   } else {
     FileUtils.copyFile(ff, tf);
   }
 }
コード例 #29
0
ファイル: ImportWorker.java プロジェクト: zakkaery/magarena
 /**
  * Merges "avatars" folder and sub-folders. If file already exists then imported version takes
  * precedence.
  */
 private void importAvatars() throws IOException {
   setProgressNote(UiString.get(_S6));
   final String directoryName = "avatars";
   final Path sourcePath = importDataPath.resolve(directoryName);
   if (sourcePath.toFile().exists()) {
     final Path targetPath = MagicFileSystem.getDataPath().resolve(directoryName);
     FileUtils.copyDirectory(sourcePath.toFile(), targetPath.toFile());
   }
   setProgressNote(OK_STRING);
 }
  @Test
  public void visit_existingTileSet() throws Exception {
    File sourceDir = new File(getClass().getResource("/geo-image").getFile());
    File destDir = new File(tmp, "geo-image");
    FileUtils.deleteQuietly(destDir);
    Thread.sleep(50);
    FileUtils.copyDirectory(sourceDir, destDir);
    Thread.sleep(50);

    // check copy status before executing code
    assertTrue(new File(destDir, "Source_Type_20141106.r01c01.jpg").exists());
    assertTrue(new File(destDir, "Source_Type_20141107.r01c01.jpg").exists());
    assertTrue(new File(destDir, "Source_Type_20141108.r01c02.jpg").exists());

    EmbryoLogService logService = Mockito.mock(EmbryoLogService.class);
    TileSetDao tileSetDao = Mockito.mock(TileSetDao.class);
    DateTime limit = DateTime.parse("2014-11-07T00:00:00-00:00");

    List<TileSet> inDatabase = new ArrayList<>();
    inDatabase.add(
        new TileSet(
            "Source_Type_20141107-r01c01",
            "Source",
            "Type",
            DateTime.parse("2014-11-07T00:00:00-00:00")));
    inDatabase.add(
        new TileSet(
            "Source_Type_20141107-r01c02",
            "Source",
            "Type",
            DateTime.parse("2014-11-07T00:00:00-00:00")));
    Mockito.when(tileSetDao.listByProviderAndType("Provider", "Source-Type"))
        .thenReturn(inDatabase);

    SaveNewImagesAsTileSetsVisitor visitor =
        new SaveNewImagesAsTileSetsVisitor(limit, tileSetDao, logService);

    // Execute
    visitor.visit(new Provider("Provider", "*****@*****.**"));
    visitor.visit(new Type("Source-Type", destDir.getAbsolutePath()));

    assertEquals(0, visitor.getResult().deleted);
    assertEquals(0, visitor.getResult().errorCount);
    assertEquals(0, visitor.getResult().jobsStarted);

    ArgumentCaptor<TileSet> captor = ArgumentCaptor.forClass(TileSet.class);
    verify(tileSetDao, times(1)).saveEntity(captor.capture());
    TileSet expected =
        tileSet(
            "Source_Type_20141108-r01c02",
            TileSet.Status.UNCONVERTED,
            DateTime.parse("2014-11-08T00:00:00-00:00"));

    ReflectionAssert.assertLenientEquals(expected, captor.getValue());
  }