use of com.sun.jersey.spi.MessageBodyWorkers in project pentaho-platform by pentaho.
the class JAXRSServletTest method initiateTest.
@Test
public void initiateTest() throws Exception {
ResourceConfig rc = mock(ResourceConfig.class);
HashMap<String, Boolean> features = new HashMap<>();
when(rc.getFeatures()).thenReturn(features);
WebApplication wa = mock(WebApplication.class);
when(jaxrsServlet.getServletConfig()).thenReturn(mock(ServletConfig.class));
MessageBodyWorkers messageBodyWorkers = mock(MessageBodyWorkers.class);
doReturn(messageBodyWorkers).when(wa).getMessageBodyWorkers();
doReturn(null).when(messageBodyWorkers).getWriters(MediaType.WILDCARD_TYPE);
doReturn(mock(ConfigurableApplicationContext.class)).when(jaxrsServlet).getAppContext();
PowerMockito.doNothing().when(jaxrsServlet, "callSuperInitiate", any(), any());
setDebugLogLevel();
jaxrsServlet.initiate(rc, wa);
verify(wa).getMessageBodyWorkers();
Boolean condition = features.get(ResourceConfig.FEATURE_TRACE);
if (condition == null) {
condition = false;
}
assertTrue(condition);
condition = features.get(ResourceConfig.FEATURE_TRACE_PER_REQUEST);
if (condition == null) {
condition = false;
}
assertTrue(condition);
}
use of com.sun.jersey.spi.MessageBodyWorkers in project pentaho-platform by pentaho.
the class JAXRSServlet method initiate.
@SuppressWarnings("unchecked")
@Override
protected void initiate(ResourceConfig rc, WebApplication wa) {
if (logger.isDebugEnabled()) {
rc.getFeatures().put(ResourceConfig.FEATURE_TRACE, true);
rc.getFeatures().put(ResourceConfig.FEATURE_TRACE_PER_REQUEST, true);
}
callSuperInitiate(rc, wa);
if (logger.isDebugEnabled()) {
MessageBodyWorkers messageBodyWorkers = wa.getMessageBodyWorkers();
Map<MediaType, List<MessageBodyWriter>> writers = messageBodyWorkers == null ? null : messageBodyWorkers.getWriters(MediaType.WILDCARD_TYPE);
// $NON-NLS-1$
logger.debug("Writers: " + writers);
}
}
Aggregations