Package org.silverpeas.kernel
Class TestManagedBeanFeeder
java.lang.Object
org.silverpeas.kernel.TestManagedBeanFeeder
A feeder of beans to manage in the underlying IoC subsystem. The subsystem is implemented here by
TestBeanContainer. This feeder is to be used by the unit tests to register the beans
required by them for the test passes successfully. For more information about are managed the
beans in the IoC container used in the unit tests, please see TestBeanContainer- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> voidmanageBean(T bean, Class<? super T> type, Annotation... qualifiers) Manages explicitly the specified bean for the given type and with the specified qualifiers.<T> voidmanageBeanForType(Class<T> beanClass, Class<? super T> type, Annotation... qualifiers) Manages the beans of the specified class for the given type and with the specified qualifiers.<T> voidmanageBeanWithName(T bean, String name) Manages explicitly the specified bean under the given unique name.voidRemoves all the beans that were fed into the IoC container.
-
Constructor Details
-
TestManagedBeanFeeder
public TestManagedBeanFeeder()
-
-
Method Details
-
manageBeanWithName
Manages explicitly the specified bean under the given unique name.- Type Parameters:
T- the concrete type of the bean to manage.- Parameters:
bean- the object to manage into the IoC container dedicated to the unit tests.name- the name under which the bean will be register in the container.
-
manageBeanForType
public <T> void manageBeanForType(@NonNull Class<T> beanClass, @NonNull Class<? super T> type, @NonNull Annotation... qualifiers) Manages the beans of the specified class for the given type and with the specified qualifiers. The life-cycle of the beans, and thus their instantiation, will be taken in charge by the underlying IoC container.- Type Parameters:
T- the concrete type of the beans to register.- Parameters:
beanClass- the class of the beans to be managed by the IoC container dedicated to the unit teststype- the type for which the beans will be managed.qualifiers- zero, one or more annotations qualifying the beans. Those must satisfy theQualifierannotation.
-
manageBean
public <T> void manageBean(@NonNull T bean, @NonNull Class<? super T> type, @NonNull Annotation... qualifiers) Manages explicitly the specified bean for the given type and with the specified qualifiers.- Type Parameters:
T- the actual type of the bean.- Parameters:
bean- the object to manage into the IoC container dedicated to the unit tests.type- the type for which the bean is registered.qualifiers- zero, one or more annotations qualifying the beans. Those must satisfy theQualifierannotation.
-
removeAllManagedBeans
public void removeAllManagedBeans()Removes all the beans that were fed into the IoC container. As theManagedBeanProviderwrapping theBeanContaineruses also a tread local cache to cache some beans to enhance performance, those are also cleared.
-