@Test
@UseDataProvider("messageBodyWriterByTypeAndMediaType")
public void retrievesMessageBodyWriterByTypeAndMediaType(boolean singletonOrPerRequest,
                                                         Class<?> writeObjectType,
                                                         Type writeObjectGenericType,
                                                         MediaType mediaType,
                                                         Object expectedMessageBodyWriterClassOrInstance) throws Exception {

    if (singletonOrPerRequest == SINGLETON) {
        registerSingletonMessageBodyWriters();
    } else {
        registerPerRequestMessageBodyWriters();
    }
    MessageBodyWriter messageBodyWriter = providers.getMessageBodyWriter(writeObjectType, writeObjectGenericType, null, mediaType);
    if (singletonOrPerRequest == SINGLETON) {
        assertSame(expectedMessageBodyWriterClassOrInstance, messageBodyWriter);
    } else {
        if (expectedMessageBodyWriterClassOrInstance == null) {
            assertNull(messageBodyWriter);
        } else {
            assertNotNull(messageBodyWriter);
            assertEquals(expectedMessageBodyWriterClassOrInstance, messageBodyWriter.getClass());
        }
    }
}