List of usage examples for java.nio.file Path resolve
default Path resolve(String other)
From source file:com.facebook.buck.jvm.java.JarDirectoryStepTest.java
@Test public void shouldFailIfMainClassMissing() throws IOException { Path zipup = folder.newFolder("zipup"); Path zip = createZip(zipup.resolve("a.zip"), "com/example/Main.class"); JarDirectoryStep step = new JarDirectoryStep(new ProjectFilesystem(zipup), Paths.get("output.jar"), ImmutableSortedSet.of(zip.getFileName()), "com.example.MissingMain", /* manifest file */ null); TestConsole console = new TestConsole(); ExecutionContext context = TestExecutionContext.newBuilder().setConsole(console).build(); int returnCode = step.execute(context).getExitCode(); assertEquals(1, returnCode);// w w w . j a v a 2 s.com assertEquals("ERROR: Main class com.example.MissingMain does not exist.\n", console.getTextWrittenToStdErr()); }
From source file:com.facebook.buck.jvm.java.JarDirectoryStepTest.java
@Test public void shouldNotComplainWhenDuplicateDirectoryNamesAreAdded() throws IOException { Path zipup = folder.newFolder(); Path first = createZip(zipup.resolve("first.zip"), "dir/example.txt", "dir/root1file.txt"); Path second = createZip(zipup.resolve("second.zip"), "dir/example.txt", "dir/root2file.txt", "com/example/Main.class"); JarDirectoryStep step = new JarDirectoryStep(new ProjectFilesystem(zipup), Paths.get("output.jar"), ImmutableSortedSet.of(first.getFileName(), second.getFileName()), "com.example.Main", /* manifest file */ null); ExecutionContext context = TestExecutionContext.newInstance(); int returnCode = step.execute(context).getExitCode(); assertEquals(0, returnCode);/* ww w . ja va 2s.c o m*/ Path zip = zipup.resolve("output.jar"); // The three below plus the manifest and Main.class. assertZipFileCountIs(5, zip); assertZipContains(zip, "dir/example.txt", "dir/root1file.txt", "dir/root2file.txt"); }
From source file:io.syndesis.project.converter.DefaultProjectGeneratorTest.java
@Test public void testConverterWithPasswordMasking() throws Exception { Step step1 = new SimpleStep.Builder().stepKind("endpoint") .connection(new Connection.Builder().id("1").configuredProperties(map()).build()) .configuredProperties(map("period", 5000)) .action(new Action.Builder().connectorId("timer").camelConnectorPrefix("periodic-timer-connector") .camelConnectorGAV("io.syndesis:timer-connector:" + CONNECTORS_VERSION).build()) .build();//from www .ja v a 2s.c om Step step2 = new SimpleStep.Builder().stepKind("endpoint") .connection(new Connection.Builder().id("2").configuredProperties(map()).build()) .configuredProperties(map("httpUri", "http://localhost:8080/hello", "username", "admin", "password", "admin", "token", "mytoken")) .action(new Action.Builder().connectorId("http").camelConnectorPrefix("http-get-connector") .camelConnectorGAV("io.syndesis:http-get-connector:" + CONNECTORS_VERSION).build()) .build(); GenerateProjectRequest request = new GenerateProjectRequest.Builder() .integration(new Integration.Builder().id("test-integration").name("Test Integration") .description("This is a test integration!").steps(Arrays.asList(step1, step2)).build()) .connectors(connectors).build(); ProjectGeneratorProperties generatorProperties = new ProjectGeneratorProperties(mavenProperties); generatorProperties.getTemplates().setOverridePath(this.basePath); generatorProperties.getTemplates().getAdditionalResources().addAll(this.additionalResources); generatorProperties.setSecretMaskingEnabled(true); Path runtimeDir = generate(request, generatorProperties); assertFileContents(generatorProperties, runtimeDir.resolve("src/main/resources/application.properties"), "test-application.properties"); assertFileContents(generatorProperties, runtimeDir.resolve("src/main/resources/syndesis.yml"), "test-syndesis-with-secrets.yml"); }
From source file:com.facebook.buck.jvm.java.JarDirectoryStepTest.java
@Test public void jarsShouldContainDirectoryEntries() throws IOException { Path zipup = folder.newFolder("dir-zip"); Path subdir = zipup.resolve("dir/subdir"); Files.createDirectories(subdir); Files.write(subdir.resolve("a.txt"), "cake".getBytes()); JarDirectoryStep step = new JarDirectoryStep(new ProjectFilesystem(zipup), Paths.get("output.jar"), ImmutableSortedSet.of(zipup), /* main class */ null, /* manifest file */ null); ExecutionContext context = TestExecutionContext.newInstance(); int returnCode = step.execute(context).getExitCode(); assertEquals(0, returnCode);/*from ww w .j a v a2 s .c o m*/ Path zip = zipup.resolve("output.jar"); assertTrue(Files.exists(zip)); // Iterate over each of the entries, expecting to see the directory names as entries. Set<String> expected = Sets.newHashSet("dir/", "dir/subdir/"); try (ZipInputStream is = new ZipInputStream(Files.newInputStream(zip))) { for (ZipEntry entry = is.getNextEntry(); entry != null; entry = is.getNextEntry()) { expected.remove(entry.getName()); } } assertTrue("Didn't see entries for: " + expected, expected.isEmpty()); }
From source file:com.facebook.buck.jvm.java.JarDirectoryStepTest.java
@Test public void shouldNotThrowAnExceptionWhenAddingDuplicateEntries() throws IOException { Path zipup = folder.newFolder("zipup"); Path first = createZip(zipup.resolve("a.zip"), "example.txt"); Path second = createZip(zipup.resolve("b.zip"), "example.txt", "com/example/Main.class"); JarDirectoryStep step = new JarDirectoryStep(new ProjectFilesystem(zipup), Paths.get("output.jar"), ImmutableSortedSet.of(first.getFileName(), second.getFileName()), "com.example.Main", /* manifest file */ null); ExecutionContext context = TestExecutionContext.newInstance(); int returnCode = step.execute(context).getExitCode(); assertEquals(0, returnCode);/*from w w w.ja va 2s. c om*/ Path zip = zipup.resolve("output.jar"); assertTrue(Files.exists(zip)); // "example.txt" "Main.class" and the MANIFEST.MF. assertZipFileCountIs(3, zip); assertZipContains(zip, "example.txt"); }
From source file:io.syndesis.project.converter.DefaultProjectGeneratorTest.java
@Test public void testWithFilter() throws Exception { Step step1 = new SimpleStep.Builder().stepKind("endpoint") .connection(new Connection.Builder().configuredProperties(map()).build()) .configuredProperties(map("period", 5000)) .action(new Action.Builder().connectorId("timer").camelConnectorPrefix("periodic-timer-connector") .camelConnectorGAV("io.syndesis:timer-connector:" + CONNECTORS_VERSION).build()) .build();/*w w w . ja v a 2s . c o m*/ Step step2 = new RuleFilterStep.Builder() .configuredProperties(map("predicate", FilterPredicate.AND.toString(), "rules", "[{ \"path\": \"in.header.counter\", \"op\": \">\", \"value\": \"10\" }]")) .build(); Step step3 = new SimpleStep.Builder().stepKind("endpoint") .connection(new Connection.Builder().configuredProperties(Collections.emptyMap()).build()) .configuredProperties(map("httpUri", "http://localhost:8080/bye")) .action(new Action.Builder().connectorId("http").camelConnectorPrefix("http-post-connector") .camelConnectorGAV("io.syndesis:http-post-connector:" + CONNECTORS_VERSION).build()) .build(); Step step4 = new ExpressionFilterStep.Builder() .configuredProperties(map("filter", "${body.germanSecondLeagueChampion} equals 'FCN'")).build(); GenerateProjectRequest request = new GenerateProjectRequest.Builder() .integration(new Integration.Builder().id("test-integration").name("Test Integration") .steps(Arrays.asList(step1, step2, step3, step4)).build()) .connectors(connectors).build(); ProjectGeneratorProperties generatorProperties = new ProjectGeneratorProperties(mavenProperties); generatorProperties.getTemplates().setOverridePath(this.basePath); generatorProperties.getTemplates().getAdditionalResources().addAll(this.additionalResources); Path runtimeDir = generate(request, generatorProperties); assertFileContents(generatorProperties, runtimeDir.resolve("src/main/resources/syndesis.yml"), "test-filter-syndesis.yml"); }
From source file:io.syndesis.project.converter.DefaultProjectGeneratorTest.java
@Test public void testConvertFromJson() throws Exception { JsonNode json = new ObjectMapper().readTree(this.getClass().getResourceAsStream("test-integration.json")); GenerateProjectRequest request = new GenerateProjectRequest.Builder().integration(new ObjectMapper() .registerModule(new Jdk8Module()).readValue(json.get("data").toString(), Integration.class)) .connectors(connectors).build(); ProjectGeneratorProperties generatorProperties = new ProjectGeneratorProperties(mavenProperties); generatorProperties.getTemplates().setOverridePath(this.basePath); generatorProperties.getTemplates().getAdditionalResources().addAll(this.additionalResources); Path runtimePath = generate(request, generatorProperties); assertFileContents(generatorProperties, runtimePath.resolve("src/main/java/io/syndesis/example/Application.java"), "test-Application.java"); assertFileContents(generatorProperties, runtimePath.resolve("src/main/resources/application.properties"), "test-pull-push-application.properties"); assertFileContents(generatorProperties, runtimePath.resolve("src/main/resources/syndesis.yml"), "test-pull-push-syndesis.yml"); assertFileContents(generatorProperties, runtimePath.resolve("pom.xml"), "test-pull-push-pom.xml"); }
From source file:io.syndesis.project.converter.DefaultProjectGeneratorTest.java
@Test public void testConverterWithPasswordMaskingAndMultipleConnectorOfSameType() throws Exception { Step step1 = new SimpleStep.Builder().stepKind("endpoint") .connection(new Connection.Builder().id("1").configuredProperties(map()).build()) .configuredProperties(map("period", 5000)) .action(new Action.Builder().connectorId("timer").camelConnectorPrefix("periodic-timer-connector") .camelConnectorGAV("io.syndesis:timer-connector:" + CONNECTORS_VERSION).build()) .build();/*from ww w . j av a 2s. co m*/ Step step2 = new SimpleStep.Builder().stepKind("endpoint") .connection(new Connection.Builder().id("2").configuredProperties(map()).build()) .configuredProperties(map("httpUri", "http://localhost:8080/hello", "username", "admin", "password", "admin", "token", "mytoken")) .action(new Action.Builder().connectorId("http").camelConnectorPrefix("http-get-connector") .camelConnectorGAV("io.syndesis:http-get-connector:" + CONNECTORS_VERSION).build()) .build(); Step step3 = new SimpleStep.Builder().stepKind("endpoint") .connection(new Connection.Builder().id("3").configuredProperties(map()).build()) .configuredProperties(map("httpUri", "http://localhost:8080/bye", "username", "admin", "password", "admin", "token", "mytoken")) .action(new Action.Builder().connectorId("http").camelConnectorPrefix("http-get-connector") .camelConnectorGAV("io.syndesis:http-get-connector:" + CONNECTORS_VERSION).build()) .build(); GenerateProjectRequest request = new GenerateProjectRequest.Builder().integration(new Integration.Builder() .id("test-integration").name("Test Integration").description("This is a test integration!") .steps(Arrays.asList(step1, step2, step3)).build()).connectors(connectors).build(); ProjectGeneratorProperties generatorProperties = new ProjectGeneratorProperties(mavenProperties); generatorProperties.getTemplates().setOverridePath(this.basePath); generatorProperties.getTemplates().getAdditionalResources().addAll(this.additionalResources); generatorProperties.setSecretMaskingEnabled(true); Path runtimeDir = generate(request, generatorProperties); assertFileContents(generatorProperties, runtimeDir.resolve("src/main/resources/application.properties"), "test-application.properties"); assertFileContents(generatorProperties, runtimeDir.resolve("src/main/resources/syndesis.yml"), "test-syndesis-with-secrets-and-multiple-connector-of-same-type.yml"); }
From source file:com.gitpitch.services.OfflineService.java
private Path prepareZipRoot(PitchParams pp) { Path zipRoot = diskService.ensure(pp); if (pp.pitchme != null) { zipRoot = zipRoot.resolve(pp.pitchme); }//w w w .j av a2s . com zipRoot = zipRoot.resolve(ZIP_ROOT_DIR); return diskService.ensure(zipRoot); }
From source file:de.topobyte.osm4j.extra.extracts.query.Query.java
private void addCompletelyContainedBatch(Path pathRelations, long id, List<OsmFileInput> filesRelations) { Path path = pathRelations.resolve(Long.toString(id)); filesNodes.add(input(path.resolve(relationNames.getNodes()))); filesWays.add(input(path.resolve(relationNames.getWays()))); filesRelations.add(input(path.resolve(relationNames.getRelations()))); }