Class TestManagedBeanFeeder

java.lang.Object
org.silverpeas.kernel.TestManagedBeanFeeder

public final class TestManagedBeanFeeder extends Object
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 Details

    • TestManagedBeanFeeder

      public TestManagedBeanFeeder()
  • Method Details

    • manageBeanWithName

      public <T> void manageBeanWithName(@NonNull T bean, @NonNull String name)
      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 tests
      type - the type for which the beans will be managed.
      qualifiers - zero, one or more annotations qualifying the beans. Those must satisfy the Qualifier annotation.
    • 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 the Qualifier annotation.
    • removeAllManagedBeans

      public void removeAllManagedBeans()
      Removes all the beans that were fed into the IoC container. As the ManagedBeanProvider wrapping the BeanContainer uses also a tread local cache to cache some beans to enhance performance, those are also cleared.