use of org.glassfish.jersey.internal.inject.ProviderBinder in project jersey by jersey.
the class ContextResolverFactoryTest method setUp.
@Before
public void setUp() {
final InjectionManager locator = Injections.createInjectionManager(new ContextResolverFactory.Binder(), new Binder());
final ProviderBinder providerBinder = new ProviderBinder(locator);
providerBinder.bindClasses(Collections.singleton(CustomIntegerResolverC.class));
crf = locator.getInstance(ContextResolverFactory.class);
}
use of org.glassfish.jersey.internal.inject.ProviderBinder in project jersey by jersey.
the class ProviderBinderTest method testCustomRegistration.
@Test
public void testCustomRegistration() {
InjectionManager injectionManager = Injections.createInjectionManager();
ProviderBinder providerBinder = new ProviderBinder(injectionManager);
providerBinder.bindClasses(Child.class);
providerBinder.bindClasses(NotFilterChild.class);
ContainerRequestFilter requestFilter = getRequestFilter(injectionManager);
ContainerRequestFilter requestFilter2 = getRequestFilter(injectionManager);
assertEquals(requestFilter, requestFilter2);
ContainerResponseFilter responseFilter = getResponseFilter(injectionManager);
ContainerResponseFilter responseFilter2 = getResponseFilter(injectionManager);
assertTrue(responseFilter == responseFilter2);
assertTrue(responseFilter == requestFilter);
// only one filter should be registered
Collection<ContainerResponseFilter> filters = Providers.getCustomProviders(injectionManager, ContainerResponseFilter.class);
assertEquals(1, filters.size());
Child child = injectionManager.getInstance(Child.class);
Child child2 = injectionManager.getInstance(Child.class);
assertTrue(child != responseFilter);
assertTrue(child == child2);
}
Aggregations