类 ApplicationContextAssert<C extends cn.taketoday.context.ApplicationContext>

java.lang.Object
org.assertj.core.api.AbstractAssert<ApplicationContextAssert<C>,C>
cn.taketoday.framework.test.context.assertj.ApplicationContextAssert<C>
类型参数:
C - the application context type
所有已实现的接口:
org.assertj.core.api.Assert<ApplicationContextAssert<C>,C>, org.assertj.core.api.Descriptable<ApplicationContextAssert<C>>, org.assertj.core.api.ExtensionPoints<ApplicationContextAssert<C>,C>

public class ApplicationContextAssert<C extends cn.taketoday.context.ApplicationContext> extends org.assertj.core.api.AbstractAssert<ApplicationContextAssert<C>,C>
AssertJ assertions that can be applied to an ApplicationContext.
从以下版本开始:
4.0
作者:
Phillip Webb, Andy Wilkinson
另请参阅:
  • 嵌套类概要

    嵌套类
    修饰符和类型
    说明
    private static final class 
    ApplicationContextAssert.ContextFailedToStart<C extends cn.taketoday.context.ApplicationContext>
     
    static enum 
    The scope of an assertion.
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    private final Throwable
     

    从类继承的字段 org.assertj.core.api.AbstractAssert

    actual, info, myself, objects, throwUnsupportedExceptionOnEquals
  • 构造器概要

    构造器
    构造器
    说明
    ApplicationContextAssert(C applicationContext, Throwable startupFailure)
    Create a new ApplicationContextAssert instance.
  • 方法概要

    修饰符和类型
    方法
    说明
    contextFailedToStartWhenExpecting(String expectationFormat, Object... arguments)
     
    Verifies that the application context (or ancestors) does not contain any beans of the given type.
    Verifies that the application context does not contain any beans of the given type.
    Verifies that the application context does not contain a beans of the given name.
    private Object
     
    protected final C
     
    <T> org.assertj.core.api.AbstractObjectAssert<?,T>
    getBean(Class<T> type)
    Obtain a single bean of the given type from the application context (or ancestors), the bean becoming the object under test.
    <T> org.assertj.core.api.AbstractObjectAssert<?,T>
    Obtain a single bean of the given type from the application context, the bean becoming the object under test.
    org.assertj.core.api.AbstractObjectAssert<?,Object>
    Obtain a single bean of the given name from the application context, the bean becoming the object under test.
    <T> org.assertj.core.api.AbstractObjectAssert<?,T>
    getBean(String name, Class<T> type)
    Obtain a single bean of the given name and type from the application context, the bean becoming the object under test.
    <T> org.assertj.core.api.AbstractObjectArrayAssert<?,String>
    Obtain the beans names of the given type from the application context, the names becoming the object array under test.
    <T> org.assertj.core.api.MapAssert<String,T>
    getBeans(Class<T> type)
    Obtain a map bean names and instances of the given type from the application context (or ancestors), the map becoming the object under test.
    <T> org.assertj.core.api.MapAssert<String,T>
    Obtain a map bean names and instances of the given type from the application context, the map becoming the object under test.
    org.assertj.core.api.AbstractThrowableAssert<?,? extends Throwable>
    Obtain the failure that stopped the application context from running, the failure becoming the object under test.
    private String
     
    protected final Throwable
     
    Verifies that the application context contains a bean with the given name.
    Verifies that the application has failed to start.
    Verifies that the application has not failed to start.
    Verifies that the application context (or ancestors) contains a single bean with the given type.
    Verifies that the application context contains a single bean with the given type.
    private boolean
     

    从类继承的方法 org.assertj.core.api.AbstractAssert

    areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError

    从类继承的方法 java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    从接口继承的方法 org.assertj.core.api.Descriptable

    as, as, as, describedAs
  • 字段详细资料

    • startupFailure

      private final Throwable startupFailure
  • 构造器详细资料

    • ApplicationContextAssert

      ApplicationContextAssert(C applicationContext, Throwable startupFailure)
      Create a new ApplicationContextAssert instance.
      参数:
      applicationContext - the source application context
      startupFailure - the startup failure or null
  • 方法详细资料

    • hasBean

      public ApplicationContextAssert<C> hasBean(String name)
      Verifies that the application context contains a bean with the given name.

      Example:

       assertThat(context).hasBean("fooBean"); 
      参数:
      name - the name of the bean
      返回:
      this assertion object.
      抛出:
      AssertionError - if the application context did not start
      AssertionError - if the application context does not contain a bean with the given name
    • hasSingleBean

      public ApplicationContextAssert<C> hasSingleBean(Class<?> type)
      Verifies that the application context (or ancestors) contains a single bean with the given type.

      Example:

       assertThat(context).hasSingleBean(Foo.class); 
      参数:
      type - the bean type
      返回:
      this assertion object.
      抛出:
      AssertionError - if the application context did not start
      AssertionError - if the application context does no beans of the given type
      AssertionError - if the application context contains multiple beans of the given type
    • hasSingleBean

      public ApplicationContextAssert<C> hasSingleBean(Class<?> type, ApplicationContextAssert.Scope scope)
      Verifies that the application context contains a single bean with the given type.

      Example:

       assertThat(context).hasSingleBean(Foo.class, Scope.NO_ANCESTORS); 
      参数:
      type - the bean type
      scope - the scope of the assertion
      返回:
      this assertion object.
      抛出:
      AssertionError - if the application context did not start
      AssertionError - if the application context does no beans of the given type
      AssertionError - if the application context contains multiple beans of the given type
    • doesNotHaveBean

      public ApplicationContextAssert<C> doesNotHaveBean(Class<?> type)
      Verifies that the application context (or ancestors) does not contain any beans of the given type.

      Example:

       assertThat(context).doesNotHaveBean(Foo.class); 
      参数:
      type - the bean type
      返回:
      this assertion object.
      抛出:
      AssertionError - if the application context did not start
      AssertionError - if the application context contains any beans of the given type
    • doesNotHaveBean

      public ApplicationContextAssert<C> doesNotHaveBean(Class<?> type, ApplicationContextAssert.Scope scope)
      Verifies that the application context does not contain any beans of the given type.

      Example:

       assertThat(context).doesNotHaveBean(Foo.class, Scope.NO_ANCESTORS); 
      参数:
      type - the bean type
      scope - the scope of the assertion
      返回:
      this assertion object.
      抛出:
      AssertionError - if the application context did not start
      AssertionError - if the application context contains any beans of the given type
    • doesNotHaveBean

      public ApplicationContextAssert<C> doesNotHaveBean(String name)
      Verifies that the application context does not contain a beans of the given name.

      Example:

       assertThat(context).doesNotHaveBean("fooBean"); 
      参数:
      name - the name of the bean
      返回:
      this assertion object.
      抛出:
      AssertionError - if the application context did not start
      AssertionError - if the application context contains a beans of the given name
    • getBeanNames

      public <T> org.assertj.core.api.AbstractObjectArrayAssert<?,String> getBeanNames(Class<T> type)
      Obtain the beans names of the given type from the application context, the names becoming the object array under test.

      Example:

       assertThat(context).getBeanNames(Foo.class).containsOnly("fooBean"); 
      类型参数:
      T - the bean type
      参数:
      type - the bean type
      返回:
      array assertions for the bean names
      抛出:
      AssertionError - if the application context did not start
    • getBean

      public <T> org.assertj.core.api.AbstractObjectAssert<?,T> getBean(Class<T> type)
      Obtain a single bean of the given type from the application context (or ancestors), the bean becoming the object under test. If no beans of the specified type can be found an assert on null is returned.

      Example:

       assertThat(context).getBean(Foo.class).isInstanceOf(DefaultFoo.class);
       assertThat(context).getBean(Bar.class).isNull();
      类型参数:
      T - the bean type
      参数:
      type - the bean type
      返回:
      bean assertions for the bean, or an assert on null if the no bean is found
      抛出:
      AssertionError - if the application context did not start
      AssertionError - if the application context contains multiple beans of the given type
    • getBean

      public <T> org.assertj.core.api.AbstractObjectAssert<?,T> getBean(Class<T> type, ApplicationContextAssert.Scope scope)
      Obtain a single bean of the given type from the application context, the bean becoming the object under test. If no beans of the specified type can be found an assert on null is returned.

      Example:

       assertThat(context).getBean(Foo.class, Scope.NO_ANCESTORS).isInstanceOf(DefaultFoo.class);
       assertThat(context).getBean(Bar.class, Scope.NO_ANCESTORS).isNull();
      类型参数:
      T - the bean type
      参数:
      type - the bean type
      scope - the scope of the assertion
      返回:
      bean assertions for the bean, or an assert on null if the no bean is found
      抛出:
      AssertionError - if the application context did not start
      AssertionError - if the application context contains multiple beans of the given type
    • getPrimary

      private String getPrimary(String[] names, ApplicationContextAssert.Scope scope)
    • isPrimary

      private boolean isPrimary(String name, ApplicationContextAssert.Scope scope)
    • getBean

      public org.assertj.core.api.AbstractObjectAssert<?,Object> getBean(String name)
      Obtain a single bean of the given name from the application context, the bean becoming the object under test. If no bean of the specified name can be found an assert on null is returned.

      Example:

       assertThat(context).getBean("foo").isInstanceOf(Foo.class);
       assertThat(context).getBean("foo").isNull();
      参数:
      name - the name of the bean
      返回:
      bean assertions for the bean, or an assert on null if the no bean is found
      抛出:
      AssertionError - if the application context did not start
    • getBean

      public <T> org.assertj.core.api.AbstractObjectAssert<?,T> getBean(String name, Class<T> type)
      Obtain a single bean of the given name and type from the application context, the bean becoming the object under test. If no bean of the specified name can be found an assert on null is returned.

      Example:

       assertThat(context).getBean("foo", Foo.class).isInstanceOf(DefaultFoo.class);
       assertThat(context).getBean("foo", Foo.class).isNull();
      类型参数:
      T - the bean type
      参数:
      name - the name of the bean
      type - the bean type
      返回:
      bean assertions for the bean, or an assert on null if the no bean is found
      抛出:
      AssertionError - if the application context did not start
      AssertionError - if the application context contains a bean with the given name but a different type
    • findBean

      private Object findBean(String name)
    • getBeans

      public <T> org.assertj.core.api.MapAssert<String,T> getBeans(Class<T> type)
      Obtain a map bean names and instances of the given type from the application context (or ancestors), the map becoming the object under test. If no bean of the specified type can be found an assert on an empty map is returned.

      Example:

       assertThat(context).getBeans(Foo.class).containsKey("foo");
       
      类型参数:
      T - the bean type
      参数:
      type - the bean type
      返回:
      bean assertions for the beans, or an assert on an empty map if the no beans are found
      抛出:
      AssertionError - if the application context did not start
    • getBeans

      public <T> org.assertj.core.api.MapAssert<String,T> getBeans(Class<T> type, ApplicationContextAssert.Scope scope)
      Obtain a map bean names and instances of the given type from the application context, the map becoming the object under test. If no bean of the specified type can be found an assert on an empty map is returned.

      Example:

       assertThat(context).getBeans(Foo.class, Scope.NO_ANCESTORS).containsKey("foo");
       
      类型参数:
      T - the bean type
      参数:
      type - the bean type
      scope - the scope of the assertion
      返回:
      bean assertions for the beans, or an assert on an empty map if the no beans are found
      抛出:
      AssertionError - if the application context did not start
    • getFailure

      public org.assertj.core.api.AbstractThrowableAssert<?,? extends Throwable> getFailure()
      Obtain the failure that stopped the application context from running, the failure becoming the object under test.

      Example:

       assertThat(context).getFailure().containsMessage("missing bean");
       
      返回:
      assertions on the cause of the failure
      抛出:
      AssertionError - if the application context started without a failure
    • hasFailed

      public ApplicationContextAssert<C> hasFailed()
      Verifies that the application has failed to start.

      Example:

       assertThat(context).hasFailed();
       
      返回:
      this assertion object.
      抛出:
      AssertionError - if the application context started without a failure
    • hasNotFailed

      public ApplicationContextAssert<C> hasNotFailed()
      Verifies that the application has not failed to start.

      Example:

       assertThat(context).hasNotFailed();
       
      返回:
      this assertion object.
      抛出:
      AssertionError - if the application context failed to start
    • getApplicationContext

      protected final C getApplicationContext()
    • getStartupFailure

      protected final Throwable getStartupFailure()
    • contextFailedToStartWhenExpecting

      private ApplicationContextAssert.ContextFailedToStart<C> contextFailedToStartWhenExpecting(String expectationFormat, Object... arguments)