Search in sources :

Example 51 with BuildImageConfiguration

use of io.fabric8.maven.docker.config.BuildImageConfiguration in project docker-maven-plugin by fabric8io.

the class DockerAssemblyManagerTest method multipleAssemblyFiles.

@Test
public void multipleAssemblyFiles(@Injectable final MojoParameters mojoParams, @Injectable final MavenProject project, @Injectable final Assembly assembly1, @Injectable final Assembly assembly2) throws AssemblyFormattingException, ArchiveCreationException, InvalidAssemblerConfigurationException, MojoExecutionException, AssemblyReadException, IllegalAccessException {
    ReflectionUtils.setVariableValueInObject(assemblyManager, "trackArchivers", trackArchivers);
    new Expectations() {

        {
            mojoParams.getOutputDirectory();
            result = "target/";
            times = 6;
            mojoParams.getProject();
            project.getBasedir();
            result = ".";
            assemblyReader.readAssemblies((AssemblerConfigurationSource) any);
            result = Collections.singletonList(assembly1);
            assemblyReader.readAssemblies((AssemblerConfigurationSource) any);
            result = Collections.singletonList(assembly2);
        }
    };
    BuildImageConfiguration buildConfig = createBuildConfigMultiAssembly();
    AssemblyFiles files = assemblyManager.getAssemblyFiles("testImage", buildConfig.getAssemblyConfigurations().get(0), mojoParams, new AnsiLogger(new SystemStreamLog(), true, "build"));
    assertNotNull(files);
    files = assemblyManager.getAssemblyFiles("testImage", buildConfig.getAssemblyConfigurations().get(1), mojoParams, new AnsiLogger(new SystemStreamLog(), true, "build"));
    assertNotNull(files);
}
Also used : Expectations(mockit.Expectations) SystemStreamLog(org.apache.maven.plugin.logging.SystemStreamLog) AnsiLogger(io.fabric8.maven.docker.util.AnsiLogger) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Test(org.junit.Test)

Example 52 with BuildImageConfiguration

use of io.fabric8.maven.docker.config.BuildImageConfiguration in project docker-maven-plugin by fabric8io.

the class DockerAssemblyManagerTest method testMultipleCopyValidVerifyGivenDockerfile.

@Test
public void testMultipleCopyValidVerifyGivenDockerfile(@Injectable final Logger logger) throws IOException {
    BuildImageConfiguration buildConfig = createBuildConfigMultiAssembly();
    assemblyManager.verifyGivenDockerfile(new File(getClass().getResource("/docker/Dockerfile_assembly_verify_multi_copy_valid.test").getPath()), buildConfig, createInterpolator(buildConfig), logger);
    new Verifications() {

        {
            logger.warn(anyString, (Object[]) any);
            times = 0;
        }
    };
}
Also used : Verifications(mockit.Verifications) File(java.io.File) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Test(org.junit.Test)

Example 53 with BuildImageConfiguration

use of io.fabric8.maven.docker.config.BuildImageConfiguration in project docker-maven-plugin by fabric8io.

the class DockerAssemblyManagerTest method testNoAssembly.

@Test
public void testNoAssembly() {
    BuildImageConfiguration buildConfig = new BuildImageConfiguration();
    List<AssemblyConfiguration> assemblyConfig = buildConfig.getAssemblyConfigurations();
    String content = assemblyManager.createDockerFileBuilder(buildConfig, assemblyConfig).content();
    assertFalse(content.contains("COPY"));
    assertFalse(content.contains("VOLUME"));
}
Also used : AssemblyConfiguration(io.fabric8.maven.docker.config.AssemblyConfiguration) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Test(org.junit.Test)

Example 54 with BuildImageConfiguration

use of io.fabric8.maven.docker.config.BuildImageConfiguration in project docker-maven-plugin by fabric8io.

the class DockerAssemblyManagerTest method testCopyValidVerifyGivenDockerfile.

@Test
public void testCopyValidVerifyGivenDockerfile(@Injectable final Logger logger) throws IOException {
    BuildImageConfiguration buildConfig = createBuildConfig();
    assemblyManager.verifyGivenDockerfile(new File(getClass().getResource("/docker/Dockerfile_assembly_verify_copy_valid.test").getPath()), buildConfig, createInterpolator(buildConfig), logger);
    new Verifications() {

        {
            logger.warn(anyString, (Object[]) any);
            times = 0;
        }
    };
}
Also used : Verifications(mockit.Verifications) File(java.io.File) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Test(org.junit.Test)

Example 55 with BuildImageConfiguration

use of io.fabric8.maven.docker.config.BuildImageConfiguration in project docker-maven-plugin by fabric8io.

the class DockerAssemblyManagerTest method testArchiveCreationDockerfileWithMultipleArchiveAssemblies.

@Test
public void testArchiveCreationDockerfileWithMultipleArchiveAssemblies(@Injectable final TarArchiver tarArchiver, @Injectable final Logger logger) throws MojoExecutionException, NoSuchArchiverException {
    MojoParameters mojoParams = mockMojoParams(mockMavenProject());
    BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder().dockerFile(DockerAssemblyManagerTest.class.getResource("/docker/Dockerfile.test").getPath()).assemblies(Arrays.asList(new AssemblyConfiguration.Builder().name("first").mode(AssemblyMode.tar.name()).assemblyDef(new Assembly()).build(), new AssemblyConfiguration.Builder().name("second").mode(AssemblyMode.tar.name()).assemblyDef(new Assembly()).build())).build();
    buildImageConfiguration.initAndValidate(logger);
    File tarArchive = assemblyManager.createDockerTarArchive("test_image", mojoParams, buildImageConfiguration, logger, null);
    assertNotNull(tarArchive);
    new Verifications() {

        {
            archiverManager.getArchiver("tar");
            times = 1;
            List<FileSet> fileSets = new ArrayList<>();
            tarArchiver.addFileSet(withCapture(fileSets));
            assertEquals(1, fileSets.size());
            assertArrayEquals(new String[] { "target/**", "Dockerfile.test" }, fileSets.get(0).getExcludes());
            assertNull(fileSets.get(0).getIncludes());
            tarArchiver.addFile(new File("target/test_image/build/Dockerfile.test"), "Dockerfile.test");
            List<ArchivedFileSet> archivedFileSets = new ArrayList<>();
            tarArchiver.addArchivedFileSet(withCapture(archivedFileSets));
            assertEquals(2, archivedFileSets.size());
            assertEquals(new File("target/test_image/build/first.tar"), archivedFileSets.get(0).getArchive());
            assertEquals("first/", archivedFileSets.get(0).getPrefix());
            assertEquals(new File("target/test_image/build/second.tar"), archivedFileSets.get(1).getArchive());
            assertEquals("second/", archivedFileSets.get(1).getPrefix());
        }
    };
}
Also used : FileSet(org.codehaus.plexus.archiver.FileSet) ArchivedFileSet(org.codehaus.plexus.archiver.ArchivedFileSet) ArrayList(java.util.ArrayList) ArchivedFileSet(org.codehaus.plexus.archiver.ArchivedFileSet) Verifications(mockit.Verifications) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) AssemblyConfiguration(io.fabric8.maven.docker.config.AssemblyConfiguration) MojoParameters(io.fabric8.maven.docker.util.MojoParameters) File(java.io.File) Assembly(org.apache.maven.plugins.assembly.model.Assembly) Test(org.junit.Test)

Aggregations

BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)68 Test (org.junit.Test)40 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)34 File (java.io.File)19 Verifications (mockit.Verifications)15 RunImageConfiguration (io.fabric8.maven.docker.config.RunImageConfiguration)12 ArrayList (java.util.ArrayList)11 AssemblyConfiguration (io.fabric8.maven.docker.config.AssemblyConfiguration)10 AbstractConfigHandlerTest (io.fabric8.maven.docker.config.handler.AbstractConfigHandlerTest)10 Expectations (mockit.Expectations)9 MojoParameters (io.fabric8.maven.docker.util.MojoParameters)8 Properties (java.util.Properties)7 Before (org.junit.Before)7 VolumeConfig (io.fabric8.maven.core.config.VolumeConfig)6 ArchivedFileSet (org.codehaus.plexus.archiver.ArchivedFileSet)6 Assembly (org.apache.maven.plugins.assembly.model.Assembly)5 Arguments (io.fabric8.maven.docker.config.Arguments)4 CleanupMode (io.fabric8.maven.docker.config.CleanupMode)4 FileSet (org.codehaus.plexus.archiver.FileSet)4 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)3