Search in sources :

Example 1 with MessageBodyWorkers

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);
}
Also used : MessageBodyWorkers(com.sun.jersey.spi.MessageBodyWorkers) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) HashMap(java.util.HashMap) WebServletConfig(com.sun.jersey.spi.container.servlet.WebServletConfig) ServletConfig(javax.servlet.ServletConfig) ResourceConfig(com.sun.jersey.api.core.ResourceConfig) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) WebApplication(com.sun.jersey.spi.container.WebApplication) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with MessageBodyWorkers

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);
    }
}
Also used : MessageBodyWorkers(com.sun.jersey.spi.MessageBodyWorkers) MediaType(javax.ws.rs.core.MediaType) List(java.util.List)

Aggregations

MessageBodyWorkers (com.sun.jersey.spi.MessageBodyWorkers)2 ResourceConfig (com.sun.jersey.api.core.ResourceConfig)1 WebApplication (com.sun.jersey.spi.container.WebApplication)1 WebServletConfig (com.sun.jersey.spi.container.servlet.WebServletConfig)1 HashMap (java.util.HashMap)1 List (java.util.List)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 ServletConfig (javax.servlet.ServletConfig)1 MediaType (javax.ws.rs.core.MediaType)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1