use of org.glassfish.hk2.api.IterableProvider in project glassfish-hk2 by eclipse-ee4j.
the class ProvidesTest method testProvidesNullFromInstanceField.
/**
* Verifies that {@code null} may be provided from an instance field annotated
* with {@link Provides}.
*/
@Test
public void testProvidesNullFromInstanceField() {
ServiceLocator locator = createAndPopulateServiceLocator();
ServiceLocatorUtilities.addClasses(locator, ProvidesListener.class, ProvidesNull.class);
IterableProvider<NullFromInstanceField> provider = locator.getService(new TypeLiteral<IterableProvider<NullFromInstanceField>>() {
}.getType());
try (ServiceHandle<NullFromInstanceField> handle = provider.getHandle()) {
assertNull(handle.getService());
}
}
Aggregations