use of java.nio.file.Path in project druid by druid-io.
the class CompressionUtilsTest method testGoodZipStream.
@Test
public void testGoodZipStream() throws IOException {
final File tmpDir = temporaryFolder.newFolder("testGoodZipStream");
final File zipFile = new File(tmpDir, "compressionUtilTest.zip");
CompressionUtils.zip(testDir, new FileOutputStream(zipFile));
final File newDir = new File(tmpDir, "newDir");
newDir.mkdir();
CompressionUtils.unzip(new FileInputStream(zipFile), newDir);
final Path newPath = Paths.get(newDir.getAbsolutePath(), testFile.getName());
Assert.assertTrue(newPath.toFile().exists());
try (final FileInputStream inputStream = new FileInputStream(newPath.toFile())) {
assertGoodDataStream(inputStream);
}
}
use of java.nio.file.Path in project druid by druid-io.
the class CompressionUtilsTest method testGoodZipCompressUncompress.
@Test
public void testGoodZipCompressUncompress() throws IOException {
final File tmpDir = temporaryFolder.newFolder("testGoodZipCompressUncompress");
final File zipFile = new File(tmpDir, "compressionUtilTest.zip");
try {
CompressionUtils.zip(testDir, zipFile);
final File newDir = new File(tmpDir, "newDir");
newDir.mkdir();
CompressionUtils.unzip(zipFile, newDir);
final Path newPath = Paths.get(newDir.getAbsolutePath(), testFile.getName());
Assert.assertTrue(newPath.toFile().exists());
try (final FileInputStream inputStream = new FileInputStream(newPath.toFile())) {
assertGoodDataStream(inputStream);
}
} finally {
if (zipFile.exists()) {
zipFile.delete();
}
if (tmpDir.exists()) {
tmpDir.delete();
}
}
}
use of java.nio.file.Path in project che by eclipse.
the class FlywaySchemaInitializerTest method createFile.
private static Path createFile(String filepath, String content) throws URISyntaxException, IOException {
final Path path = targetDir().resolve(Paths.get(filepath));
if (!Files.exists(path.getParent())) {
Files.createDirectories(path.getParent());
}
Files.write(path, content.getBytes(StandardCharsets.UTF_8));
return path;
}
use of java.nio.file.Path in project che by eclipse.
the class ResourcesFinderTest method findsScriptsOnFileSystem.
@Test
public void findsScriptsOnFileSystem() throws Exception {
final List<Path> paths = createFiles("finder-sql-files/1.0/1.sql", "finder-sql-files/1.0/2.sql", "finder-sql-files/2.0/1.sql", "finder-sql-files/2.0/postgresql/1.sql");
cleanAfter.addAll(paths);
final Path finderSqlFiles = paths.get(0).getParent().getParent();
final String fsLocation = "filesystem:" + finderSqlFiles.toAbsolutePath();
flyway.setLocations(fsLocation);
final Set<String> locations = findResources(flyway).get(fsLocation);
assertEquals(locations, newHashSet(finderSqlFiles.resolve("1.0").resolve("1.sql").toString(), finderSqlFiles.resolve("1.0").resolve("2.sql").toString(), finderSqlFiles.resolve("2.0").resolve("1.sql").toString(), finderSqlFiles.resolve("2.0").resolve("postgresql").resolve("1.sql").toString()));
}
use of java.nio.file.Path in project ghostdriver by detro.
the class GetFixtureHttpRequestCallback method call.
@Override
public void call(HttpServletRequest req, HttpServletResponse res) throws IOException {
// Construct path to the file
Path filePath = FileSystems.getDefault().getPath(FIXTURE_PATH, req.getPathInfo());
// If the file exists
if (filePath.toFile().exists()) {
try {
// Set Content Type
res.setContentType(filePathToMimeType(filePath.toString()));
// Read and write to response
Files.copy(filePath, res.getOutputStream());
return;
} catch (NoSuchFileException nsfe) {
LOG.warning(nsfe.getClass().getName());
} catch (IOException ioe) {
LOG.warning(ioe.getClass().getName());
} catch (RuntimeException re) {
LOG.warning(re.getClass().getName());
}
}
LOG.warning("Fixture NOT FOUND: " + filePath);
//< Not Found
res.sendError(404);
}
Aggregations