Search in sources :

Example 76 with JARArchive

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

the class JGroupsArquillianTest method createDeployment.

@Deployment
public static Archive createDeployment() {
    JARArchive deployment = ShrinkWrap.create(JARArchive.class);
    deployment.add(EmptyAsset.INSTANCE, "nothing");
    return deployment;
}
Also used : JARArchive(org.wildfly.swarm.spi.api.JARArchive) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 77 with JARArchive

use of org.wildfly.swarm.spi.api.JARArchive 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)

Example 78 with JARArchive

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

the class SystemContextTransformTest method deployment.

@Deployment
public static JARArchive deployment() {
    JARArchive archive = ShrinkWrap.create(JARArchive.class, "system-context-tests.jar");
    archive.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    return archive;
}
Also used : JARArchive(org.wildfly.swarm.spi.api.JARArchive) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 79 with JARArchive

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

the class RibbonArchiveTest method testAdvertiseMultiple.

@Test
public void testAdvertiseMultiple() {
    JARArchive archive = ShrinkWrap.create(JARArchive.class, "myapp.war");
    archive.as(RibbonArchive.class).advertise("service-a").advertise("service-b").advertise("service-c");
    Asset asset = archive.get(RibbonArchive.REGISTRATION_CONF).getAsset();
    assertThat(asset).isNotNull();
    assertThat(asset).isInstanceOf(StringAsset.class);
    String[] services = ((StringAsset) asset).getSource().split("\n");
    assertThat(services).contains("service-a");
    assertThat(services).contains("service-b");
    assertThat(services).contains("service-c");
    assertThat(archive.as(ServiceActivatorArchive.class).containsServiceActivator(RibbonArchiveImpl.SERVICE_ACTIVATOR_CLASS_NAME)).isTrue();
}
Also used : ServiceActivatorArchive(org.wildfly.swarm.msc.ServiceActivatorArchive) StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) Asset(org.jboss.shrinkwrap.api.asset.Asset) JARArchive(org.wildfly.swarm.spi.api.JARArchive) Test(org.junit.Test)

Example 80 with JARArchive

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

the class RibbonArchiveTest method testNotAdvertise.

@Test
public void testNotAdvertise() {
    JARArchive archive = ShrinkWrap.create(JARArchive.class, "myapp.war");
    archive.as(RibbonArchive.class);
    assertThat(archive.as(ServiceActivatorArchive.class).containsServiceActivator(RibbonArchiveImpl.SERVICE_ACTIVATOR_CLASS_NAME)).isFalse();
}
Also used : ServiceActivatorArchive(org.wildfly.swarm.msc.ServiceActivatorArchive) JARArchive(org.wildfly.swarm.spi.api.JARArchive) Test(org.junit.Test)

Aggregations

JARArchive (org.wildfly.swarm.spi.api.JARArchive)84 Deployment (org.jboss.arquillian.container.test.api.Deployment)52 Test (org.junit.Test)25 File (java.io.File)12 ShrinkWrap (org.jboss.shrinkwrap.api.ShrinkWrap)12 Files (java.nio.file.Files)11 ZipExporter (org.jboss.shrinkwrap.api.exporter.ZipExporter)11 Assertions.assertThat (org.fest.assertions.Assertions.assertThat)10 FractionUsageAnalyzer (org.wildfly.swarm.fractions.FractionUsageAnalyzer)10 IOException (java.io.IOException)5 Asset (org.jboss.shrinkwrap.api.asset.Asset)5 ServiceActivatorArchive (org.wildfly.swarm.msc.ServiceActivatorArchive)5 Assertions (org.fest.assertions.Assertions)4 ArchivePath (org.jboss.shrinkwrap.api.ArchivePath)4 Node (org.jboss.shrinkwrap.api.Node)4 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)4 InputStream (java.io.InputStream)3 Map (java.util.Map)3 ZipImporter (org.jboss.shrinkwrap.api.importer.ZipImporter)3 TopologyArchive (org.wildfly.swarm.topology.TopologyArchive)3