use of org.wildfly.swarm.spi.api.config.ConfigView in project wildfly-swarm by wildfly-swarm.
the class ProjectStagesTest method testPropertyBasedConfigStagesFileOnlyDefault.
@Test
public void testPropertyBasedConfigStagesFileOnlyDefault() throws Exception {
try {
URL projectStages = getClass().getClassLoader().getResource("multi-project-stages.yml");
System.setProperty(SwarmProperties.PROJECT_STAGE_FILE, projectStages.toExternalForm());
Swarm swarm = new Swarm(new Properties());
ConfigView view = swarm.configView();
assertThat(view.resolve("foo.bar.baz").getValue()).isEqualTo("cheddar");
} finally {
System.clearProperty(SwarmProperties.PROJECT_STAGE_FILE);
}
}
use of org.wildfly.swarm.spi.api.config.ConfigView in project wildfly-swarm by wildfly-swarm.
the class ProjectStagesTest method testPropertiesPreferredToEnvironmentVars.
@Test
public void testPropertiesPreferredToEnvironmentVars() 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);
ConfigView view = swarm.configView();
assertThat(view.resolve("swarm.myname").getValue()).isEqualTo("from_props");
}
use of org.wildfly.swarm.spi.api.config.ConfigView in project wildfly-swarm by wildfly-swarm.
the class ProjectStagesTest method testSwarmAPIToLoadConfig.
@Test
public void testSwarmAPIToLoadConfig() throws Exception {
Swarm swarm = new Swarm(new Properties());
swarm.withProfile("foo");
ConfigView view = swarm.configView();
assertThat(view.resolve("swarm.myname").getValue()).isEqualTo("foo");
swarm.withProfile("bar");
assertThat(view.resolve("swarm.myname").getValue()).isEqualTo("foo");
assertThat(view.resolve("swarm.mydottednumber").as(Double.class).getValue()).isEqualTo(2.82);
}
use of org.wildfly.swarm.spi.api.config.ConfigView in project wildfly-swarm by wildfly-swarm.
the class StageConfigTest method testPropertyBasedConfigStagesFile.
@Test
public void testPropertyBasedConfigStagesFile() throws Exception {
try {
URL projectStages = getClass().getClassLoader().getResource("simple-project-stages.yml");
System.setProperty(SwarmProperties.PROJECT_STAGE_FILE, projectStages.toExternalForm());
Swarm swarm = new Swarm(new Properties());
ConfigView view = swarm.configView();
assertThat(view.resolve("foo.bar.baz").getValue()).isEqualTo("cheddar");
StageConfig stageConfig = swarm.stageConfig();
assertThat(stageConfig.resolve("foo.bar.baz").getValue()).isEqualTo("cheddar");
} finally {
System.clearProperty(SwarmProperties.PROJECT_STAGE_FILE);
}
}
use of org.wildfly.swarm.spi.api.config.ConfigView in project wildfly-swarm by wildfly-swarm.
the class ConfigurableManagerTest method testDeploymentConfigurableUsingBoth.
@Test
public void testDeploymentConfigurableUsingBoth() throws Exception {
Properties props = new Properties();
Map<String, String> env = new HashMap<>();
ConfigViewFactory factory = new ConfigViewFactory(props, env);
factory.withProperty("swarm.deployment.[myapp.war].context", "/my-specific-app");
factory.withProperty("swarm.http.context", "/my-alias-app");
ConfigView configView = factory.get(true);
DeploymentContext context = new DeploymentContextImpl();
ConfigurableManager manager = new ConfigurableManager(configView, context);
Archive archive = ShrinkWrap.create(JavaArchive.class, "myapp.war");
try {
context.activate(archive, archive.getName(), false);
Component component = new Component();
manager.scan(component);
assertThat(component.context.get()).isEqualTo("/my-specific-app");
} finally {
context.deactivate();
}
Archive archiveToo = ShrinkWrap.create(JavaArchive.class, "otherapp.war");
try {
context.activate(archiveToo, archiveToo.getName(), false);
Component component = new Component();
manager.scan(component);
assertThat(component.context.get()).isEqualTo("/my-alias-app");
} finally {
context.deactivate();
}
}
Aggregations