Search in sources :

Example 31 with JARArchive

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

the class JPATest method testFractionMatching.

@Test
public void testFractionMatching() throws Exception {
    JARArchive archive = ShrinkWrap.create(JARArchive.class);
    archive.addAsResource("META-INF/persistence.xml");
    FractionUsageAnalyzer analyzer = new FractionUsageAnalyzer();
    File out = Files.createTempFile(archive.getName(), ".war").toFile();
    archive.as(ZipExporter.class).exportTo(out, true);
    analyzer.source(out);
    assertThat(analyzer.detectNeededFractions().stream().filter(fd -> fd.getArtifactId().equals("jpa")).count()).isEqualTo(1);
    out.delete();
}
Also used : ExplodedExporter(org.jboss.shrinkwrap.api.exporter.ExplodedExporter) ShrinkWrap(org.jboss.shrinkwrap.api.ShrinkWrap) FractionUsageAnalyzer(org.wildfly.swarm.fractions.FractionUsageAnalyzer) Assertions.assertThat(org.fest.assertions.Assertions.assertThat) Files(java.nio.file.Files) TempFileManager(org.wildfly.swarm.bootstrap.util.TempFileManager) JARArchive(org.wildfly.swarm.spi.api.JARArchive) Test(org.junit.Test) ZipExporter(org.jboss.shrinkwrap.api.exporter.ZipExporter) File(java.io.File) FractionUsageAnalyzer(org.wildfly.swarm.fractions.FractionUsageAnalyzer) ZipExporter(org.jboss.shrinkwrap.api.exporter.ZipExporter) JARArchive(org.wildfly.swarm.spi.api.JARArchive) File(java.io.File) Test(org.junit.Test)

Example 32 with JARArchive

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

the class ArqSecuredManagementInterfaceTest method createDeployment.

@Deployment(testable = false)
public static Archive createDeployment() {
    JARArchive deployment = ShrinkWrap.create(JARArchive.class, "myapp.jar");
    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 33 with JARArchive

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

the class KeycloakArquillianTest method createDeployment.

@Deployment(testable = false)
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 34 with JARArchive

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

the class SecuredTest method testShouldContainOneLoginConfig.

@Test
public void testShouldContainOneLoginConfig() throws Exception {
    JARArchive archive = ShrinkWrap.create(JARArchive.class, "test.jar");
    archive.as(Secured.class).protect("/companies").withRole("default");
    archive.as(Secured.class).protect("/accounts").withRole("manager");
    InputStream assetStream = archive.get(WebXmlAsset.NAME).getAsset().openStream();
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    Document document = factory.newDocumentBuilder().parse(assetStream);
    XPath xpath = XPathFactory.newInstance().newXPath();
    XPathExpression xpr = xpath.compile("count(//web-app/login-config)");
    Number count = (Number) xpr.evaluate(document, XPathConstants.NUMBER);
    Assert.assertEquals("Should have only one login-config element", 1, count.intValue());
}
Also used : XPath(javax.xml.xpath.XPath) XPathExpression(javax.xml.xpath.XPathExpression) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) InputStream(java.io.InputStream) JARArchive(org.wildfly.swarm.spi.api.JARArchive) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 35 with JARArchive

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

the class LoggingArquillianDefaultTest 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)

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