use of javax.servlet.ServletConfig in project metrics by dropwizard.
the class HealthCheckServletTest method constructorWithRegistryAsArgumentUsesServletConfigWhenNull.
@Test
public void constructorWithRegistryAsArgumentUsesServletConfigWhenNull() throws Exception {
final HealthCheckRegistry healthCheckRegistry = mock(HealthCheckRegistry.class);
final ServletContext servletContext = mock(ServletContext.class);
final ServletConfig servletConfig = mock(ServletConfig.class);
when(servletConfig.getServletContext()).thenReturn(servletContext);
when(servletContext.getAttribute(eq(HealthCheckServlet.HEALTH_CHECK_REGISTRY))).thenReturn(healthCheckRegistry);
final HealthCheckServlet healthCheckServlet = new HealthCheckServlet(null);
healthCheckServlet.init(servletConfig);
verify(servletConfig, times(1)).getServletContext();
verify(servletContext, times(1)).getAttribute(eq(HealthCheckServlet.HEALTH_CHECK_REGISTRY));
}
use of javax.servlet.ServletConfig in project metrics by dropwizard.
the class MetricsServletTest method constructorWithRegistryAsArgumentUsesServletConfigWhenNull.
@Test
public void constructorWithRegistryAsArgumentUsesServletConfigWhenNull() throws Exception {
final MetricRegistry metricRegistry = mock(MetricRegistry.class);
final ServletContext servletContext = mock(ServletContext.class);
final ServletConfig servletConfig = mock(ServletConfig.class);
when(servletConfig.getServletContext()).thenReturn(servletContext);
when(servletContext.getAttribute(eq(MetricsServlet.METRICS_REGISTRY))).thenReturn(metricRegistry);
final MetricsServlet metricsServlet = new MetricsServlet(null);
metricsServlet.init(servletConfig);
verify(servletConfig, times(1)).getServletContext();
verify(servletContext, times(1)).getAttribute(eq(MetricsServlet.METRICS_REGISTRY));
}
use of javax.servlet.ServletConfig in project cxf by apache.
the class JAXRSUtilsTest method testServletContextParameters.
@Test
public void testServletContextParameters() throws Exception {
ClassResourceInfo cri = new ClassResourceInfo(Customer.class, true);
OperationResourceInfo ori = new OperationResourceInfo(Customer.class.getMethod("testServletParams", new Class[] { HttpServletRequest.class, HttpServletResponse.class, ServletContext.class, ServletConfig.class }), cri);
ori.setHttpMethod("GET");
HttpServletRequest request = EasyMock.createMock(HttpServletRequest.class);
HttpServletResponse response = new HttpServletResponseFilter(EasyMock.createMock(HttpServletResponse.class), null);
ServletContext context = EasyMock.createMock(ServletContext.class);
ServletConfig config = EasyMock.createMock(ServletConfig.class);
EasyMock.replay(request);
EasyMock.replay(context);
EasyMock.replay(config);
Message m = createMessage();
m.put(AbstractHTTPDestination.HTTP_REQUEST, request);
m.put(AbstractHTTPDestination.HTTP_RESPONSE, response);
m.put(AbstractHTTPDestination.HTTP_CONTEXT, context);
m.put(AbstractHTTPDestination.HTTP_CONFIG, config);
List<Object> params = JAXRSUtils.processParameters(ori, new MetadataMap<String, String>(), m);
assertEquals("4 parameters expected", 4, params.size());
assertSame(request.getClass(), ((HttpServletRequestFilter) params.get(0)).getRequest().getClass());
assertSame(response.getClass(), params.get(1).getClass());
assertSame(context.getClass(), params.get(2).getClass());
assertSame(config.getClass(), params.get(3).getClass());
}
use of javax.servlet.ServletConfig in project cxf by apache.
the class MessageContextImplTest method testServletConfig.
@Test
public void testServletConfig() {
Message m = createMessage();
MessageContext mc = new MessageContextImpl(m);
ServletConfig request = EasyMock.createMock(ServletConfig.class);
m.put(AbstractHTTPDestination.HTTP_CONFIG, request);
assertSame(request.getClass(), mc.getServletConfig().getClass());
assertSame(request.getClass(), mc.getContext(ServletConfig.class).getClass());
}
use of javax.servlet.ServletConfig in project Lucee by lucee.
the class Admin method doGetInfo.
private void doGetInfo() throws PageException {
Struct sct = new StructImpl();
pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
if (config instanceof ConfigWebImpl) {
ConfigWebImpl cw = (ConfigWebImpl) config;
sct.setEL(KeyConstants._id, cw.getIdentification().getId());
sct.setEL(KeyConstants._label, cw.getLabel());
sct.setEL(KeyConstants._hash, cw.getHash());
sct.setEL(KeyConstants._root, cw.getRootDirectory().getAbsolutePath());
sct.setEL("configServerDir", cw.getConfigServerDir().getAbsolutePath());
sct.setEL("configWebDir", cw.getConfigDir().getAbsolutePath());
} else {
sct.setEL("configServerDir", config.getConfigDir().getAbsolutePath());
sct.setEL("configWebDir", pageContext.getConfig().getConfigDir().getAbsolutePath());
}
sct.setEL(KeyConstants._config, config.getConfigFile().getAbsolutePath());
// Servlets
if (config instanceof ConfigServer) {
ConfigServer cs = (ConfigServer) config;
CFMLEngineImpl engine = (CFMLEngineImpl) cs.getCFMLEngine();
Struct srv = new StructImpl(), params;
ServletConfig[] configs = engine.getServletConfigs();
ServletConfig sc;
Enumeration e;
String name, value;
for (int i = 0; i < configs.length; i++) {
sc = configs[i];
e = sc.getInitParameterNames();
params = new StructImpl();
while (e.hasMoreElements()) {
name = (String) e.nextElement();
value = sc.getInitParameter(name);
params.set(name, value);
}
srv.set(sc.getServletName(), params);
}
sct.set("servlets", srv);
}
// sct.setEL("javaAgentSupported", Caster.toBoolean(InstrumentationUtil.isSupported()));
sct.setEL("javaAgentSupported", Boolean.TRUE);
// sct.setEL("javaAgentPath", ClassUtil.getSourcePathForClass("lucee.runtime.instrumentation.Agent", ""));
}
Aggregations