Class FakeBeanFactory

java.lang.Object
mockit.MockUp<org.springframework.beans.factory.support.DefaultListableBeanFactory>
mockit.integration.springframework.FakeBeanFactory

public final class FakeBeanFactory extends MockUp<org.springframework.beans.factory.support.DefaultListableBeanFactory>
If applied, this fake will take over calls to AbstractBeanFactory.getBean(String) and AbstractBeanFactory.getBean(String, Class) in any implementation class, returning instead a @Tested or @Injectable object with the given field name, or a dependency object injected at any level into a @Tested object.

In case said calls come (indirectly) from a test class having no @Tested fields, bean lookup will proceed into the actual getBean implementation method.

Note this fake is only useful if the code under test makes direct calls to Spring's getBean methods.

  • Constructor Details

    • FakeBeanFactory

      public FakeBeanFactory()
  • Method Details

    • getBean

      public static Object getBean(@NonNull Invocation invocation, @NonNull String name)
    • getBean

      public static <T> T getBean(@NonNull Invocation invocation, @NonNull String name, @Nullable Class<T> requiredType)
    • getBean

      public static <T> T getBean(@NonNull Invocation invocation, @NonNull Class<T> requiredType)