use of org.wildfly.swarm.spi.api.config.ConfigView in project wildfly-swarm by wildfly-swarm.
the class ConfigurableManagerTest method testDeploymentConfigurableUsingAlias.
@Test
public void testDeploymentConfigurableUsingAlias() throws Exception {
Properties props = new Properties();
Map<String, String> env = new HashMap<>();
ConfigViewFactory factory = new ConfigViewFactory(props, env);
factory.withProperty("swarm.http.context", "/myapp");
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("/myapp");
} finally {
context.deactivate();
}
}
use of org.wildfly.swarm.spi.api.config.ConfigView in project wildfly-swarm by wildfly-swarm.
the class ConfigurableManagerTest method testDeploymentConfigurable.
@Test
public void testDeploymentConfigurable() 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", "/myapp");
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("/myapp");
} finally {
context.deactivate();
}
}
use of org.wildfly.swarm.spi.api.config.ConfigView in project wildfly-swarm by wildfly-swarm.
the class InterfaceExtensionTest method testAfterBeanDiscovery.
@Test
public void testAfterBeanDiscovery() throws Exception {
ConfigView configView = mock(ConfigView.class);
List<SimpleKey> interfaces = Arrays.asList(new SimpleKey("test"));
when(configView.simpleSubkeys(any(ConfigKey.class))).thenReturn(interfaces);
when(configView.valueOf(any(ConfigKey.class))).thenReturn("192.168.1.1");
ext = new InterfaceExtension(configView);
BeanManager beanManager = mock(BeanManager.class);
AfterBeanDiscovery abd = mock(AfterBeanDiscovery.class);
@SuppressWarnings("unchecked") ArgumentCaptor<CommonBean<Interface>> captor = ArgumentCaptor.forClass(CommonBean.class);
ext.afterBeanDiscovery(abd, beanManager);
verify(abd, times(1)).addBean(captor.capture());
assertThat(captor.getValue().create(null).getName()).isEqualTo("test");
assertThat(captor.getValue().create(null).getExpression()).isEqualTo("192.168.1.1");
}
use of org.wildfly.swarm.spi.api.config.ConfigView in project wildfly-swarm by wildfly-swarm.
the class ProjectStagesTest method testCLIToLoadConfig.
@Test
public void testCLIToLoadConfig() throws Exception {
Swarm swarm = new Swarm(new Properties(), "-Sfoo");
ConfigView view = swarm.configView();
assertThat(view.resolve("swarm.myname").getValue()).isEqualTo("foo");
}
use of org.wildfly.swarm.spi.api.config.ConfigView in project wildfly-swarm by wildfly-swarm.
the class ProjectStagesTest method testPseudoPropertiesToSelectProjectStage.
@Test
public void testPseudoPropertiesToSelectProjectStage() throws Exception {
Swarm swarm = new Swarm(new Properties(), "-Dswarm.project.stage=production");
ConfigView view = swarm.configView();
assertThat(view.resolve("foo.bar.baz").getValue()).isEqualTo("brie");
}
Aggregations