Search in sources :

Example 1 with JBossDeploymentStructureAsset

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

the class DebugUtils method dumpJBossDeploymentStructure.

public static void dumpJBossDeploymentStructure(Archive archive) {
    System.err.println("--- start jboss-deployment-structure.xml");
    JBossDeploymentStructureAsset asset = archive.as(JARArchive.class).getDescriptorAsset();
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(asset.openStream()))) {
        reader.lines().forEach(line -> System.err.println(line));
    } catch (IOException e) {
        e.printStackTrace();
    }
    System.err.println("--- end jboss-deployment-structure.xml");
}
Also used : InputStreamReader(java.io.InputStreamReader) JBossDeploymentStructureAsset(org.wildfly.swarm.spi.api.JBossDeploymentStructureAsset) BufferedReader(java.io.BufferedReader) JARArchive(org.wildfly.swarm.spi.api.JARArchive) IOException(java.io.IOException)

Example 2 with JBossDeploymentStructureAsset

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

the class JARArchiveTest method testVirginJBossDeploymentStructure.

@Test
public void testVirginJBossDeploymentStructure() throws Exception {
    JARArchive archive = ShrinkWrap.create(JARArchive.class);
    archive.addModule("com.foo");
    archive.addModule("com.bar", "api");
    JBossDeploymentStructureAsset asset = archive.getDescriptorAsset();
    assertThat(asset).isNotNull();
    List<Module> modules = asset.deploymentModules();
    assertThat(modules.size()).isEqualTo(2);
    Module module = modules.get(0);
    assertThat(module.name()).isEqualTo("com.foo");
    assertThat(module.slot()).isEqualTo("main");
    module = modules.get(1);
    assertThat(module.name()).isEqualTo("com.bar");
    assertThat(module.slot()).isEqualTo("api");
    archive = archive.as(JARArchive.class);
    asset = archive.getDescriptorAsset();
    assertThat(asset).isNotNull();
    modules = asset.deploymentModules();
    assertThat(modules.size()).isEqualTo(2);
    module = modules.get(0);
    assertThat(module.name()).isEqualTo("com.foo");
    assertThat(module.slot()).isEqualTo("main");
    module = modules.get(1);
    assertThat(module.name()).isEqualTo("com.bar");
    assertThat(module.slot()).isEqualTo("api");
}
Also used : JBossDeploymentStructureAsset(org.wildfly.swarm.spi.api.JBossDeploymentStructureAsset) JARArchive(org.wildfly.swarm.spi.api.JARArchive) Module(org.wildfly.swarm.spi.api.Module) Test(org.junit.Test)

Example 3 with JBossDeploymentStructureAsset

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

the class JARArchiveTest method testExistingJBossDeploymentStructure.

@Test
public void testExistingJBossDeploymentStructure() throws Exception {
    JARArchive archive = ShrinkWrap.create(JARArchive.class);
    archive.add(new StringAsset("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<jboss-deployment-structure xmlns=\"urn:jboss:deployment-structure:1.2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:jboss:deployment-structure:1.2 jboss-deployment-structure-1_2.xsd\">\n" + "  <deployment>\n" + "    <dependencies>\n" + "      <module name=\"com.foo\" slot=\"main\"/>\n" + "      <module name=\"com.bar\" slot=\"api\"/>\n" + "    </dependencies>\n" + "  </deployment>\n" + "</jboss-deployment-structure>"), JBossDeploymentStructureContainer.PRIMARY_JBOSS_DEPLOYMENT_DESCRIPTOR_PATH);
    archive.addModule("com.baz", "api");
    JBossDeploymentStructureAsset asset = archive.getDescriptorAsset();
    assertThat(asset).isNotNull();
    List<Module> modules = asset.deploymentModules();
    assertThat(modules.size()).isEqualTo(3);
    Module module = modules.get(0);
    assertThat(module.name()).isEqualTo("com.foo");
    assertThat(module.slot()).isEqualTo("main");
    module = modules.get(1);
    assertThat(module.name()).isEqualTo("com.bar");
    assertThat(module.slot()).isEqualTo("api");
    module = modules.get(2);
    assertThat(module.name()).isEqualTo("com.baz");
    assertThat(module.slot()).isEqualTo("api");
    archive = archive.as(JARArchive.class);
    asset = archive.getDescriptorAsset();
    assertThat(asset).isNotNull();
    modules = asset.deploymentModules();
    assertThat(modules.size()).isEqualTo(3);
    module = modules.get(0);
    assertThat(module.name()).isEqualTo("com.foo");
    assertThat(module.slot()).isEqualTo("main");
    module = modules.get(1);
    assertThat(module.name()).isEqualTo("com.bar");
    assertThat(module.slot()).isEqualTo("api");
    module = modules.get(2);
    assertThat(module.name()).isEqualTo("com.baz");
    assertThat(module.slot()).isEqualTo("api");
}
Also used : StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) JBossDeploymentStructureAsset(org.wildfly.swarm.spi.api.JBossDeploymentStructureAsset) JARArchive(org.wildfly.swarm.spi.api.JARArchive) Module(org.wildfly.swarm.spi.api.Module) Test(org.junit.Test)

Aggregations

JARArchive (org.wildfly.swarm.spi.api.JARArchive)3 JBossDeploymentStructureAsset (org.wildfly.swarm.spi.api.JBossDeploymentStructureAsset)3 Test (org.junit.Test)2 Module (org.wildfly.swarm.spi.api.Module)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)1