ApplicationProviderBinder extends ProviderBinder { @Override public <T> MessageBodyWriter<T> getMessageBodyWriter(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType) { MessageBodyWriter<T> writer = doGetMessageBodyWriter(type, genericType, annotations, mediaType); if (writer == null) { writer = getDefaults().getMessageBodyWriter(type, genericType, annotations, mediaType); } return writer; }  @Override List<MediaType> getAcceptableWriterMediaTypes(Class<?> type, Type genericType, Annotation[] annotations); @Override ContextResolver<T> getContextResolver(Class<T> contextType, MediaType mediaType); @Override ExceptionMapper<T> getExceptionMapper(Class<T> type); @Override MessageBodyReader<T> getMessageBodyReader(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override MessageBodyWriter<T> getMessageBodyWriter(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override List<MethodInvokerFilter> getMethodInvokerFilters(String path); @Override List<RequestFilter> getRequestFilters(String path); @Override List<ResponseFilter> getResponseFilters(String path);  }
@Test public void retrievesMessageBodyWriterByTypeAndMediaType() { MessageBodyWriter<String> stringMessageBodyWriter = new StringEntityProvider(); applicationProviders.addMessageBodyWriter(stringMessageBodyWriter); assertSame(stringMessageBodyWriter, applicationProviders.getMessageBodyWriter(String.class, null, null, TEXT_PLAIN_TYPE)); }
@Test public void retrievesMessageBodyWriterFromEmbeddedProviderBinderByTypeAndMediaTypeWhenRequiredMessageBodyWriterIsNotAvailableInApplicationProviderBinder() { MessageBodyWriter<String> stringMessageBodyWriter = mock(MessageBodyWriter.class); when(applicationProviders.getMessageBodyWriter(String.class, null, null, TEXT_PLAIN_TYPE)).thenReturn(stringMessageBodyWriter); assertSame(stringMessageBodyWriter, applicationProviders.getMessageBodyWriter(String.class, null, null, TEXT_PLAIN_TYPE)); }