use of org.eclipse.jkube.kit.common.AssemblyFile in project jkube by eclipse.
the class AssemblyManagerCreateDockerTarArchiveTest method withDockerfileInBaseDirectoryAndAssemblyFile.
@Test
public void withDockerfileInBaseDirectoryAndAssemblyFile() throws IOException {
// Given
final File dockerFile = new File(baseDirectory, "Dockerfile");
writeLineToFile(dockerFile, "FROM busybox");
final File assemblyFile = temporaryFolder.newFile("extra-file-1.txt");
writeLineToFile(assemblyFile, "HELLO");
AssemblyConfiguration assemblyConfig = AssemblyConfiguration.builder().inline(Assembly.builder().file(AssemblyFile.builder().source(assemblyFile).outputDirectory(new File(".")).build()).build()).build();
final JKubeConfiguration configuration = createJKubeConfiguration();
final BuildConfiguration jKubeBuildConfiguration = BuildConfiguration.builder().dockerFileFile(dockerFile).dockerFile(dockerFile.getPath()).assembly(assemblyConfig).build();
// When
final File dockerArchiveFile = assemblyManager.createDockerTarArchive("dockerfile-and-assembly-file", configuration, jKubeBuildConfiguration, prefixedLogger, null);
// Then
assertTargetHasDockerDirectories("dockerfile-and-assembly-file");
ArchiveAssertions.assertThat(dockerArchiveFile).isFile().hasName("docker-build.tar").hasSameContentAsDirectory(getExpectedDirectory("with-dockerfile-in-base-directory-and-assembly-file"));
assertDockerFile("dockerfile-and-assembly-file").hasContent("FROM busybox\n");
assertBuildDirectoryFileTree("dockerfile-and-assembly-file").containsExactlyInAnyOrder("Dockerfile", "maven", "maven/Dockerfile", "maven/test-0.1.0.jar", "maven/extra-file-1.txt", "maven/target", "maven/target/test-0.1.0.jar");
}
use of org.eclipse.jkube.kit.common.AssemblyFile in project jkube by eclipse.
the class AssemblyFileUtilsTest method getAssemblyFileOutputDirectoryWithAbsoluteDirectoryShouldReturnSameWindows.
@Test
public void getAssemblyFileOutputDirectoryWithAbsoluteDirectoryShouldReturnSameWindows() throws IOException {
// Given
assumeTrue(isWindows());
final AssemblyFile af = AssemblyFile.builder().outputDirectory(new File("C:\\")).build();
final File outputDirectoryForRelativePaths = temporaryFolder.newFolder("output");
final Assembly layer = new Assembly();
final AssemblyConfiguration ac = AssemblyConfiguration.builder().build();
// When
final File result = getAssemblyFileOutputDirectory(af, outputDirectoryForRelativePaths, layer, ac);
// Then
assertEquals("C:\\", result.getAbsolutePath());
}
use of org.eclipse.jkube.kit.common.AssemblyFile in project jkube by eclipse.
the class AssemblyFileUtilsTest method resolveSourceFileAbsoluteFileShouldReturnSameWindows.
@Test
public void resolveSourceFileAbsoluteFileShouldReturnSameWindows() throws IOException {
// Given
assumeTrue(isWindows());
final File baseDirectory = temporaryFolder.newFolder("base");
final AssemblyFile af = AssemblyFile.builder().source(new File("C:\\")).build();
// When
final File result = AssemblyFileUtils.resolveSourceFile(baseDirectory, af);
// Then
assertEquals("C:\\", result.getAbsolutePath());
}
use of org.eclipse.jkube.kit.common.AssemblyFile in project jkube by eclipse.
the class AssemblyFileUtilsTest method getAssemblyFileOutputDirectoryRequired.
@Test
public void getAssemblyFileOutputDirectoryRequired() throws IOException {
// Given
final AssemblyFile af = AssemblyFile.builder().build();
final File outputDirectoryForRelativePaths = temporaryFolder.newFolder("output");
final Assembly layer = new Assembly();
final AssemblyConfiguration ac = AssemblyConfiguration.builder().build();
// When
final NullPointerException result = assertThrows(NullPointerException.class, () -> {
getAssemblyFileOutputDirectory(af, outputDirectoryForRelativePaths, layer, ac);
fail("Should fail as output directory should not be null");
});
// Then
assertEquals("Assembly Configuration output dir is required", result.getMessage());
}
use of org.eclipse.jkube.kit.common.AssemblyFile in project jkube by eclipse.
the class AssemblyFileUtilsTest method getAssemblyFileOutputDirectoryWithRelativeDirectoryShouldReturnComputedPath.
@Test
public void getAssemblyFileOutputDirectoryWithRelativeDirectoryShouldReturnComputedPath() throws IOException {
// Given
final AssemblyFile af = AssemblyFile.builder().outputDirectory(new File("target")).build();
final File outputDirectoryForRelativePaths = temporaryFolder.newFolder("output");
final Assembly layer = new Assembly();
final AssemblyConfiguration ac = AssemblyConfiguration.builder().targetDir("/project").build();
// When
final File result = getAssemblyFileOutputDirectory(af, outputDirectoryForRelativePaths, layer, ac);
// Then
final String expectedPath = outputDirectoryForRelativePaths.toPath().resolve("project").resolve("target").toAbsolutePath().toString();
assertEquals(expectedPath, result.getAbsolutePath());
}
Aggregations