Search in sources :

Example 1 with ConfigViewImpl

use of org.wildfly.swarm.container.config.ConfigViewImpl 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");
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) Node(org.jboss.shrinkwrap.api.Node) Properties(java.util.Properties) WARArchive(org.wildfly.swarm.undertow.WARArchive) URL(java.net.URL) ConfigViewImpl(org.wildfly.swarm.container.config.ConfigViewImpl) UndertowExternalMountsAsset(org.wildfly.swarm.undertow.internal.UndertowExternalMountsAsset) ConfigViewFactory(org.wildfly.swarm.container.config.ConfigViewFactory) BufferedReader(java.io.BufferedReader) List(java.util.List) Test(org.junit.Test)

Aggregations

BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 URL (java.net.URL)1 List (java.util.List)1 Properties (java.util.Properties)1 Node (org.jboss.shrinkwrap.api.Node)1 Test (org.junit.Test)1 ConfigViewFactory (org.wildfly.swarm.container.config.ConfigViewFactory)1 ConfigViewImpl (org.wildfly.swarm.container.config.ConfigViewImpl)1 WARArchive (org.wildfly.swarm.undertow.WARArchive)1 UndertowExternalMountsAsset (org.wildfly.swarm.undertow.internal.UndertowExternalMountsAsset)1