RestServlet servlet =
(RestServlet)Class.forName("org.apache.wink.server.internal.servlet.RestServlet")
.newInstance();
String requestProcessorAttribute = "MOCK_REQUEST_PROCESSOR";
DeploymentConfiguration configuration = new DeploymentConfiguration();
configuration.init();
RequestProcessor requestProcessor = new RequestProcessor(configuration);
MockServletContext servletContext = new MockServletContext();
servletContext.setAttribute(requestProcessorAttribute, requestProcessor);
MockServletConfig servletConfig = new MockServletConfig(servletContext);
servletConfig.addInitParameter("javax.ws.rs.Application", getApplicationClassName());
servletConfig.addInitParameter("requestProcessorAttribute", requestProcessorAttribute);
String propertiesFile = getPropertiesFile();
if (propertiesFile != null) {
servletConfig.addInitParameter("propertiesLocation", propertiesFile);
}
assertNull(configuration.getServletContext());
assertNull(configuration.getServletConfig());
ThreadLocal<MockServletInvocationTest> tls = new ThreadLocal<MockServletInvocationTest>();
tls.set(this);
servlet.init(servletConfig);
DeploymentConfiguration servletConfiguration =
servlet.getRequestProcessor().getConfiguration();
assertEquals(configuration, servletConfiguration);
assertNotNull(servletConfiguration.getServletContext());
assertNotNull(servletConfiguration.getServletConfig());
}