Search in sources :

Example 1 with ApiListingResource

use of io.swagger.jaxrs.listing.ApiListingResource in project swagger-core by swagger-api.

the class ApiListingResourceTest method shouldHandleErrorServletConfig_issue1691.

@Test
public void shouldHandleErrorServletConfig_issue1691() throws JsonProcessingException {
    ServletConfig sc = new ServletConfig() {

        @Override
        public String getServletName() {
            throw new RuntimeException("test_1691");
        }

        @Override
        public ServletContext getServletContext() {
            throw new RuntimeException("test_1691");
        }

        @Override
        public String getInitParameter(String name) {
            throw new RuntimeException("test_1691");
        }

        @Override
        public Enumeration getInitParameterNames() {
            throw new RuntimeException("test_1691");
        }
    };
    ApiListingResource a = new ApiListingResource();
    try {
        a.getListing(null, sc, null, null, "json");
    } catch (RuntimeException e) {
        // test will fail before, no need to mock Response
        if (e.getCause() instanceof ClassNotFoundException) {
            return;
        }
        throw e;
    }
}
Also used : ServletConfig(javax.servlet.ServletConfig) ApiListingResource(io.swagger.jaxrs.listing.ApiListingResource) Test(org.testng.annotations.Test)

Aggregations

ApiListingResource (io.swagger.jaxrs.listing.ApiListingResource)1 ServletConfig (javax.servlet.ServletConfig)1 Test (org.testng.annotations.Test)1