Refine search
throw new IllegalArgumentException("Destination '" + destDir + "' is not a directory"); copyDirectory(srcDir, new File(destDir, srcDir.getName()), true);
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); } }
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); } }
@Override public boolean copy(URI srcUri, URI dstUri) throws IOException { File srcFile = new File(decodeURI(srcUri.getRawPath())); File dstFile = new File(decodeURI(dstUri.getRawPath())); if (dstFile.exists()) { FileUtils.deleteQuietly(dstFile); } if (srcFile.isDirectory()) { // Throws Exception on failure FileUtils.copyDirectory(srcFile, dstFile); } else { // Will create parent directories, throws Exception on failure FileUtils.copyFile(srcFile, dstFile); } return true; }
@Override public void hook() throws IOException { //some test cases may require additional metadata entries besides standard test metadata in test_case_data/localmeta for (String overlay : overlayMetadataDirs) { FileUtils.copyDirectory(new File(overlay), new File(LOCALMETA_TEMP_DATA)); } } }
/** * NOTE: original segment should be in V1 format. * TODO: support V3 format */ public RawIndexConverter(@Nonnull File originalIndexDir, @Nonnull File convertedIndexDir, @Nullable String columnsToConvert) throws Exception { FileUtils.copyDirectory(originalIndexDir, convertedIndexDir); IndexLoadingConfig indexLoadingConfig = new IndexLoadingConfig(); indexLoadingConfig.setSegmentVersion(SegmentVersion.v1); indexLoadingConfig.setReadMode(ReadMode.mmap); _originalImmutableSegment = ImmutableSegmentLoader.load(originalIndexDir, indexLoadingConfig); _originalSegmentMetadata = (SegmentMetadataImpl) _originalImmutableSegment.getSegmentMetadata(); _convertedIndexDir = convertedIndexDir; _convertedProperties = new PropertiesConfiguration(new File(_convertedIndexDir, V1Constants.MetadataKeys.METADATA_FILE_NAME)); _columnsToConvert = columnsToConvert; }
@Before public void setUp() throws IOException { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); File snapDir = new File(testData, "invalidsnap"); mySnapDir = ClientBase.createTmpDir(); FileUtils.copyDirectory(snapDir, mySnapDir); }
private static void prepareLocalMavenRepository() throws IOException { FileUtils.copyDirectory(new File(SRC_TEST_RESOURCES_TEST_MVN_CACHE), new File(BUILD_PATH)); unzipRepo(); }
private static void prepareLocalMavenRepository() throws IOException { FileUtils.copyDirectory(new File(SRC_TEST_RESOURCES_TEST_MVN_CACHE), new File(BUILD_PATH)); unzipRepo(); }
@Override public void beforeClass(HiveTestEnvContext ctx) throws Exception { File confFolder = new File(ctx.tmpFolder, "conf"); FileUtils.copyDirectory(new File(DATA_DIR + "/conf/"), confFolder); FileUtils.copyDirectory(new File(DATA_DIR + "/conf/tez"), confFolder); HiveConf.setHiveSiteLocation(new File(confFolder, "hive-site.xml").toURI().toURL()); HiveConf.setHivemetastoreSiteUrl(new File(confFolder, "hivemetastore-site.xml").toURI().toURL()); // FIXME: hiveServer2SiteUrl is not settable? ctx.hiveConf = new HiveConf(IDriver.class); ctx.hiveConf.setBoolVar(ConfVars.HIVE_IN_TEST_IDE, true); }
public SvnTestRepo(TemporaryFolder temporaryFolder, String folderName) throws IOException { super(temporaryFolder); if (isBlank(folderName)) { tempRepo = temporaryFolder.newFolder(); } else { tempRepo = temporaryFolder.newFolder(folderName); } tmpFolders.add(tempRepo); try { copyDirectory(new File(REPO_TEST_DATA_FOLDER), tempRepo); } catch (IOException e) { Assert.fail("Could not copy test repo [" + REPO_TEST_DATA_FOLDER + "] into [" + tempRepo + "] beacuse of " + e.getMessage()); } new File(tempRepo, "/project1/db/transactions").mkdir(); }
@Test public void testCopyDirectoryFiltered() throws Exception { final File grandParentDir = new File(getTestDirectory(), "grandparent"); final File parentDir = new File(grandParentDir, "parent"); final File childDir = new File(parentDir, "child"); createFilesForTestCopyDirectory(grandParentDir, parentDir, childDir); final NameFileFilter filter = new NameFileFilter(new String[]{"parent", "child", "file3.txt"}); final File destDir = new File(getTestDirectory(), "copydest"); FileUtils.copyDirectory(grandParentDir, destDir, filter); final List<File> files = LIST_WALKER.list(destDir); assertEquals(3, files.size()); assertEquals("parent", files.get(0).getName()); assertEquals("child", files.get(1).getName()); assertEquals("file3.txt", files.get(2).getName()); }
@Test public void testCopyDirectoryErrors() throws Exception { try { FileUtils.copyDirectory(null, null); fail(); } catch (final NullPointerException ignore) { FileUtils.copyDirectory(new File("a"), null); fail(); } catch (final NullPointerException ignore) { FileUtils.copyDirectory(null, new File("a")); fail(); } catch (final NullPointerException ignore) { FileUtils.copyDirectory(new File("doesnt-exist"), new File("a")); fail(); } catch (final IOException ignore) { FileUtils.copyDirectory(testFile1, new File("a")); fail(); } catch (final IOException ignore) { FileUtils.copyDirectory(getTestDirectory(), testFile1); fail(); } catch (final IOException ignore) { FileUtils.copyDirectory(getTestDirectory(), getTestDirectory()); fail(); } catch (final IOException ignore) {
private P4TestRepo(int port, String repoPrototype, String user, String password, String clientName, boolean useTickets, TemporaryFolder temporaryFolder, File clientFolder) throws IOException { super(temporaryFolder); this.port = port; this.user = user; this.password = password; this.clientName = clientName; this.useTickets = useTickets; tempRepo = temporaryFolder.newFolder(); this.clientFolder = clientFolder; try { copyDirectory(new File(repoPrototype), tempRepo); } catch (IOException e) { bomb(e); } }
final File subDir = new File(srcDir, "sub"); subDir.mkdir(); final File subFile = new File(subDir, "A.txt"); FileUtils.writeStringToFile(subFile, "HELLO WORLD", "UTF8"); final File destDir = new File(System.getProperty("java.io.tmpdir"), "tmp-FileUtilsTestCase"); FileUtils.deleteDirectory(destDir); destDir.mkdirs(); FileUtils.copyDirectory(srcDir, destDir);
@Before public void setUp() throws Exception { // TODO: reallocf Remove initServiceProvider when ProcessJob fully guiced initServiceProvider(); final File jobTypeDir = this.temp.newFolder(TEST_PLUGIN_DIR); this.testPluginDirPath = jobTypeDir.getCanonicalPath(); final URL resourceUrl = Resources.getResource("plugins/jobtypes"); assertNotNull(resourceUrl); FileUtils.copyDirectory(new File(resourceUrl.toURI()), jobTypeDir); this.manager = new JobTypeManager(this.testPluginDirPath, null, this.getClass().getClassLoader()); }
final File subDir = new File(srcDir, "sub"); subDir.mkdir(); final File subFile = new File(subDir, "A.txt"); FileUtils.writeStringToFile(subFile, "HELLO WORLD", "UTF8"); final File destDir = new File(System.getProperty("java.io.tmpdir"), "tmp-FileUtilsTestCase"); FileUtils.deleteDirectory(destDir); FileUtils.copyDirectory(srcDir, destDir);
@Test public void testCopyDirectoryPreserveDates() throws Exception { final File source = new File(getTestDirectory(), "source"); final File sourceDirectory = new File(source, "directory"); final File sourceFile = new File(sourceDirectory, "hello.txt"); FileUtils.copyDirectory(source, target, false); assertTrue(1000000000000L != target.lastModified()); assertTrue(1000000001000L != targetDirectory.lastModified()); FileUtils.copyDirectory(source, target, true); assertEquals(1000000000000L, target.lastModified()); assertEquals(1000000001000L, targetDirectory.lastModified()); FileUtils.copyDirectory(source, target, true); assertEquals(1000000000000L, target.lastModified()); assertEquals(1000000001000L, targetDirectory.lastModified()); FileUtils.copyDirectory(source, target, true); assertEquals(1000000000000L, target.lastModified()); assertEquals(1000000001000L, targetDirectory.lastModified());
private File copyProject(String path) throws Exception { File projectDir = temp.newFolder(); File originalProjectDir = new File(path); FileUtils.copyDirectory(originalProjectDir, projectDir, FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter(".sonar"))); return projectDir; }
private File copyProject(String path) throws Exception { File projectDir = temp.newFolder(); File originalProjectDir = new File(path); FileUtils.copyDirectory(originalProjectDir, projectDir, FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter(".sonar"))); return projectDir; }