org.springframework.util.FileSystemUtils Java Examples

The following examples show how to use org.springframework.util.FileSystemUtils. 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: ImageService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 6 votes vote down vote up
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
Example #2
Source File: ImageServiceTests.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 6 votes vote down vote up
@Before
public void setUp() throws IOException {
	operations.dropCollection(Image.class);

	operations.insert(new Image("1",
		"learning-spring-boot-cover.jpg"));
	operations.insert(new Image("2",
		"learning-spring-boot-2nd-edition-cover.jpg"));
	operations.insert(new Image("3",
		"bazinga.png"));

	FileSystemUtils.deleteRecursively(new File(ImageService.UPLOAD_ROOT));

	Files.createDirectory(Paths.get(ImageService.UPLOAD_ROOT));

	FileCopyUtils.copy("Test file",
		new FileWriter(ImageService.UPLOAD_ROOT +
			"/learning-spring-boot-cover.jpg"));

	FileCopyUtils.copy("Test file2",
		new FileWriter(ImageService.UPLOAD_ROOT +
			"/learning-spring-boot-2nd-edition-cover.jpg"));

	FileCopyUtils.copy("Test file3",
		new FileWriter(ImageService.UPLOAD_ROOT + "/bazinga.png"));
}
 
Example #3
Source File: ImageService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 6 votes vote down vote up
/**
 * Pre-load some test images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically
 *         run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
Example #4
Source File: ImageService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 6 votes vote down vote up
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
Example #5
Source File: ImageService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 6 votes vote down vote up
/**
 * Pre-load some test images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically
 *         run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
Example #6
Source File: ImageService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 6 votes vote down vote up
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
Example #7
Source File: ImageService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 6 votes vote down vote up
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
Example #8
Source File: ImageService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 6 votes vote down vote up
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
Example #9
Source File: ImageService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 6 votes vote down vote up
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
Example #10
Source File: ImageService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 6 votes vote down vote up
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
Example #11
Source File: ImageService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 6 votes vote down vote up
/**
 * Pre-load some test images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically
 *         run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
Example #12
Source File: ImageService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 6 votes vote down vote up
/**
 * Pre-load some test images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically
 *         run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
Example #13
Source File: AeroRemoteApiControllerTest.java    From webanno with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
    mvc = MockMvcBuilders
            .webAppContextSetup(context)
            .alwaysDo(print())
            .apply(SecurityMockMvcConfigurers.springSecurity())
            .addFilters(new OpenCasStorageSessionForRequestFilter())
            .build();
    
    if (!initialized) {
        userRepository.create(new User("admin", Role.ROLE_ADMIN));
        initialized = true;
        
        FileSystemUtils.deleteRecursively(new File("target/RemoteApiController2Test"));
    }
}
 
Example #14
Source File: ImageService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 6 votes vote down vote up
/**
 * Pre-load some test images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically
 *         run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
Example #15
Source File: ImageService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 6 votes vote down vote up
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
Example #16
Source File: ImageService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 6 votes vote down vote up
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
Example #17
Source File: DefaultPackageWriter.java    From spring-cloud-skipper with Apache License 2.0 6 votes vote down vote up
@Override
public File write(Package pkg, File targetDirectory) {
	PackageMetadata packageMetadata = pkg.getMetadata();
	File tmpDir = TempFileUtils.createTempDirectory("skipper" + packageMetadata.getName()).toFile();
	File rootPackageDir = new File(tmpDir,
			String.format("%s-%s", packageMetadata.getName(), packageMetadata.getVersion()));
	rootPackageDir.mkdir();
	writePackage(pkg, rootPackageDir);
	if (!pkg.getDependencies().isEmpty()) {
		File packagesDir = new File(rootPackageDir, "packages");
		packagesDir.mkdir();
		for (Package dependencyPkg : pkg.getDependencies()) {
			File packageDir = new File(packagesDir, dependencyPkg.getMetadata().getName());
			packageDir.mkdir();
			writePackage(dependencyPkg, packageDir);
		}
	}
	File targetZipFile = PackageFileUtils.calculatePackageZipFile(pkg.getMetadata(), targetDirectory);
	ZipUtil.pack(rootPackageDir, targetZipFile, true);
	FileSystemUtils.deleteRecursively(tmpDir);
	return targetZipFile;
}
 
Example #18
Source File: ImageService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 6 votes vote down vote up
/**
 * Pre-load some test images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically
 *         run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
Example #19
Source File: FetchingCacheServiceImpl.java    From genie with Apache License 2.0 6 votes vote down vote up
/**
 * Delete a resource version directory after taking appropriate lock.
 *
 * @param resourceVersionDir Directory to be deleted
 * @throws IOException
 */
private void cleanUpResourceVersion(final File resourceVersionDir)
    throws LockException, IOException {
    /*
     * Acquire a lock on the lock file for the resource version being deleted.
     * Delete the entire directory for the resource version
     */
    try (
        CloseableLock lock = fileLockFactory.getLock(
            touchCacheResourceVersionLockFile(resourceVersionDir)
        )
    ) {
        //critical section begin
        lock.lock();

        //Remove the data file. If last download was successful for the resource, only
        //data file would exist
        FileSystemUtils.deleteRecursively(getCacheResourceVersionDataFile(resourceVersionDir));

        //data.tmp file could exist if the last download of the resource failed in the middle
        //and after that a newer version was downloaded. So, delete it too
        FileSystemUtils.deleteRecursively(getCacheResourceVersionDownloadFile(resourceVersionDir));

        //critical section end
    }
}
 
Example #20
Source File: ImageService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 6 votes vote down vote up
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
Example #21
Source File: ImageService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 6 votes vote down vote up
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
Example #22
Source File: ResourcesCopier.java    From spring-cloud-release with Apache License 2.0 6 votes vote down vote up
void copy(List<File> baseDirs, File output) {
	File images = new File(output, "images");
	baseDirs.forEach(input -> {
		try {
			File inputImages = new File(input, "images");
			if (!inputImages.exists()) {
				return;
			}
			Logger.info("Will copy [" + inputImages + "] files to [" + images + "]");
			FileSystemUtils.copyRecursively(inputImages, images);
		}
		catch (IOException e) {
			throw new IllegalStateException(e);
		}
	});
}
 
Example #23
Source File: DefaultGradleInitializrService.java    From gradle-initializr with Apache License 2.0 6 votes vote down vote up
private byte[] createDownloadFile(Function<File, File> action) {
    Path tmpDir = null;

    try {
        tmpDir = createTempDir();

        if (logger.isDebugEnabled()) {
            logger.debug("Generating project in temporary directory " + tmpDir.toFile());
        }

        File download = action.apply(tmpDir.toFile());
        return fileToByteArray(download);
    } catch(Exception e) {
        throw new RuntimeException(e);
    } finally {
        if (tmpDir != null) {
            if (!FileSystemUtils.deleteRecursively(tmpDir.toFile())) {
                logger.warn("Unable to delete temporary directory " + tmpDir.toFile());
            }
        }
    }
}
 
Example #24
Source File: GenerateReleaseTrainDocsTests.java    From spring-cloud-release with Apache License 2.0 6 votes vote down vote up
@Test
void should_generate_adocs_from_templates() {
	File file = new File("target/test-train-docs");
	FileSystemUtils.deleteRecursively(file);
	List<Project> projects = Arrays.asList(new Project("spring-cloud-foo", "1.0.0"),
			new Project("spring-cloud-bar", "2.0.0"),
			new Project("spring-boot", "3.0.0"),
			new Project("spring-cloud", "4.0.0"));
	List<ConfigurationProperty> configurationProperties = Arrays.asList(
			new ConfigurationProperty("first", "firstDefault", "firstDescription"),
			new ConfigurationProperty("second", "secondDefault",
					"secondDescription"));

	File outputFolder = new TemplateGenerator(file).generate(projects,
			configurationProperties);

	BDDAssertions.then(outputFolder).isNotEmptyDirectory();
}
 
Example #25
Source File: GenerateReleaseTrainDocsTests.java    From spring-cloud-release with Apache License 2.0 6 votes vote down vote up
@Test
void should_generate_adocs_from_spring_cloud_sleuth_docs()
		throws URISyntaxException, IOException {
	File generatedAdocs = new File("target/test-train-sleuth-docs");
	FileSystemUtils.deleteRecursively(generatedAdocs);
	File testPom = new File(GenerateReleaseTrainDocsTests.class
			.getResource("/test/sleuth-only.xml").toURI());
	File starterPom = new File(GenerateReleaseTrainDocsTests.class
			.getResource("/test/starter-pom.xml").toURI());
	File unzippedDocs = new File("target/test-unpacked-sleuth-docs/");

	GenerateReleaseTrainDocs.main(testPom.getAbsolutePath(),
			starterPom.getAbsolutePath(), "https://github.com/spring-cloud/",
			unzippedDocs.getAbsolutePath(), generatedAdocs.getAbsolutePath());

	BDDAssertions.then(generatedAdocs).isNotEmptyDirectory();
	BDDAssertions.then(configProps(generatedAdocs)).contains(
			"|spring.sleuth.async.configurer.enabled | true | Enable default AsyncConfigurer.");
}
 
Example #26
Source File: ImageService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 6 votes vote down vote up
/**
 * Pre-load some fake images
 *
 * @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
 */
@Bean
CommandLineRunner setUp() throws IOException {
	return (args) -> {
		FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));

		Files.createDirectory(Paths.get(UPLOAD_ROOT));

		FileCopyUtils.copy("Test file",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-cover.jpg"));

		FileCopyUtils.copy("Test file2",
			new FileWriter(UPLOAD_ROOT +
				"/learning-spring-boot-2nd-edition-cover.jpg"));

		FileCopyUtils.copy("Test file3",
			new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
	};
}
 
Example #27
Source File: HdfsTextWriterTests.java    From spring-cloud-task-app-starters with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
	tmpDir = System.getProperty("java.io.tmpdir") + "/jdbchdfs-task";
	File file = new File(tmpDir);
	if (file.exists()) {
		FileSystemUtils.deleteRecursively(file);
	}
	props = new JdbcHdfsTaskProperties();
	props.setFsUri("file:///");
	props.setDirectory(tmpDir);
	props.setFileName("dataWriterBasicTest");
}
 
Example #28
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 #29
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 #30
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/");
}