new ProvidersRegistry(new LifecycleManagersRegistry(), new ApplicationValidator());
return providers;
}
public void testMessageBodyWriters() {
ProvidersRegistry providers = createProvidersRegistryImpl();
ByteArrayProvider byteArrayProvider = new ByteArrayProvider();
InputStreamProvider inputStreamProvider = new InputStreamProvider();
StringProvider stringProvider = new StringProvider();
String2Provider string2Provider = new String2Provider();
FileProvider fileProvider = new FileProvider();
IntegerMessageBodyProvider objectMessageBodyProvider = new IntegerMessageBodyProvider();
providers.addProvider(byteArrayProvider, WinkApplication.SYSTEM_PRIORITY);
providers.addProvider(inputStreamProvider, WinkApplication.SYSTEM_PRIORITY);
providers.addProvider(string2Provider);
providers.addProvider(stringProvider, WinkApplication.SYSTEM_PRIORITY);
providers.addProvider(fileProvider, WinkApplication.SYSTEM_PRIORITY);
providers.addProvider(objectMessageBodyProvider);
assertEquals(byteArrayProvider, providers
.getMessageBodyReader(byte[].class, null, null, MediaType.APPLICATION_JSON_TYPE, null));
assertEquals(string2Provider, providers.getMessageBodyReader(String.class,
null,
null,
MediaType.WILDCARD_TYPE,
null));
assertEquals(fileProvider, providers
.getMessageBodyReader(File.class, null, null, MediaType.APPLICATION_SVG_XML_TYPE, null));
assertEquals(byteArrayProvider, providers
.getMessageBodyWriter(byte[].class,
null,
null,
MediaType.APPLICATION_ATOM_XML_TYPE,
null));
// string2Provider is favored over stringProvider because it is a
// user-defined provider
assertEquals(string2Provider, providers.getMessageBodyWriter(String.class,
null,
null,
MediaType.WILDCARD_TYPE,
null));
assertEquals(fileProvider, providers
.getMessageBodyWriter(File.class, null, null, MediaType.APPLICATION_SVG_XML_TYPE, null));
assertEquals(IntegerMessageBodyProvider.class, providers
.getMessageBodyWriter(Integer.class, null, null, MediaType.WILDCARD_TYPE, null)
.getClass());
}