use of org.wildfly.swarm.container.config.ConfigViewFactory in project wildfly-swarm by wildfly-swarm.
the class ContextPathArchivePreparerTest method testExternalMount.
@SuppressWarnings("unchecked")
@Test
public void testExternalMount() throws Exception {
WARArchive archive = DefaultWarDeploymentFactory.archiveFromCurrentApp();
assertThat(archive.getContextRoot()).isNull();
URL url = getClass().getClassLoader().getResource("mounts.yml");
ConfigViewFactory factory = new ConfigViewFactory(new Properties());
factory.load("test", url);
factory.withProfile("test");
ConfigViewImpl view = factory.get(true);
List<String> mounts = view.resolve("swarm.context.mounts").as(List.class).getValue();
ContextPathArchivePreparer preparer = new ContextPathArchivePreparer(archive);
preparer.mounts = mounts;
preparer.process();
Node externalMount = archive.get(WARArchive.EXTERNAL_MOUNT_PATH);
assertThat(externalMount).isNotNull();
assertThat(externalMount.getAsset()).isInstanceOf(UndertowExternalMountsAsset.class);
UndertowExternalMountsAsset externalMountAsset = (UndertowExternalMountsAsset) externalMount.getAsset();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(externalMountAsset.openStream()))) {
assertThat(reader.readLine()).endsWith("external1");
assertThat(reader.readLine()).endsWith("external2");
}
}
use of org.wildfly.swarm.container.config.ConfigViewFactory 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.container.config.ConfigViewFactory 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.container.config.ConfigViewFactory 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