use of org.apache.felix.ipojo.manipulator.metadata.annotation.registry.Binding in project felix by apache.
the class AbsBindingModuleTestCase method testConditionalBindings.
public void testConditionalBindings() throws Exception {
final AnnotationVisitorFactory factory = mock(AnnotationVisitorFactory.class);
final AnnotationVisitorFactory factory2 = mock(AnnotationVisitorFactory.class);
AbsBindingModule module = new AbsBindingModule() {
public void configure() {
bind(Provides.class).when(on(ElementType.FIELD)).to(factory).when(on(ElementType.PARAMETER)).to(factory2);
}
};
module.configure();
Iterator<Binding> i = module.iterator();
Binding one = i.next();
assertNotNull(one);
assertEquals(getType(Provides.class), one.getAnnotationType());
assertEquals(factory, one.getFactory());
// Second Binding
Binding two = i.next();
assertNotNull(two);
assertEquals(getType(Provides.class), two.getAnnotationType());
assertEquals(factory2, two.getFactory());
}
use of org.apache.felix.ipojo.manipulator.metadata.annotation.registry.Binding in project felix by apache.
the class AbsBindingModuleTestCase method testStereotypeBindings.
public void testStereotypeBindings() throws Exception {
AbsBindingModule module = new AbsBindingModule() {
public void configure() {
bindStereotype(Bound.class).with(new ComponentLiteral() {
@Override
public boolean publicFactory() {
return false;
}
});
}
};
module.configure();
Iterator<Binding> i = module.iterator();
Binding one = i.next();
assertNotNull(one);
assertEquals(getType(Bound.class), one.getAnnotationType());
assertTrue(one.getFactory() instanceof StereotypeVisitorFactory);
}
use of org.apache.felix.ipojo.manipulator.metadata.annotation.registry.Binding in project felix by apache.
the class AbsBindingModuleTestCase method testSimpleBinding.
public void testSimpleBinding() throws Exception {
final AnnotationVisitorFactory factory = mock(AnnotationVisitorFactory.class);
AbsBindingModule module = new AbsBindingModule() {
public void configure() {
bind(Provides.class).to(factory);
}
};
module.configure();
Iterator<Binding> i = module.iterator();
Binding one = i.next();
assertNotNull(one);
assertEquals(getType(Provides.class), one.getAnnotationType());
assertEquals(factory, one.getFactory());
// Only 1 Binding
assertFalse(i.hasNext());
}
use of org.apache.felix.ipojo.manipulator.metadata.annotation.registry.Binding in project felix by apache.
the class AbsBindingModuleTestCase method testTwoBindingsForSameAnnotation.
public void testTwoBindingsForSameAnnotation() throws Exception {
final AnnotationVisitorFactory factory = mock(AnnotationVisitorFactory.class);
final AnnotationVisitorFactory factory2 = mock(AnnotationVisitorFactory.class);
AbsBindingModule module = new AbsBindingModule() {
public void configure() {
bind(Provides.class).to(factory);
bind(Provides.class).to(factory2);
}
};
module.configure();
Iterator<Binding> i = module.iterator();
Binding one = i.next();
assertNotNull(one);
assertEquals(getType(Provides.class), one.getAnnotationType());
assertEquals(factory, one.getFactory());
// Second Binding
Binding two = i.next();
assertNotNull(two);
assertEquals(getType(Provides.class), two.getAnnotationType());
assertEquals(factory2, two.getFactory());
}
use of org.apache.felix.ipojo.manipulator.metadata.annotation.registry.Binding in project felix by apache.
the class AbsBindingModuleTestCase method testConditionalBinding.
public void testConditionalBinding() throws Exception {
final AnnotationVisitorFactory factory = mock(AnnotationVisitorFactory.class);
AbsBindingModule module = new AbsBindingModule() {
public void configure() {
bind(Provides.class).when(on(ElementType.FIELD)).to(factory);
}
};
module.configure();
Iterator<Binding> i = module.iterator();
Binding one = i.next();
assertNotNull(one);
assertEquals(getType(Provides.class), one.getAnnotationType());
assertEquals(factory, one.getFactory());
// Only 1 Binding
assertFalse(i.hasNext());
}
Aggregations