Search in sources :

Example 66 with Builder

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

the class InitContainerHandlerTest method existingDifferent.

@Test
public void existingDifferent() {
    try {
        PodTemplateSpecBuilder builder = getPodTemplateBuilder("blub", "foo/bla");
        assertTrue(handler.hasInitContainer(builder, "blub"));
        JSONObject initContainer = createInitContainer("blub", "foo/blub");
        handler.appendInitContainer(builder, initContainer);
        fail();
    } catch (IllegalArgumentException exp) {
        assertTrue(exp.getMessage().contains("blub"));
    }
}
Also used : JSONObject(org.json.JSONObject) PodTemplateSpecBuilder(io.fabric8.kubernetes.api.model.PodTemplateSpecBuilder) Test(org.junit.Test)

Example 67 with Builder

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

the class InitContainerHandlerTest method existingSame.

@Test
public void existingSame() {
    new Expectations() {

        {
            log.warn(anyString, withSubstring("blub"));
        }
    };
    PodTemplateSpecBuilder builder = getPodTemplateBuilder("blub", "foo/blub");
    assertTrue(handler.hasInitContainer(builder, "blub"));
    JSONObject initContainer = createInitContainer("blub", "foo/blub");
    handler.appendInitContainer(builder, initContainer);
    assertTrue(handler.hasInitContainer(builder, "blub"));
    verifyBuilder(builder, initContainer);
}
Also used : Expectations(mockit.Expectations) JSONObject(org.json.JSONObject) PodTemplateSpecBuilder(io.fabric8.kubernetes.api.model.PodTemplateSpecBuilder) Test(org.junit.Test)

Example 68 with Builder

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

the class InitContainerHandlerTest method verifyBuilder.

private void verifyBuilder(PodTemplateSpecBuilder builder, JSONObject... initContainers) {
    PodTemplateSpec spec = builder.build();
    String containers = spec.getMetadata().getAnnotations().get(InitContainerHandler.INIT_CONTAINER_ANNOTATION);
    if (initContainers.length == 0) {
        assertNull(containers);
    } else {
        JSONArray got = new JSONArray(containers);
        assertEquals(got.length(), initContainers.length);
        for (int i = 0; i < initContainers.length; i++) {
            assertTrue(JSONUtil.equals(got.getJSONObject(i), initContainers[i]));
        }
    }
}
Also used : PodTemplateSpec(io.fabric8.kubernetes.api.model.PodTemplateSpec) JSONArray(org.json.JSONArray)

Example 69 with Builder

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

the class InitContainerHandlerTest method append.

@Test
public void append() {
    PodTemplateSpecBuilder builder = getPodTemplateBuilder("bla", "foo/bla");
    assertFalse(handler.hasInitContainer(builder, "blub"));
    JSONObject initContainer = createInitContainer("blub", "foo/blub");
    handler.appendInitContainer(builder, initContainer);
    assertTrue(handler.hasInitContainer(builder, "blub"));
    verifyBuilder(builder, createInitContainer("bla", "foo/bla"), initContainer);
}
Also used : JSONObject(org.json.JSONObject) PodTemplateSpecBuilder(io.fabric8.kubernetes.api.model.PodTemplateSpecBuilder) Test(org.junit.Test)

Example 70 with Builder

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

the class InitContainerHandlerTest method simple.

@Test
public void simple() {
    PodTemplateSpecBuilder builder = getPodTemplateBuilder();
    assertFalse(handler.hasInitContainer(builder, "blub"));
    JSONObject initContainer = createInitContainer("blub", "foo/blub");
    handler.appendInitContainer(builder, initContainer);
    assertTrue(handler.hasInitContainer(builder, "blub"));
    verifyBuilder(builder, initContainer);
}
Also used : JSONObject(org.json.JSONObject) PodTemplateSpecBuilder(io.fabric8.kubernetes.api.model.PodTemplateSpecBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)60 ProfileBuilder (io.fabric8.api.ProfileBuilder)34 Profile (io.fabric8.api.Profile)33 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)27 FabricService (io.fabric8.api.FabricService)24 InputStream (java.io.InputStream)21 Deployment (org.jboss.arquillian.container.test.api.Deployment)21 OSGiManifestBuilder (org.jboss.osgi.metadata.OSGiManifestBuilder)21 Asset (org.jboss.shrinkwrap.api.asset.Asset)21 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)21 ServiceTracker (org.osgi.util.tracker.ServiceTracker)20 HashMap (java.util.HashMap)19 Map (java.util.Map)19 Logger (org.slf4j.Logger)19 CommandSupport (io.fabric8.itests.support.CommandSupport)18 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)17 ServiceLocator (io.fabric8.api.gravia.ServiceLocator)16 IOException (java.io.IOException)16 Action (org.apache.felix.gogo.commands.Action)16 AbstractCommand (org.apache.felix.gogo.commands.basic.AbstractCommand)16