use of io.swagger.jaxrs.config.SwaggerContextService in project swagger-core by swagger-api.
the class SwaggerContextServiceTest method initConfigViaContextParamSwagger.
@Test(description = "should get correct swagger context set via context param \"swagger\"")
public void initConfigViaContextParamSwagger() {
stubWithContextSwaggerAttribute();
Swagger swagger = new SwaggerContextService().withServletConfig(servletConfig1).getSwagger();
assertEquals("Test Title", swagger.getInfo().getTitle());
//verify(servletConfig1, times(2)).getInitParameter(eq(CONTEXT_ID_KEY));
}
use of io.swagger.jaxrs.config.SwaggerContextService in project swagger-core by swagger-api.
the class SwaggerContextServiceTest method initializeAndGetConfigBasedOnPath.
@Test(description = "should add SwaggerConfig to SwaggerConfigLocator map with keys path-based keys")
public void initializeAndGetConfigBasedOnPath() {
stubWithPathBasedConfigInitParam();
new SwaggerContextService().withServletConfig(servletConfig1).withBasePath("/url1").initConfig();
new SwaggerContextService().withServletConfig(servletConfig2).withBasePath("url2").initConfig();
assertTrue(SwaggerConfigLocator.getInstance().getConfig(CONFIG_ID_PREFIX + "/url1/") instanceof WebXMLReader);
assertTrue(SwaggerConfigLocator.getInstance().getConfig(CONFIG_ID_PREFIX + "/url2/") instanceof WebXMLReader);
verify(servletConfig1, times(1)).getInitParameter(eq(USE_PATH_BASED_CONFIG));
verify(servletConfig2, times(1)).getInitParameter(eq(USE_PATH_BASED_CONFIG));
}
use of io.swagger.jaxrs.config.SwaggerContextService in project swagger-core by swagger-api.
the class SwaggerContextServiceTest method getScannerWithContextInitParam.
@Test(description = "should call servletContext getAttribute with param SCANNER_ID_PREFIX + \"test.1/2\"")
public void getScannerWithContextInitParam() {
stubWithContextInitParam();
Scanner scanner1 = new SwaggerContextService().withServletConfig(servletConfig1).getScanner();
Scanner scanner2 = new SwaggerContextService().withServletConfig(servletConfig2).getScanner();
assertEquals(beanConfigScanner1, scanner1);
assertEquals(beanConfigScanner2, scanner2);
verify(servletConfig1, times(1)).getInitParameter(eq(SCANNER_ID_KEY));
verify(servletConfig1, times(2)).getInitParameter(eq(CONTEXT_ID_KEY));
verify(servletContext1, times(1)).getAttribute(eq(SCANNER_ID_PREFIX + "test.1"));
verify(servletContext2, never()).getAttribute(eq(SCANNER_ID_PREFIX + "test.1"));
verify(servletConfig2, times(1)).getInitParameter(eq(SCANNER_ID_KEY));
verify(servletConfig2, times(2)).getInitParameter(eq(CONTEXT_ID_KEY));
verify(servletContext2, times(1)).getAttribute(eq(SCANNER_ID_PREFIX + "test.2"));
verify(servletContext1, never()).getAttribute(eq(SCANNER_ID_PREFIX + "test.2"));
}
Aggregations