Search in sources :

Example 16 with JAXRSArchive

use of org.wildfly.swarm.jaxrs.JAXRSArchive in project wildfly-swarm by wildfly-swarm.

the class DefaultApplicationDeploymentProcessorTest method testMalformedWebXmlApplicationServletMappingAbsent.

@Test
public void testMalformedWebXmlApplicationServletMappingAbsent() throws Exception {
    JAXRSArchive archive = ShrinkWrap.create(JAXRSArchive.class);
    archive.addClass(MyResource.class);
    archive.setWebXML(new StringAsset("blablabla"));
    DefaultApplicationDeploymentProcessor processor = new DefaultApplicationDeploymentProcessor(archive);
    // Simulate the behavior of loading the project defaults.
    processor.applicationPath.set("/api-test");
    processor.process();
    Node generated = archive.get(PATH);
    assertThat(generated).isNotNull();
}
Also used : StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) AnnotationNode(org.objectweb.asm.tree.AnnotationNode) Node(org.jboss.shrinkwrap.api.Node) ClassNode(org.objectweb.asm.tree.ClassNode) JAXRSArchive(org.wildfly.swarm.jaxrs.JAXRSArchive) Test(org.junit.Test)

Example 17 with JAXRSArchive

use of org.wildfly.swarm.jaxrs.JAXRSArchive in project wildfly-swarm by wildfly-swarm.

the class DefaultApplicationDeploymentProcessorTest method testWebXmlApplicationServletMappingAbsent.

@Test
public void testWebXmlApplicationServletMappingAbsent() throws Exception {
    JAXRSArchive archive = ShrinkWrap.create(JAXRSArchive.class);
    archive.addClass(MyResource.class);
    archive.setWebXML(new StringAsset("<web-app><display-name>Foo</display-name></web-app>"));
    DefaultApplicationDeploymentProcessor processor = new DefaultApplicationDeploymentProcessor(archive);
    // Simulate the behavior of loading the project defaults.
    processor.applicationPath.set("/api-test");
    processor.process();
    Node generated = archive.get(PATH);
    assertThat(generated).isNotNull();
}
Also used : StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) AnnotationNode(org.objectweb.asm.tree.AnnotationNode) Node(org.jboss.shrinkwrap.api.Node) ClassNode(org.objectweb.asm.tree.ClassNode) JAXRSArchive(org.wildfly.swarm.jaxrs.JAXRSArchive) Test(org.junit.Test)

Example 18 with JAXRSArchive

use of org.wildfly.swarm.jaxrs.JAXRSArchive in project wildfly-swarm by wildfly-swarm.

the class FractionUsageAnalyzerTest method testExplodedFractionMatching.

@Test
public void testExplodedFractionMatching() throws Exception {
    JAXRSArchive archive = ShrinkWrap.create(JAXRSArchive.class);
    archive.addClass(MyResource.class);
    FractionUsageAnalyzer analyzer = new FractionUsageAnalyzer();
    File dirFile = TempFileManager.INSTANCE.newTempDirectory("fractionusagetest", null);
    archive.as(ExplodedExporter.class).exportExplodedInto(dirFile);
    analyzer.source(dirFile);
    assertThat(analyzer.detectNeededFractions().stream().filter(fd -> fd.getArtifactId().equals("jaxrs")).count()).isEqualTo(1);
}
Also used : ShrinkWrap(org.jboss.shrinkwrap.api.ShrinkWrap) EmptyAsset(org.jboss.shrinkwrap.api.asset.EmptyAsset) Files(java.nio.file.Files) TemporalField(java.time.temporal.TemporalField) Test(org.junit.Test) ZipExporter(org.jboss.shrinkwrap.api.exporter.ZipExporter) File(java.io.File) ExplodedExporter(org.jboss.shrinkwrap.api.exporter.ExplodedExporter) JAXRSArchive(org.wildfly.swarm.jaxrs.JAXRSArchive) Assertions.assertThat(org.fest.assertions.Assertions.assertThat) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) TempFileManager(org.wildfly.swarm.bootstrap.util.TempFileManager) After(org.junit.After) JAXRSArchive(org.wildfly.swarm.jaxrs.JAXRSArchive) ExplodedExporter(org.jboss.shrinkwrap.api.exporter.ExplodedExporter) File(java.io.File) Test(org.junit.Test)

Example 19 with JAXRSArchive

use of org.wildfly.swarm.jaxrs.JAXRSArchive in project wildfly-swarm by wildfly-swarm.

the class DroolsDeploymentProducer method droolsWar.

@Produces
public Archive droolsWar() throws Exception {
    if (System.getProperty("org.drools.server.swarm.web.conf") == null) {
        // Path dir = Files.createTempDirectory("swarm-keycloak-config");
        File dir = TempFileManager.INSTANCE.newTempDirectory("swarm-drools-web-config", ".d");
        System.setProperty("org.drools.server.swarm.conf", dir.getAbsolutePath());
        Files.copy(getClass().getClassLoader().getResourceAsStream("config/web/web.xml"), dir.toPath().resolve("web.xml"), StandardCopyOption.REPLACE_EXISTING);
        Files.copy(getClass().getClassLoader().getResourceAsStream("config/web/jboss-web.xml"), dir.toPath().resolve("jboss-web.xml"), StandardCopyOption.REPLACE_EXISTING);
        configFolder = dir.toPath().toString();
    }
    DroolsMessages.MESSAGES.configurationDirectory(configFolder);
    JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class, "drools-server.war");
    deployment.addAllDependencies();
    deployment.addAsWebInfResource(new File(configFolder + "/web.xml"), "web.xml");
    deployment.addAsWebInfResource(new File(configFolder + "/jboss-web.xml"), "jboss-web.xml");
    return deployment;
}
Also used : JAXRSArchive(org.wildfly.swarm.jaxrs.JAXRSArchive) File(java.io.File) Produces(javax.enterprise.inject.Produces)

Example 20 with JAXRSArchive

use of org.wildfly.swarm.jaxrs.JAXRSArchive in project wildfly-swarm by wildfly-swarm.

the class SwaggerArchivePreparerTest method testWithSwaggerConfInRoot.

@Test
public void testWithSwaggerConfInRoot() {
    JAXRSArchive archive = ShrinkWrap.create(JAXRSArchive.class);
    archive.addResource(MyResource.class);
    archive.addResource(MyOtherResource.class);
    archive.add(new ByteArrayAsset("packages: com.myapp.mysubstuff".getBytes()), "META-INF/swarm.swagger.conf");
    SwaggerArchivePreparer preparer = new SwaggerArchivePreparer(archive);
    preparer.process();
    SwaggerArchive swaggerArchive = archive.as(SwaggerArchive.class);
    assertThat(swaggerArchive.getResourcePackages()).containsOnly("com.myapp.mysubstuff");
}
Also used : ByteArrayAsset(org.jboss.shrinkwrap.api.asset.ByteArrayAsset) JAXRSArchive(org.wildfly.swarm.jaxrs.JAXRSArchive) SwaggerArchive(org.wildfly.swarm.swagger.SwaggerArchive) Test(org.junit.Test)

Aggregations

JAXRSArchive (org.wildfly.swarm.jaxrs.JAXRSArchive)21 Test (org.junit.Test)12 AnnotationNode (org.objectweb.asm.tree.AnnotationNode)7 ClassNode (org.objectweb.asm.tree.ClassNode)7 File (java.io.File)6 Node (org.jboss.shrinkwrap.api.Node)6 Deployment (org.jboss.arquillian.container.test.api.Deployment)5 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)4 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)3 SwaggerArchive (org.wildfly.swarm.swagger.SwaggerArchive)3 Files (java.nio.file.Files)2 TemporalField (java.time.temporal.TemporalField)2 Assertions.assertThat (org.fest.assertions.Assertions.assertThat)2 ShrinkWrap (org.jboss.shrinkwrap.api.ShrinkWrap)2 ByteArrayAsset (org.jboss.shrinkwrap.api.asset.ByteArrayAsset)2 EmptyAsset (org.jboss.shrinkwrap.api.asset.EmptyAsset)2 ExplodedExporter (org.jboss.shrinkwrap.api.exporter.ExplodedExporter)2 ZipExporter (org.jboss.shrinkwrap.api.exporter.ZipExporter)2 After (org.junit.After)2 TempFileManager (org.wildfly.swarm.bootstrap.util.TempFileManager)2