Java Code Examples for org.wildfly.swarm.jaxrs.JAXRSArchive#get()

The following examples show how to use org.wildfly.swarm.jaxrs.JAXRSArchive#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultApplicationDeploymentProcessorTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Test
public void testApplicationPathAnnotation_SpecifiedInProjectDefaults() throws Exception {
    JAXRSArchive archive = ShrinkWrap.create(JAXRSArchive.class, "app.war");
    DefaultApplicationDeploymentProcessor processor = new DefaultApplicationDeploymentProcessor(archive);
    processor.applicationPath.set("/api-test"); // Simulate the behavior of loading the project defaults.
    processor.process();

    Node generated = archive.get(PATH);
    Asset asset = generated.getAsset();

    assertThat(generated).isNotNull();
    assertThat(asset).isNotNull();
}
 
Example 2
Source File: DefaultApplicationDeploymentProcessorTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Test
public void testApplicationPathAnnotation_DirectlyInArchive() throws Exception {
    JAXRSArchive archive = ShrinkWrap.create(JAXRSArchive.class);
    archive.addClass(MySampleApplication.class);
    DefaultApplicationDeploymentProcessor processor = new DefaultApplicationDeploymentProcessor(archive);

    processor.process();

    Node generated = archive.get(PATH);
    assertThat(generated).isNull();
}
 
Example 3
Source File: DefaultApplicationDeploymentProcessorTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example 4
Source File: DefaultApplicationDeploymentProcessorTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Test
public void testWebXmlApplicationServletMappingPresent() throws Exception {
    JAXRSArchive archive = ShrinkWrap.create(JAXRSArchive.class);
    archive.addClass(MyResource.class);
    archive.setWebXML(new StringAsset(
            "<web-app><servlet-mapping><servlet-name>Faces Servlet</servlet-name><url-pattern>*.jsf</url-pattern></servlet-mapping><servlet-mapping><servlet-name>javax.ws.rs.core.Application</servlet-name><url-pattern>/foo/*</url-pattern></servlet-mapping></web-app>"));
    DefaultApplicationDeploymentProcessor processor = new DefaultApplicationDeploymentProcessor(archive);

    processor.process();

    Node generated = archive.get(PATH);
    assertThat(generated).isNull();
}
 
Example 5
Source File: DefaultApplicationDeploymentProcessorTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@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);
    processor.applicationPath.set("/api-test"); // Simulate the behavior of loading the project defaults.

    processor.process();

    Node generated = archive.get(PATH);
    assertThat(generated).isNotNull();
}
 
Example 6
Source File: DefaultApplicationDeploymentProcessorTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@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);
    processor.applicationPath.set("/api-test"); // Simulate the behavior of loading the project defaults.

    processor.process();

    Node generated = archive.get(PATH);
    assertThat(generated).isNotNull();
}