Search in sources :

Example 31 with InjectionManager

use of org.glassfish.jersey.internal.inject.InjectionManager 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 32 with InjectionManager

use of org.glassfish.jersey.internal.inject.InjectionManager 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 33 with InjectionManager

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

the class InjectionManagerTest method testRegisterUnknownProvider.

@Test(expected = IllegalArgumentException.class)
public void testRegisterUnknownProvider() {
    InjectionManager injectionManager = new HK2InjectionManager();
    injectionManager.initialize();
    injectionManager.register(new Object());
}
Also used : InjectionManager(org.glassfish.jersey.internal.inject.InjectionManager) Test(org.junit.Test)

Example 34 with InjectionManager

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

the class InjectionManagerTest method testInjectionManagerParent.

@Test
public void testInjectionManagerParent() {
    ClassBinding<EnglishGreeting> greetingBinding = Bindings.serviceAsContract(EnglishGreeting.class);
    InjectionManager parentInjectionManager = new HK2InjectionManager();
    parentInjectionManager.initialize();
    parentInjectionManager.register(greetingBinding);
    InjectionManager injectionManager = new HK2InjectionManager();
    injectionManager.initialize(parentInjectionManager);
    assertNotNull(injectionManager.getInstance(EnglishGreeting.class));
}
Also used : InjectionManager(org.glassfish.jersey.internal.inject.InjectionManager) Test(org.junit.Test)

Example 35 with InjectionManager

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

the class InjectionManagerTest method testUnknownParent.

@Test(expected = IllegalArgumentException.class)
public void testUnknownParent() {
    InjectionManager parentInjectionManager = new HK2InjectionManager();
    parentInjectionManager.initialize(new Object());
    Injections.createInjectionManager(parentInjectionManager);
}
Also used : InjectionManager(org.glassfish.jersey.internal.inject.InjectionManager) Test(org.junit.Test)

Aggregations

InjectionManager (org.glassfish.jersey.internal.inject.InjectionManager)50 Test (org.junit.Test)41 WadlGenerator (org.glassfish.jersey.server.wadl.WadlGenerator)10 AbstractBinder (org.glassfish.jersey.internal.inject.AbstractBinder)8 ProviderBinder (org.glassfish.jersey.internal.inject.ProviderBinder)7 MessageBodyReader (javax.ws.rs.ext.MessageBodyReader)5 File (java.io.File)4 URL (java.net.URL)4 Properties (java.util.Properties)4 WriterInterceptor (javax.ws.rs.ext.WriterInterceptor)4 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)4 MessageBodyWriter (javax.ws.rs.ext.MessageBodyWriter)3 JerseyTest (org.glassfish.jersey.test.JerseyTest)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 IdentityHashMap (java.util.IdentityHashMap)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Function (java.util.function.Function)2