Search in sources :

Example 11 with ConfigView

use of org.wildfly.swarm.spi.api.config.ConfigView in project wildfly-swarm by wildfly-swarm.

the class ProjectStagesTest method testCLIBasedSelectedStage.

@Test
public void testCLIBasedSelectedStage() throws Exception {
    Swarm swarm = new Swarm(new Properties(), "-S", "production");
    ConfigView view = swarm.configView();
    assertThat(view.resolve("foo.bar.baz").getValue()).isEqualTo("brie");
}
Also used : ConfigView(org.wildfly.swarm.spi.api.config.ConfigView) Properties(java.util.Properties) SwarmProperties(org.wildfly.swarm.spi.api.SwarmProperties) Test(org.junit.Test)

Example 12 with ConfigView

use of org.wildfly.swarm.spi.api.config.ConfigView in project wildfly-swarm by wildfly-swarm.

the class ProjectStagesTest method testPropertiesOnCLIPreferredToEnvironmentVars.

@Test
public void testPropertiesOnCLIPreferredToEnvironmentVars() throws Exception {
    Map<String, String> environment = new HashMap<>();
    Properties properties = new Properties();
    environment.put("swarm.myname", "from_env");
    properties.setProperty("swarm.myname", "from_props");
    Swarm swarm = new Swarm(properties, environment, "-Dswarm.myname=tacos");
    ConfigView view = swarm.configView();
    assertThat(view.resolve("swarm.myname").getValue()).isEqualTo("tacos");
}
Also used : HashMap(java.util.HashMap) ConfigView(org.wildfly.swarm.spi.api.config.ConfigView) Properties(java.util.Properties) SwarmProperties(org.wildfly.swarm.spi.api.SwarmProperties) Test(org.junit.Test)

Example 13 with ConfigView

use of org.wildfly.swarm.spi.api.config.ConfigView in project wildfly-swarm by wildfly-swarm.

the class ProjectStagesTest method testPropertyBasedConfigStagesFileAndSelectedStage.

@Test
public void testPropertyBasedConfigStagesFileAndSelectedStage() throws Exception {
    try {
        URL projectStages = getClass().getClassLoader().getResource("multi-project-stages.yml");
        System.setProperty(SwarmProperties.PROJECT_STAGE_FILE, projectStages.toExternalForm());
        System.setProperty(SwarmProperties.PROJECT_STAGE, "production");
        Swarm swarm = new Swarm(new Properties());
        ConfigView view = swarm.configView();
        assertThat(view.resolve("foo.bar.baz").getValue()).isEqualTo("brie");
    } finally {
        System.clearProperty(SwarmProperties.PROJECT_STAGE_FILE);
        System.clearProperty(SwarmProperties.PROJECT_STAGE);
    }
}
Also used : ConfigView(org.wildfly.swarm.spi.api.config.ConfigView) Properties(java.util.Properties) SwarmProperties(org.wildfly.swarm.spi.api.SwarmProperties) URL(java.net.URL) Test(org.junit.Test)

Example 14 with ConfigView

use of org.wildfly.swarm.spi.api.config.ConfigView in project wildfly-swarm by wildfly-swarm.

the class ProjectStagesTest method testEnvironmentVars.

@Test
public void testEnvironmentVars() throws Exception {
    Map<String, String> environment = new HashMap<>();
    environment.put("swarm.myname", "from_env");
    Swarm swarm = new Swarm(new Properties(), environment);
    ConfigView view = swarm.configView();
    assertThat(view.resolve("swarm.myname").getValue()).isEqualTo("from_env");
}
Also used : HashMap(java.util.HashMap) ConfigView(org.wildfly.swarm.spi.api.config.ConfigView) Properties(java.util.Properties) SwarmProperties(org.wildfly.swarm.spi.api.SwarmProperties) Test(org.junit.Test)

Example 15 with ConfigView

use of org.wildfly.swarm.spi.api.config.ConfigView in project wildfly-swarm by wildfly-swarm.

the class ProjectStagesTest method testIsolatedPropertiesToSelectProjectStage.

@Test
public void testIsolatedPropertiesToSelectProjectStage() throws Exception {
    Properties props = new Properties();
    props.setProperty("swarm.project.stage", "production");
    Swarm swarm = new Swarm(props, "-Dswarm.project.stage=production");
    ConfigView view = swarm.configView();
    assertThat(view.resolve("foo.bar.baz").getValue()).isEqualTo("brie");
    assertThat(view.resolve("foo.bar.taco").getValue()).isEqualTo("crunchy");
}
Also used : ConfigView(org.wildfly.swarm.spi.api.config.ConfigView) Properties(java.util.Properties) SwarmProperties(org.wildfly.swarm.spi.api.SwarmProperties) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)16 ConfigView (org.wildfly.swarm.spi.api.config.ConfigView)16 Properties (java.util.Properties)15 SwarmProperties (org.wildfly.swarm.spi.api.SwarmProperties)12 HashMap (java.util.HashMap)6 URL (java.net.URL)4 Archive (org.jboss.shrinkwrap.api.Archive)3 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)3 ConfigViewFactory (org.wildfly.swarm.container.config.ConfigViewFactory)3 DeploymentContext (org.wildfly.swarm.container.runtime.cdi.DeploymentContext)3 DeploymentContextImpl (org.wildfly.swarm.container.runtime.cdi.DeploymentContextImpl)3 AfterBeanDiscovery (javax.enterprise.inject.spi.AfterBeanDiscovery)1 BeanManager (javax.enterprise.inject.spi.BeanManager)1 StageConfig (org.wildfly.swarm.spi.api.StageConfig)1 CommonBean (org.wildfly.swarm.spi.api.cdi.CommonBean)1 ConfigKey (org.wildfly.swarm.spi.api.config.ConfigKey)1 SimpleKey (org.wildfly.swarm.spi.api.config.SimpleKey)1