use of org.wildfly.swarm.jaxrs.JAXRSArchive in project wildfly-swarm by wildfly-swarm.
the class OpenApiDeploymentProcessorTest method archive.
/**
* Creates and returns the shrinkwrap archive for this test.
*/
private Archive archive(String staticResource) {
JAXRSArchive archive = ShrinkWrap.create(JAXRSArchive.class, "app.war");
archive.addClass(TestApplication.class);
archive.addClass(HelloResource.class);
if (staticResource != null) {
archive.addAsManifestResource(new UrlAsset(getClass().getResource(staticResource)), "openapi.json");
}
return archive;
}
use of org.wildfly.swarm.jaxrs.JAXRSArchive in project wildfly-swarm by wildfly-swarm.
the class Main method main.
public static void main(String... args) throws Exception {
swarm = new Swarm(args);
swarm.start();
JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class, "myapp.war");
deployment.addClass(MyResource.class);
deployment.setContextRoot("rest");
deployment.addAllDependencies();
swarm.deploy(deployment);
}
use of org.wildfly.swarm.jaxrs.JAXRSArchive in project wildfly-swarm by wildfly-swarm.
the class DefaultApplicationDeploymentProcessorTest method testApplicationPathAnnotation_InWebInfLibArchive.
@Test
public void testApplicationPathAnnotation_InWebInfLibArchive() throws Exception {
JavaArchive subArchive = ShrinkWrap.create(JavaArchive.class, "mysubarchive.jar");
subArchive.addClass(MySampleApplication.class);
JAXRSArchive archive = ShrinkWrap.create(JAXRSArchive.class);
archive.addAsLibrary(subArchive);
DefaultApplicationDeploymentProcessor processor = new DefaultApplicationDeploymentProcessor(archive);
processor.process();
Node generated = archive.get(PATH);
assertThat(generated).isNull();
}
use of org.wildfly.swarm.jaxrs.JAXRSArchive in project wildfly-swarm by wildfly-swarm.
the class DefaultApplicationDeploymentProcessorTest method testApplicationPathAnnotation_SpecifiedInProjectDefaults.
@Test
public void testApplicationPathAnnotation_SpecifiedInProjectDefaults() throws Exception {
JAXRSArchive archive = ShrinkWrap.create(JAXRSArchive.class, "app.war");
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);
Asset asset = generated.getAsset();
assertThat(generated).isNotNull();
assertThat(asset).isNotNull();
}
use of org.wildfly.swarm.jaxrs.JAXRSArchive in project wildfly-swarm by wildfly-swarm.
the class DefaultApplicationDeploymentProcessorTest method testApplicationPathAnnotation_None_And_ChangeThePath.
@Test
public void testApplicationPathAnnotation_None_And_ChangeThePath() throws Exception {
String applicationPath = "/api";
JAXRSArchive archive = ShrinkWrap.create(JAXRSArchive.class);
DefaultApplicationDeploymentProcessor processor = new DefaultApplicationDeploymentProcessor(archive);
processor.applicationPath.set(applicationPath);
processor.process();
try (InputStream in = archive.get(PATH).getAsset().openStream()) {
ClassReader reader = new ClassReader(in);
ClassNode node = new ClassNode();
reader.accept(node, 0);
List<AnnotationNode> visibleAnnotations = node.visibleAnnotations;
assertThat(visibleAnnotations.size()).isEqualTo(1);
assertThat(visibleAnnotations.get(0).values).contains(applicationPath);
} catch (IOException ignored) {
}
}
Aggregations