use of com.github.tomakehurst.wiremock.http.AdminRequestHandler in project wiremock by wiremock.
the class JettyHttpServer method addAdminContext.
private ServletContextHandler addAdminContext(AdminRequestHandler adminRequestHandler, Notifier notifier) {
ServletContextHandler adminContext = new ServletContextHandler(jettyServer, ADMIN_CONTEXT_ROOT);
adminContext.setInitParameter("org.eclipse.jetty.servlet.Default.maxCacheSize", "0");
String javaVendor = System.getProperty("java.vendor");
if (javaVendor != null && javaVendor.toLowerCase().contains("android")) {
// Special case for Android, fixes IllegalArgumentException("resource assets not found."):
// The Android ClassLoader apparently does not resolve directories.
// Furthermore, lib assets will be merged into a single asset directory when a jar file is
// assimilated into an apk.
// As resources can be addressed like "assets/swagger-ui/index.html", a static path element
// will suffice.
adminContext.setInitParameter("org.eclipse.jetty.servlet.Default.resourceBase", "assets");
} else {
adminContext.setInitParameter("org.eclipse.jetty.servlet.Default.resourceBase", Resources.getResource("assets").toString());
}
Resources.getResource("assets/swagger-ui/index.html");
adminContext.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
ServletHolder swaggerUiServletHolder = adminContext.addServlet(DefaultServlet.class, "/swagger-ui/*");
swaggerUiServletHolder.setAsyncSupported(false);
adminContext.addServlet(DefaultServlet.class, "/recorder/*");
ServletHolder servletHolder = adminContext.addServlet(WireMockHandlerDispatchingServlet.class, "/");
servletHolder.setInitParameter(RequestHandler.HANDLER_CLASS_KEY, AdminRequestHandler.class.getName());
adminContext.setAttribute(AdminRequestHandler.class.getName(), adminRequestHandler);
adminContext.setAttribute(Notifier.KEY, notifier);
adminContext.setAttribute(MultipartRequestConfigurer.KEY, buildMultipartRequestConfigurer());
addCorsFilter(adminContext);
return adminContext;
}
use of com.github.tomakehurst.wiremock.http.AdminRequestHandler in project wiremock by wiremock.
the class JettyHttpServerTest method init.
@BeforeEach
public void init() {
Admin admin = Mockito.mock(Admin.class);
adminRequestHandler = new AdminRequestHandler(AdminRoutes.defaults(), admin, new BasicResponseRenderer(), new NoAuthenticator(), false, Collections.<RequestFilter>emptyList());
stubRequestHandler = new StubRequestHandler(Mockito.mock(StubServer.class), Mockito.mock(ResponseRenderer.class), admin, Collections.<String, PostServeAction>emptyMap(), Mockito.mock(RequestJournal.class), Collections.<RequestFilter>emptyList(), false);
}
use of com.github.tomakehurst.wiremock.http.AdminRequestHandler in project wiremock by wiremock.
the class AdminRequestHandlerTest method init.
@BeforeEach
public void init() {
httpResponder = new MockHttpResponder();
handler = new AdminRequestHandler(AdminRoutes.defaults(), admin, new BasicResponseRenderer(), new NoAuthenticator(), false, Collections.<RequestFilter>emptyList());
}
Aggregations