List of usage examples for java.nio.file Path resolve
default Path resolve(String other)
From source file:com.github.harti2006.neo4j.StartNeo4jServerMojo.java
private void configureNeo4jServer() throws MojoExecutionException { final Path serverLocation = getServerLocation(); final Path serverPropertiesPath = serverLocation.resolve(Paths.get("conf", "neo4j-server.properties")); final Properties serverProperties = PropertyUtils.loadProperties(serverPropertiesPath.toFile()); serverProperties.setProperty("org.neo4j.server.webserver.port", port); serverProperties.setProperty("org.neo4j.server.webserver.https.enabled", "false"); try {/*from w ww . j a v a 2s . co m*/ serverProperties.store(newBufferedWriter(serverPropertiesPath, TRUNCATE_EXISTING, WRITE), "Generated by Neo4j Server Maven Plugin"); } catch (IOException e) { throw new MojoExecutionException("Could not configure Neo4j server", e); } }
From source file:org.wte4j.examples.showcase.server.hsql.ShowCaseDbInitializerTest.java
@Test public void createDatabaseFilesWithOveride() throws IOException, SQLException { ApplicationContext context = new StaticApplicationContext(); Path directory = Files.createTempDirectory("database"); Path dummyFile = directory.resolve("wte4j-showcase.script"); Files.createFile(dummyFile);//from w w w . j a va2 s .c om try { ShowCaseDbInitializer showCaseDbInitializer = new ShowCaseDbInitializer(context); showCaseDbInitializer.createDateBaseFiles(directory, true); Set<String> fileNamesInDirectory = listFiles(directory); Set<String> expectedFileNames = new HashSet<String>(); expectedFileNames.add("wte4j-showcase.lobs"); expectedFileNames.add("wte4j-showcase.properties"); expectedFileNames.add("wte4j-showcase.script"); assertEquals(expectedFileNames, fileNamesInDirectory); assertTrue(Files.size(dummyFile) > 0); } finally { deleteDirectory(directory); } }
From source file:at.makubi.maven.plugin.avrohugger.AvrohuggerGeneratorTest.java
public void testAvrohuggerGenerator() throws IOException { Path inputDirectory = Paths.get(getBasedir()).resolve("src/test/resources/unit/avrohugger-maven-plugin"); Path schemaDirectory = inputDirectory.resolve("schema"); File expectedRecord = inputDirectory.resolve("expected/Record.scala").toFile(); File actualRecords = outputDirectory.resolve("at/makubi/maven/plugin/model/Record.scala").toFile(); avrohuggerGenerator.generateScalaFiles(schemaDirectory.toFile(), outputDirectory.toString(), new SystemStreamLog(), false); assertTrue("Generated Scala file does not match expected one", FileUtils.contentEquals(expectedRecord, actualRecords)); }
From source file:com.gooddata.util.ZipHelperTest.java
@Test public void shouldZipDir() throws Exception { Path toZipDir = temporaryFolder.resolve("toZip"); toZipDir.toFile().mkdirs();//from ww w . j a va2s . c o m File toZipFile = toZipDir.resolve(SOME_FILE_PATH).toFile(); toZipFile.getParentFile().mkdirs(); toZipFile.createNewFile(); try (ByteArrayOutputStream output = new ByteArrayOutputStream()) { ZipHelper.zip(toZipDir.toFile(), output, true); output.close(); verifyZipContent(output, Paths.get("toZip", "a", "b", SOME_FILE).toString()); } }
From source file:com.gooddata.util.ZipHelperTest.java
@Test public void shouldZipDirWithoutRoot() throws Exception { Path toZipDir = temporaryFolder.resolve("toZip"); toZipDir.toFile().mkdirs();/* www .j a va 2 s . co m*/ File toZipFile = toZipDir.resolve(SOME_FILE_PATH).toFile(); toZipFile.getParentFile().mkdirs(); toZipFile.createNewFile(); try (ByteArrayOutputStream output = new ByteArrayOutputStream()) { ZipHelper.zip(toZipDir.toFile(), output); output.close(); verifyZipContent(output, Paths.get("a", "b", SOME_FILE).toString()); } }
From source file:org.n52.io.request.IoParametersTest.java
private File getAlternativeConfigFile() throws URISyntaxException { Path root = Paths.get(getClass().getResource("/").toURI()); return root.resolve("test-config.json").toFile(); }
From source file:at.makubi.maven.plugin.avrohugger.AvrohuggerGeneratorTest.java
public void testAvrohuggerGeneratorRecursive() throws IOException { Path inputDirectory = Paths.get(getBasedir()).resolve("src/test/resources/unit/avrohugger-maven-plugin"); Path schemaDirectory = inputDirectory.resolve("schema"); File expectedRecord = inputDirectory.resolve("expected/Record.scala").toFile(); File actualRecords = outputDirectory.resolve("at/makubi/maven/plugin/model/Record.scala").toFile(); File expectedSubRecord = inputDirectory.resolve("expected/SubRecord.scala").toFile(); File actualSubRecords = outputDirectory.resolve("at/makubi/maven/plugin/model/submodel/SubRecord.scala") .toFile();/* www .j av a2 s . c o m*/ avrohuggerGenerator.generateScalaFiles(schemaDirectory.toFile(), outputDirectory.toString(), new SystemStreamLog(), true); assertTrue("Generated Scala Record file does not match expected one", FileUtils.contentEquals(expectedRecord, actualRecords)); assertTrue("Generated Scala SubRecord file does not match expected one", FileUtils.contentEquals(expectedSubRecord, actualSubRecords)); }
From source file:de.siegmar.securetransfer.component.Cryptor.java
private byte[] initSalt(final Path baseDir) { final Path saltFile = baseDir.resolve("salt"); try {/* www . j a v a 2 s .c o m*/ if (Files.exists(saltFile)) { return Files.readAllBytes(saltFile); } final byte[] newSalt = newRandom(SALT_SIZE); Files.write(saltFile, newSalt, StandardOpenOption.CREATE_NEW); LOG.info("Initialized instance salt at {}", saltFile); return newSalt; } catch (final IOException e) { throw new UncheckedIOException(e); } }
From source file:uk.ac.ebi.eva.pipeline.jobs.steps.VariantLoaderStep.java
@Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { ObjectMap variantOptions = jobOptions.getVariantOptions(); ObjectMap pipelineOptions = jobOptions.getPipelineOptions(); VariantStorageManager variantStorageManager = StorageManagerFactory.getVariantStorageManager();// TODO add mongo URI outdirUri = URLHelper.createUri(pipelineOptions.getString("output.dir")); URI nextFileUri = URLHelper.createUri(pipelineOptions.getString("input.vcf")); // URI pedigreeUri = pipelineOptions.getString("input.pedigree") != null ? createUri(pipelineOptions.getString("input.pedigree")) : null; Path output = Paths.get(outdirUri.getPath()); Path input = Paths.get(nextFileUri.getPath()); Path outputVariantJsonFile = output.resolve( input.getFileName().toString() + ".variants.json" + pipelineOptions.getString("compressExtension")); // outputFileJsonFile = output.resolve(input.getFileName().toString() + ".file.json" + config.compressExtension); URI transformedVariantsUri = outdirUri.resolve(outputVariantJsonFile.getFileName().toString()); logger.info("-- PreLoad variants -- {}", nextFileUri); variantStorageManager.preLoad(transformedVariantsUri, outdirUri, variantOptions); logger.info("-- Load variants -- {}", nextFileUri); variantStorageManager.load(transformedVariantsUri, variantOptions); // logger.info("-- PostLoad variants -- {}", nextFileUri); // variantStorageManager.postLoad(transformedVariantsUri, outdirUri, variantOptions); return RepeatStatus.FINISHED; }
From source file:com.netflix.spinnaker.clouddriver.artifacts.http.HttpArtifactCredentialsTest.java
@Test void downloadWithBasicAuthFromFile(@TempDirectory.TempDir Path tempDir, @WiremockResolver.Wiremock WireMockServer server) throws IOException { Path authFile = tempDir.resolve("auth-file"); Files.write(authFile, "someuser:somepassw0rd!".getBytes()); HttpArtifactAccount account = new HttpArtifactAccount(); account.setName("my-http-account"); account.setUsernamePasswordFile(authFile.toAbsolutePath().toString()); runTestCase(server, account, m -> m.withBasicAuth("someuser", "somepassw0rd!")); }