Search in sources :

Example 1 with OpenApiServletContextListener

use of org.wildfly.swarm.microprofile.openapi.deployment.OpenApiServletContextListener in project wildfly-swarm by wildfly-swarm.

the class ApimanManagerApiDeploymentTest method testApimanManagerWAR.

@Test
public void testApimanManagerWAR() throws Exception {
    File warFile = Maven.resolver().resolve("io.apiman:apiman-manager-api-war:war:1.3.1.Final").withoutTransitivity().asSingleFile();
    WildFlyConfigBuilder cfgBuilder = new WildFlyConfigBuilder();
    cfgBuilder.addDefaultSources();
    Config cfg = cfgBuilder.build();
    Archive archive = ShrinkWrap.createFromZipFile(JAXRSArchive.class, warFile);
    OpenApiConfig config = new OpenApiConfig(cfg);
    OpenApiDocument.INSTANCE.reset();
    OpenApiDeploymentProcessor processor = new OpenApiDeploymentProcessor(config, archive);
    processor.process();
    new OpenApiServletContextListener().contextInitialized(null);
    String actual = OpenApiSerializer.serialize(OpenApiDocument.INSTANCE.get(), Format.JSON);
    String expected = loadResource(getClass().getResource("testApimanManagerWAR.expected.json"));
    // System.out.println(actual);
    assertJsonEquals(expected, actual);
}
Also used : WildFlyConfigBuilder(org.wildfly.microprofile.config.WildFlyConfigBuilder) Archive(org.jboss.shrinkwrap.api.Archive) JAXRSArchive(org.wildfly.swarm.jaxrs.JAXRSArchive) OpenApiServletContextListener(org.wildfly.swarm.microprofile.openapi.deployment.OpenApiServletContextListener) OpenApiConfig(org.wildfly.swarm.microprofile.openapi.api.OpenApiConfig) Config(org.eclipse.microprofile.config.Config) OpenApiConfig(org.wildfly.swarm.microprofile.openapi.api.OpenApiConfig) File(java.io.File) Test(org.junit.Test)

Example 2 with OpenApiServletContextListener

use of org.wildfly.swarm.microprofile.openapi.deployment.OpenApiServletContextListener in project wildfly-swarm by wildfly-swarm.

the class OpenApiDeploymentProcessorTest method doTest.

/**
 * Common test method.
 * @throws Exception
 */
protected void doTest(Class modelReaderClass, String staticResource, boolean disableAnnotationScanning, Class filterClass, String expectedResource) throws Exception {
    System.setProperty(OASConfig.SCAN_DISABLE, "" + disableAnnotationScanning);
    System.setProperty(OASConfig.MODEL_READER, modelReaderClass != null ? modelReaderClass.getName() : "");
    System.setProperty(OASConfig.FILTER, filterClass != null ? filterClass.getName() : "");
    TestConfig cfg = new TestConfig();
    OpenApiConfig config = new OpenApiConfig(cfg);
    Archive archive = archive(staticResource);
    OpenApiDocument.INSTANCE.reset();
    OpenApiDeploymentProcessor processor = new OpenApiDeploymentProcessor(config, archive);
    processor.process();
    new OpenApiServletContextListener(cfg).contextInitialized(null);
    String actual = OpenApiSerializer.serialize(OpenApiDocument.INSTANCE.get(), Format.JSON);
    String expected = loadResource(getClass().getResource(expectedResource));
    assertJsonEquals(expected, actual);
}
Also used : Archive(org.jboss.shrinkwrap.api.Archive) JAXRSArchive(org.wildfly.swarm.jaxrs.JAXRSArchive) OpenApiServletContextListener(org.wildfly.swarm.microprofile.openapi.deployment.OpenApiServletContextListener) OpenApiConfig(org.wildfly.swarm.microprofile.openapi.api.OpenApiConfig)

Example 3 with OpenApiServletContextListener

use of org.wildfly.swarm.microprofile.openapi.deployment.OpenApiServletContextListener in project wildfly-swarm by wildfly-swarm.

the class ApimanManagerApiDeploymentTest method testApimanGatewayWAR.

@Test
public void testApimanGatewayWAR() throws Exception {
    File warFile = Maven.resolver().resolve("io.apiman:apiman-gateway-platforms-war-wildfly8-api:war:1.3.1.Final").withoutTransitivity().asSingleFile();
    WildFlyConfigBuilder cfgBuilder = new WildFlyConfigBuilder();
    cfgBuilder.addDefaultSources();
    Config cfg = cfgBuilder.build();
    Archive archive = ShrinkWrap.createFromZipFile(JAXRSArchive.class, warFile);
    OpenApiConfig config = new OpenApiConfig(cfg);
    OpenApiDocument.INSTANCE.reset();
    OpenApiDeploymentProcessor processor = new OpenApiDeploymentProcessor(config, archive);
    processor.process();
    new OpenApiServletContextListener().contextInitialized(null);
    String actual = OpenApiSerializer.serialize(OpenApiDocument.INSTANCE.get(), Format.JSON);
    String expected = loadResource(getClass().getResource("testApimanGatewayWAR.expected.json"));
    // System.out.println(actual);
    assertJsonEquals(expected, actual);
}
Also used : WildFlyConfigBuilder(org.wildfly.microprofile.config.WildFlyConfigBuilder) Archive(org.jboss.shrinkwrap.api.Archive) JAXRSArchive(org.wildfly.swarm.jaxrs.JAXRSArchive) OpenApiServletContextListener(org.wildfly.swarm.microprofile.openapi.deployment.OpenApiServletContextListener) OpenApiConfig(org.wildfly.swarm.microprofile.openapi.api.OpenApiConfig) Config(org.eclipse.microprofile.config.Config) OpenApiConfig(org.wildfly.swarm.microprofile.openapi.api.OpenApiConfig) File(java.io.File) Test(org.junit.Test)

Aggregations

Archive (org.jboss.shrinkwrap.api.Archive)3 JAXRSArchive (org.wildfly.swarm.jaxrs.JAXRSArchive)3 OpenApiConfig (org.wildfly.swarm.microprofile.openapi.api.OpenApiConfig)3 OpenApiServletContextListener (org.wildfly.swarm.microprofile.openapi.deployment.OpenApiServletContextListener)3 File (java.io.File)2 Config (org.eclipse.microprofile.config.Config)2 Test (org.junit.Test)2 WildFlyConfigBuilder (org.wildfly.microprofile.config.WildFlyConfigBuilder)2