Java Code Examples for org.springframework.util.FileSystemUtils#copyRecursively()

The following examples show how to use org.springframework.util.FileSystemUtils#copyRecursively() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VersionsFromBomFetcherTests.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@BeforeEach
void setup() throws IOException, URISyntaxException {
	this.temporaryFolder = Files.createTempDirectory("versions-fetcher").toFile();
	this.temporaryFolder.mkdirs();
	File projects = new File(this.temporaryFolder, "projects");
	projects.mkdirs();
	TestUtils.prepareLocalRepo();
	FileSystemUtils.copyRecursively(localFile("/projects"), projects);
}
 
Example 2
Source File: ArtifactFetcher.java    From spring-cloud-release with Apache License 2.0 5 votes vote down vote up
private void moveOneFolderUp(File unpackedDoc, String subfolder) {
	File onlySubfolder = new File(unpackedDoc, subfolder);
	try {
		FileSystemUtils.copyRecursively(onlySubfolder, unpackedDoc);
	}
	catch (IOException e) {
		throw new IllegalStateException(e);
	}
	FileSystemUtils.deleteRecursively(onlySubfolder);
}
 
Example 3
Source File: ConfigServerTestUtils.java    From spring-cloud-config with Apache License 2.0 5 votes vote down vote up
public static String prepareLocalSvnRepo(String sourceDir, String checkoutDir)
		throws Exception {
	File sourceDirFile = new File(sourceDir);
	sourceDirFile.mkdirs();
	File local = new File(checkoutDir);
	if (local.exists()) {
		FileUtils.delete(local, FileUtils.RECURSIVE);
	}
	local.mkdirs();
	FileSystemUtils.copyRecursively(sourceDirFile, local);
	return StringUtils.cleanPath("file:///" + local.getAbsolutePath());
}
 
Example 4
Source File: ConfigServerTestUtils.java    From spring-cloud-config with Apache License 2.0 5 votes vote down vote up
public static String prepareLocalRepo(String baseDir, String buildDir,
		String repoPath, String checkoutDir) throws IOException {
	buildDir = baseDir + buildDir;
	new File(buildDir).mkdirs();
	if (!repoPath.startsWith("/")) {
		repoPath = "/" + repoPath;
	}
	if (!repoPath.endsWith("/")) {
		repoPath = repoPath + "/";
	}
	File source = new File(baseDir + "src/test/resources" + repoPath);
	File dest = new File(buildDir + repoPath);
	if (dest.exists()) {
		FileUtils.delete(dest, FileUtils.RECURSIVE | FileUtils.RETRY);
	}
	FileSystemUtils.copyRecursively(source, dest);
	File dotGit = new File(buildDir + repoPath + ".git");
	File git = new File(buildDir + repoPath + "git");
	if (git.exists()) {
		if (dotGit.exists()) {
			FileUtils.delete(dotGit, FileUtils.RECURSIVE);
		}
	}
	git.renameTo(dotGit);
	File local = new File(checkoutDir);
	if (local.exists()) {
		FileUtils.delete(local, FileUtils.RECURSIVE);
	}
	if (!buildDir.startsWith("/")) {
		buildDir = "./" + buildDir;
	}
	return "file:" + buildDir + repoPath;
}
 
Example 5
Source File: GeneratedTestClassTests.java    From spring-cloud-contract with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws IOException, URISyntaxException {
	this.file = this.tmpFolder.newFile();
	Files.write(this.file.toPath(), this.contract.getBytes());
	this.tmp = this.tmpFolder.newFolder();
	File classpath = new File(
			GeneratedTestClassTests.class.getResource("/classpath/").toURI());
	FileSystemUtils.copyRecursively(classpath, this.tmp);
}
 
Example 6
Source File: SpringBatchApplicationTests.java    From spring-batch with MIT License 5 votes vote down vote up
@BeforeClass
public static void copyFiles()
    throws URISyntaxException, IOException {
  csvFilesPath = Paths.get(new ClassPathResource("csv").getURI());
  testInputsPath = Paths.get("target/test-inputs");
  try {
    Files.createDirectory(testInputsPath);
  } catch (Exception e) {
    // if directory exists do nothing
  }

  FileSystemUtils.copyRecursively(csvFilesPath, testInputsPath);
}
 
Example 7
Source File: ReleaseTrainContentsUpdaterTests.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
	this.temporaryFolder = this.tmp.newFolder();
	TestUtils.prepareLocalRepo();
	FileSystemUtils.copyRecursively(file("/projects"), this.temporaryFolder);
	this.springCloudRepo = new File(this.temporaryFolder, "spring-cloud/");
	this.wikiRepo = new File(this.temporaryFolder, "spring-cloud-wiki/");
}
 
Example 8
Source File: ProjectCommandExecutorTests.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Before
public void checkOs() throws Exception {
	Assume.assumeFalse(System.getProperty("os.name").toLowerCase().startsWith("win"));
	this.temporaryFolder = this.tmp.newFolder();
	TestUtils.prepareLocalRepo();
	FileSystemUtils.copyRecursively(file("/projects"), this.temporaryFolder);
}
 
Example 9
Source File: SpringCloudMavenBomParserTests.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws URISyntaxException, IOException, GitAPIException {
	this.tmpFolder = this.tmp.newFolder();
	TestUtils.prepareLocalRepo();
	FileSystemUtils.copyRecursively(file("/projects"), this.tmpFolder);
	this.springCloudReleaseProject = new File(this.tmpFolder,
			"/spring-cloud-release");
}
 
Example 10
Source File: AbstractSpringCloudAcceptanceTests.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Before
public void setupCloud() throws Exception {
	this.temporaryFolder = this.tmp.newFolder();
	this.springCloudConsulProject = new File(AbstractSpringAcceptanceTests.class
			.getResource("/projects/spring-cloud-consul").toURI());
	this.springCloudBuildProject = new File(AbstractSpringAcceptanceTests.class
			.getResource("/projects/spring-cloud-build").toURI());
	TestUtils.prepareLocalRepo();
	FileSystemUtils.copyRecursively(file("/projects/"), this.temporaryFolder);
}
 
Example 11
Source File: SpringCloudCustomProjectDocumentationUpdaterTests.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws IOException, URISyntaxException {
	this.tmpFolder = this.tmp.newFolder();
	this.project = new File(SpringCloudCustomProjectDocumentationUpdater.class
			.getResource("/projects/spring-cloud-static").toURI());
	TestUtils.prepareLocalRepo();
	FileSystemUtils.copyRecursively(file("/projects"), this.tmpFolder);
	this.properties.getGit().setDocumentationUrl(
			file("/projects/spring-cloud-static/").toURI().toString());
	this.handler = new ProjectGitHandler(this.properties);
	this.clonedDocProject = this.handler.cloneDocumentationProject();
	this.gitHubHandler = new ProjectGitHubHandler(this.properties,
			Collections.singletonList(
					SpringCloudGithubIssuesAccessor.springCloud(this.properties)));
}
 
Example 12
Source File: AbstractSpringAcceptanceTests.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
	this.temporaryFolder = this.tmp.newFolder();
	TestUtils.prepareLocalRepo();
	FileSystemUtils.copyRecursively(file("/projects/"), this.temporaryFolder);
	clean();
}
 
Example 13
Source File: GradleUpdaterTests.java    From spring-cloud-release-tools with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() throws Exception {
	this.temporaryFolder = this.tmp.newFolder();
	FileSystemUtils.copyRecursively(file("/projects/"), this.temporaryFolder);
}
 
Example 14
Source File: PomUpdateAcceptanceTests.java    From spring-cloud-release-tools with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() throws Exception {
	this.temporaryFolder = this.tmp.newFolder();
	TestUtils.prepareLocalRepo();
	FileSystemUtils.copyRecursively(file("/projects/"), this.temporaryFolder);
}
 
Example 15
Source File: PostReleaseActionsTests.java    From spring-cloud-release-tools with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() throws Exception {
	this.temporaryFolder = this.tmp.newFolder();
	TestUtils.prepareLocalRepo();
	FileSystemUtils.copyRecursively(file("/projects/"), this.temporaryFolder);
}
 
Example 16
Source File: PomUpdaterTests.java    From spring-cloud-release-tools with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() throws Exception {
	this.temporaryFolder = this.tmp.newFolder();
	FileSystemUtils.copyRecursively(file("/projects/"), this.temporaryFolder);
}
 
Example 17
Source File: GitStubDownloaderTests.java    From spring-cloud-contract with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() throws Exception {
	this.temporaryFolder = this.tmp.newFolder();
	TestUtils.prepareLocalRepo();
	FileSystemUtils.copyRecursively(file("/git_samples/"), this.temporaryFolder);
}
 
Example 18
Source File: AbstractMojoTest.java    From spring-cloud-contract with Apache License 2.0 4 votes vote down vote up
@Before
public void setupTemp() throws IOException {
	this.tmpFolder = this.tmp.newFolder();
	File projects = new File("src/test/projects");
	FileSystemUtils.copyRecursively(projects, this.tmpFolder);
}
 
Example 19
Source File: ConfigServerTestUtils.java    From spring-cloud-config with Apache License 2.0 4 votes vote down vote up
public static String copyLocalRepo(String path) throws IOException {
	File dest = new File(REPO_PREFIX + path);
	FileSystemUtils.deleteRecursively(dest);
	FileSystemUtils.copyRecursively(new File("target/repos/config-repo"), dest);
	return "file:./target/repos/" + path;
}