Search in sources :

Example 36 with Logger

use of io.fabric8.maven.docker.util.Logger in project docker-maven-plugin by fabric8io.

the class LogMatchCallbackTest method matchingMultipleLinesSucceeds.

@Test(expected = LogCallback.DoneException.class)
public void matchingMultipleLinesSucceeds() throws Exception {
    final String patterString = "(?s)ready to accept connections.*\\n.*ready to accept connections";
    final LogMatchCallback logMatchCallback = new LogMatchCallback(logger, callback, patterString);
    new Expectations() {

        {
            callback.matched();
            times = 1;
        }
    };
    logMatchCallback.log(1, new Timestamp(), "LOG:  database system is ready to accept connections");
    logMatchCallback.log(1, new Timestamp(), "LOG:  autovacuum launcher started");
    logMatchCallback.log(1, new Timestamp(), "LOG:  database system is shut down");
    logMatchCallback.log(1, new Timestamp(), "LOG:  database system is ready to accept connections");
}
Also used : Expectations(mockit.Expectations) Timestamp(io.fabric8.maven.docker.util.Timestamp) Test(org.junit.Test)

Example 37 with Logger

use of io.fabric8.maven.docker.util.Logger in project docker-maven-plugin by fabric8io.

the class DockerAssemblyManager method getAssemblyFiles.

/**
 * Extract all files with a tracking archiver. These can be used to track changes in the filesystem and triggering
 * a rebuild of the image if needed ('docker:watch')
 */
public AssemblyFiles getAssemblyFiles(String name, BuildImageConfiguration buildConfig, MojoParameters mojoParams, Logger log) throws InvalidAssemblerConfigurationException, ArchiveCreationException, AssemblyFormattingException, MojoExecutionException {
    BuildDirs buildDirs = createBuildDirs(name, mojoParams);
    AssemblyConfiguration assemblyConfig = buildConfig.getAssemblyConfiguration();
    String assemblyName = assemblyConfig.getName();
    DockerAssemblyConfigurationSource source = new DockerAssemblyConfigurationSource(mojoParams, buildDirs, assemblyConfig);
    Assembly assembly = getAssemblyConfig(assemblyConfig, source);
    synchronized (trackArchiver) {
        MappingTrackArchiver ta = (MappingTrackArchiver) trackArchiver;
        ta.init(log, assemblyName);
        assembly.setId("tracker");
        assemblyArchiver.createArchive(assembly, assemblyName, "track", source, false);
        return ta.getAssemblyFiles(mojoParams.getSession());
    }
}
Also used : AssemblyConfiguration(io.fabric8.maven.docker.config.AssemblyConfiguration) Assembly(org.apache.maven.plugin.assembly.model.Assembly)

Example 38 with Logger

use of io.fabric8.maven.docker.util.Logger in project docker-maven-plugin by fabric8io.

the class EcrExtendedAuthTest method testClientClosedAndCredentialsDecoded.

@Test
public void testClientClosedAndCredentialsDecoded(@Mocked final CloseableHttpClient closeableHttpClient, @Mocked final CloseableHttpResponse closeableHttpResponse, @Mocked final StatusLine statusLine) throws IOException, MojoExecutionException {
    final HttpEntity entity = new StringEntity("{\"authorizationData\": [{" + "\"authorizationToken\": \"QVdTOnBhc3N3b3Jk\"," + "\"expiresAt\": 1448878779.809," + "\"proxyEndpoint\": \"https://012345678910.dkr.ecr.eu-west-1.amazonaws.com\"}]}");
    new Expectations() {

        {
            statusLine.getStatusCode();
            result = 200;
            closeableHttpResponse.getEntity();
            result = entity;
        }
    };
    EcrExtendedAuth eea = new EcrExtendedAuth(logger, "123456789012.dkr.ecr.eu-west-1.amazonaws.com") {

        CloseableHttpClient createClient() {
            return closeableHttpClient;
        }
    };
    AuthConfig localCredentials = new AuthConfig("username", "password", null, null);
    AuthConfig awsCredentials = eea.extendedAuth(localCredentials);
    assertEquals("AWS", awsCredentials.getUsername());
    assertEquals("password", awsCredentials.getPassword());
    new Verifications() {

        {
            closeableHttpClient.close();
        }
    };
}
Also used : Expectations(mockit.Expectations) StringEntity(org.apache.http.entity.StringEntity) HttpEntity(org.apache.http.HttpEntity) AuthConfig(io.fabric8.maven.docker.access.AuthConfig) Verifications(mockit.Verifications) Test(org.junit.Test)

Example 39 with Logger

use of io.fabric8.maven.docker.util.Logger 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 40 with Logger

use of io.fabric8.maven.docker.util.Logger in project docker-maven-plugin by fabric8io.

the class DockerAssemblyManagerTest method testCopyInvalidVerifyGivenDockerfile.

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

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

Aggregations

Test (org.junit.Test)30 File (java.io.File)11 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)10 IOException (java.io.IOException)9 ArrayList (java.util.ArrayList)9 URL (java.net.URL)8 GeneratorContext (io.fabric8.maven.generator.api.GeneratorContext)7 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)6 ResourceValidator (io.fabric8.maven.core.util.validator.ResourceValidator)6 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)6 Logger (io.fabric8.maven.docker.util.Logger)6 Util.readAsString (io.fabric8.arquillian.utils.Util.readAsString)5 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)5 Pod (io.fabric8.kubernetes.api.model.Pod)5 OpenShiftMockServer (io.fabric8.openshift.client.server.mock.OpenShiftMockServer)5 Expectations (mockit.Expectations)5 Logger (io.fabric8.arquillian.kubernetes.log.Logger)4 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)4 BuildService (io.fabric8.maven.core.service.BuildService)4 Fabric8ServiceException (io.fabric8.maven.core.service.Fabric8ServiceException)4