use of org.glassfish.jersey.internal.inject.InjectionManager in project jersey by jersey.
the class CommonConfigTest method testConfigureFeatureInstanceRecursive.
@Test
public void testConfigureFeatureInstanceRecursive() throws Exception {
config.register(new RecursiveInstanceFeature());
InjectionManager injectionManager = Injections.createInjectionManager();
config.configureMetaProviders(injectionManager);
assertEquals(0, config.getClasses().size());
assertEquals(2, config.getInstances().size());
final Set<Object> pureProviders = config.getComponentBag().getInstances(ComponentBag.excludeMetaProviders(injectionManager));
assertEquals(1, pureProviders.size());
assertSame(CustomReaderA.class, pureProviders.iterator().next().getClass());
}
use of org.glassfish.jersey.internal.inject.InjectionManager in project jersey by jersey.
the class CommonConfigTest method testProviderOrderManual.
@Test
public void testProviderOrderManual() throws Exception {
final InjectionManager injectionManager = Injections.createInjectionManager();
config.register(MidPriorityProvider.class, 500);
config.register(LowPriorityProvider.class, 20);
config.register(HighPriorityProvider.class, 150);
ProviderBinder.bindProviders(config.getComponentBag(), injectionManager);
final Iterable<WriterInterceptor> allProviders = Providers.getAllProviders(injectionManager, WriterInterceptor.class, new RankedComparator<>());
final Iterator<WriterInterceptor> iterator = allProviders.iterator();
assertEquals(LowPriorityProvider.class, iterator.next().getClass());
assertEquals(HighPriorityProvider.class, iterator.next().getClass());
assertEquals(MidPriorityProvider.class, iterator.next().getClass());
assertFalse(iterator.hasNext());
}
use of org.glassfish.jersey.internal.inject.InjectionManager in project jersey by jersey.
the class ProviderBinderTest method testProvidersMbwInstance.
@Test
public void testProvidersMbwInstance() {
InjectionManager injectionManager = Injections.createInjectionManager(initBinders());
ProviderBinder providerBinder = new ProviderBinder(injectionManager);
providerBinder.bindInstances(Collections.singleton(new MyProvider()));
Set<MessageBodyWriter> providers = Providers.getCustomProviders(injectionManager, MessageBodyWriter.class);
assertEquals(instancesOfType(MyProvider.class, providers).size(), 1);
}
use of org.glassfish.jersey.internal.inject.InjectionManager in project jersey by jersey.
the class ProviderBinderTest method testServicesMbr.
@Test
public void testServicesMbr() {
InjectionManager injectionManager = Injections.createInjectionManager(initBinders());
Set<MessageBodyReader> providers = Providers.getProviders(injectionManager, MessageBodyReader.class);
assertTrue(providers.size() > 0);
}
use of org.glassfish.jersey.internal.inject.InjectionManager in project jersey by jersey.
the class ProviderBinderTest method testProvidersMbw.
@Test
public void testProvidersMbw() {
InjectionManager injectionManager = Injections.createInjectionManager(initBinders());
ProviderBinder providerBinder = new ProviderBinder(injectionManager);
providerBinder.bindClasses(Collections.singleton(MyProvider.class));
Set<MessageBodyWriter> providers = Providers.getCustomProviders(injectionManager, MessageBodyWriter.class);
final Collection<MyProvider> myProviders = instancesOfType(MyProvider.class, providers);
assertEquals(1, myProviders.size());
}
Aggregations