use of org.glassfish.jersey.internal.inject.ClassBinding in project jersey by jersey.
the class AbstractBinderTest method testWithInstall.
@Test
public void testWithInstall() {
AbstractBinder internalBinder = new AbstractBinder() {
@Override
protected void configure() {
bind(MediaTypeProvider.class).to(HeaderDelegateProvider.class).in(Singleton.class);
bind(NewCookieProvider.class).to(HeaderDelegateProvider.class).in(Singleton.class);
bind(StringHeaderProvider.class).to(HeaderDelegateProvider.class).in(Singleton.class);
bind(UriProvider.class).to(HeaderDelegateProvider.class).in(Singleton.class);
}
};
AbstractBinder binder = new AbstractBinder() {
@Override
protected void configure() {
bind(CacheControlProvider.class).to(HeaderDelegateProvider.class).in(Singleton.class);
bind(CookieProvider.class).to(HeaderDelegateProvider.class).in(Singleton.class);
bind(DateProvider.class).to(HeaderDelegateProvider.class).in(Singleton.class);
bind(EntityTagProvider.class).to(HeaderDelegateProvider.class).in(Singleton.class);
bind(LinkProvider.class).to(HeaderDelegateProvider.class).in(Singleton.class);
install(internalBinder);
}
};
List<Binding> bindings = new ArrayList<>(binder.getBindings());
assertEquals(9, bindings.size());
// Keep ordering.
assertEquals(MediaTypeProvider.class, ((ClassBinding) bindings.get(0)).getService());
assertEquals(NewCookieProvider.class, ((ClassBinding) bindings.get(1)).getService());
assertEquals(StringHeaderProvider.class, ((ClassBinding) bindings.get(2)).getService());
assertEquals(UriProvider.class, ((ClassBinding) bindings.get(3)).getService());
assertEquals(CacheControlProvider.class, ((ClassBinding) bindings.get(4)).getService());
assertEquals(CookieProvider.class, ((ClassBinding) bindings.get(5)).getService());
assertEquals(DateProvider.class, ((ClassBinding) bindings.get(6)).getService());
assertEquals(EntityTagProvider.class, ((ClassBinding) bindings.get(7)).getService());
assertEquals(LinkProvider.class, ((ClassBinding) bindings.get(8)).getService());
}
use of org.glassfish.jersey.internal.inject.ClassBinding in project jersey by jersey.
the class AbstractBinderTest method testFirstLayer.
@Test
public void testFirstLayer() {
AbstractBinder binder = new AbstractBinder() {
@Override
protected void configure() {
bind(CacheControlProvider.class).to(HeaderDelegateProvider.class).in(Singleton.class);
bind(CookieProvider.class).to(HeaderDelegateProvider.class).in(Singleton.class);
bind(DateProvider.class).to(HeaderDelegateProvider.class).in(Singleton.class);
bind(EntityTagProvider.class).to(HeaderDelegateProvider.class).in(Singleton.class);
bind(LinkProvider.class).to(HeaderDelegateProvider.class).in(Singleton.class);
}
};
List<Binding> bindings = new ArrayList<>(binder.getBindings());
assertEquals(5, bindings.size());
// Keep ordering.
assertEquals(CacheControlProvider.class, ((ClassBinding) bindings.get(0)).getService());
assertEquals(CookieProvider.class, ((ClassBinding) bindings.get(1)).getService());
assertEquals(DateProvider.class, ((ClassBinding) bindings.get(2)).getService());
assertEquals(EntityTagProvider.class, ((ClassBinding) bindings.get(3)).getService());
assertEquals(LinkProvider.class, ((ClassBinding) bindings.get(4)).getService());
}
Aggregations