Search in sources :

Example 1 with JARArchive

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

the class KeycloakThemesCustomizer method customize.

@Override
public void customize() throws ModuleLoadException, IOException {
    if (!this.keycloakServer.subresources().themes().isEmpty()) {
        return;
    }
    Module module = Module.getBootModuleLoader().loadModule("org.keycloak.keycloak-themes");
    URL resource = module.getExportedResource("keycloak-themes.jar");
    JARArchive themesArtifact = ShrinkWrap.create(JARArchive.class);
    themesArtifact.as(ZipImporter.class).importFrom(resource.openStream());
    File root = TempFileManager.INSTANCE.newTempDirectory("keycloak-themes", ".d");
    File exportedDir = themesArtifact.as(ExplodedExporter.class).exportExplodedInto(root);
    File themeDir = new File(exportedDir, "theme");
    this.keycloakServer.theme("defaults", (theme) -> {
        theme.dir(themeDir.getAbsolutePath());
        theme.staticmaxage(2592000L);
        theme.cachethemes(true);
        theme.cachetemplates(true);
    });
}
Also used : ZipImporter(org.jboss.shrinkwrap.api.importer.ZipImporter) JARArchive(org.wildfly.swarm.spi.api.JARArchive) Module(org.jboss.modules.Module) ExplodedExporter(org.jboss.shrinkwrap.api.exporter.ExplodedExporter) File(java.io.File) URL(java.net.URL)

Example 2 with JARArchive

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

the class TopologyArchiveTest method testMultipleCastingToTopologyArchive.

@Test
public void testMultipleCastingToTopologyArchive() {
    JARArchive archive = ShrinkWrap.create(JARArchive.class);
    archive.as(TopologyArchive.class).advertise("foo");
    assertThat(archive.as(TopologyArchive.class).advertisements()).hasSize(1);
    assertThat(archive.as(TopologyArchive.class).advertisements()).contains("foo");
}
Also used : JARArchive(org.wildfly.swarm.spi.api.JARArchive) Test(org.junit.Test)

Example 3 with JARArchive

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

the class CreateSOAPInVmTest 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 4 with JARArchive

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

the class SimpleCoreTransformTest method deployment.

@Deployment
public static JARArchive deployment() {
    JARArchive archive = ShrinkWrap.create(JARArchive.class);
    archive.addAsResource("spring/simple-camel-context.xml");
    archive.addClasses(RouteBuilderA.class);
    return archive;
}
Also used : JARArchive(org.wildfly.swarm.spi.api.JARArchive) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 5 with JARArchive

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

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