Search in sources :

Example 1 with ProviderBinder

use of org.glassfish.jersey.internal.inject.ProviderBinder 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);
}
Also used : ProviderBinder(org.glassfish.jersey.internal.inject.ProviderBinder) MessageBodyWriter(javax.ws.rs.ext.MessageBodyWriter) InjectionManager(org.glassfish.jersey.internal.inject.InjectionManager) Test(org.junit.Test)

Example 2 with ProviderBinder

use of org.glassfish.jersey.internal.inject.ProviderBinder 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());
}
Also used : ProviderBinder(org.glassfish.jersey.internal.inject.ProviderBinder) MessageBodyWriter(javax.ws.rs.ext.MessageBodyWriter) InjectionManager(org.glassfish.jersey.internal.inject.InjectionManager) Test(org.junit.Test)

Example 3 with ProviderBinder

use of org.glassfish.jersey.internal.inject.ProviderBinder in project jersey by jersey.

the class ProviderBinderTest method testProvidersMbr.

@Test
public void testProvidersMbr() {
    InjectionManager injectionManager = Injections.createInjectionManager(initBinders());
    ProviderBinder providerBinder = new ProviderBinder(injectionManager);
    providerBinder.bindClasses(Collections.singleton(MyProvider.class));
    Set<MessageBodyReader> providers = Providers.getCustomProviders(injectionManager, MessageBodyReader.class);
    assertEquals(1, instancesOfType(MyProvider.class, providers).size());
}
Also used : ProviderBinder(org.glassfish.jersey.internal.inject.ProviderBinder) MessageBodyReader(javax.ws.rs.ext.MessageBodyReader) InjectionManager(org.glassfish.jersey.internal.inject.InjectionManager) Test(org.junit.Test)

Example 4 with ProviderBinder

use of org.glassfish.jersey.internal.inject.ProviderBinder in project jersey by jersey.

the class ProviderBinderTest method testProvidersMbrInstance.

@Test
public void testProvidersMbrInstance() {
    InjectionManager injectionManager = Injections.createInjectionManager(initBinders());
    ProviderBinder providerBinder = new ProviderBinder(injectionManager);
    providerBinder.bindInstances(Collections.singleton(new MyProvider()));
    Set<MessageBodyReader> providers = Providers.getCustomProviders(injectionManager, MessageBodyReader.class);
    assertEquals(1, instancesOfType(MyProvider.class, providers).size());
}
Also used : ProviderBinder(org.glassfish.jersey.internal.inject.ProviderBinder) MessageBodyReader(javax.ws.rs.ext.MessageBodyReader) InjectionManager(org.glassfish.jersey.internal.inject.InjectionManager) Test(org.junit.Test)

Example 5 with ProviderBinder

use of org.glassfish.jersey.internal.inject.ProviderBinder in project jersey by jersey.

the class TestBinder method initProviders.

public static void initProviders(final InjectionManager injectionManager, final Iterable<Class<?>> providerClasses, final Iterable<Object> providerInstances) {
    final ProviderBinder providerBinder = new ProviderBinder(injectionManager);
    providerBinder.bindClasses(providerClasses);
    providerBinder.bindInstances(providerInstances);
}
Also used : ProviderBinder(org.glassfish.jersey.internal.inject.ProviderBinder)

Aggregations

ProviderBinder (org.glassfish.jersey.internal.inject.ProviderBinder)7 InjectionManager (org.glassfish.jersey.internal.inject.InjectionManager)6 Test (org.junit.Test)5 MessageBodyReader (javax.ws.rs.ext.MessageBodyReader)2 MessageBodyWriter (javax.ws.rs.ext.MessageBodyWriter)2 ContainerRequestFilter (javax.ws.rs.container.ContainerRequestFilter)1 ContainerResponseFilter (javax.ws.rs.container.ContainerResponseFilter)1 AbstractBinder (org.glassfish.jersey.internal.inject.AbstractBinder)1 Before (org.junit.Before)1