use of com.google.cloud.tools.jib.filesystem.DirectoryWalker in project jib by google.
the class MainClassFinderTest method testFindMainClass_noClass.
@Test
public void testFindMainClass_noClass() throws URISyntaxException, IOException {
Path rootDirectory = Paths.get(Resources.getResource("core/class-finder-tests/no-main").toURI());
MainClassFinder.Result mainClassFinderResult = MainClassFinder.find(new DirectoryWalker(rootDirectory).walk(), logEventConsumer);
Assert.assertEquals(Result.Type.MAIN_CLASS_NOT_FOUND, mainClassFinderResult.getType());
}
use of com.google.cloud.tools.jib.filesystem.DirectoryWalker in project jib by GoogleContainerTools.
the class StandardWarExplodedProcessorTest method zipUpDirectory.
private static Path zipUpDirectory(Path sourceRoot, Path targetZip) throws IOException {
try (ZipOutputStream zipOut = new ZipOutputStream(Files.newOutputStream(targetZip))) {
for (Path source : new DirectoryWalker(sourceRoot).filterRoot().walk()) {
StringJoiner pathJoiner = new StringJoiner("/", "", "");
sourceRoot.relativize(source).forEach(element -> pathJoiner.add(element.toString()));
String zipEntryPath = Files.isDirectory(source) ? pathJoiner.toString() + '/' : pathJoiner.toString();
ZipEntry entry = new ZipEntry(zipEntryPath);
zipOut.putNextEntry(entry);
if (!Files.isDirectory(source)) {
try (InputStream in = Files.newInputStream(source)) {
ByteStreams.copy(in, zipOut);
}
}
zipOut.closeEntry();
}
}
return targetZip;
}
use of com.google.cloud.tools.jib.filesystem.DirectoryWalker in project jib by GoogleContainerTools.
the class MainClassFinderTest method testFindMainClass_simple.
@Test
public void testFindMainClass_simple() throws URISyntaxException, IOException {
Path rootDirectory = Paths.get(Resources.getResource("core/class-finder-tests/simple").toURI());
MainClassFinder.Result mainClassFinderResult = MainClassFinder.find(new DirectoryWalker(rootDirectory).walk(), logEventConsumer);
Assert.assertSame(Result.Type.MAIN_CLASS_FOUND, mainClassFinderResult.getType());
MatcherAssert.assertThat(mainClassFinderResult.getFoundMainClass(), CoreMatchers.containsString("HelloWorld"));
}
use of com.google.cloud.tools.jib.filesystem.DirectoryWalker in project jib by GoogleContainerTools.
the class MainClassFinderTest method testFindMainClass_noClass.
@Test
public void testFindMainClass_noClass() throws URISyntaxException, IOException {
Path rootDirectory = Paths.get(Resources.getResource("core/class-finder-tests/no-main").toURI());
MainClassFinder.Result mainClassFinderResult = MainClassFinder.find(new DirectoryWalker(rootDirectory).walk(), logEventConsumer);
Assert.assertEquals(Result.Type.MAIN_CLASS_NOT_FOUND, mainClassFinderResult.getType());
}
use of com.google.cloud.tools.jib.filesystem.DirectoryWalker in project jib by GoogleContainerTools.
the class MainClassFinderTest method testFindMainClass_multiple.
@Test
public void testFindMainClass_multiple() throws URISyntaxException, IOException {
Path rootDirectory = Paths.get(Resources.getResource("core/class-finder-tests/multiple").toURI());
MainClassFinder.Result mainClassFinderResult = MainClassFinder.find(new DirectoryWalker(rootDirectory).walk(), logEventConsumer);
Assert.assertEquals(Result.Type.MULTIPLE_MAIN_CLASSES, mainClassFinderResult.getType());
Assert.assertEquals(2, mainClassFinderResult.getFoundMainClasses().size());
Assert.assertTrue(mainClassFinderResult.getFoundMainClasses().contains("multi.layered.HelloMoon"));
Assert.assertTrue(mainClassFinderResult.getFoundMainClasses().contains("HelloWorld"));
}
Aggregations