类 DefaultTestContext
java.lang.Object
cn.taketoday.test.context.support.DefaultTestContext
- 所有已实现的接口:
cn.taketoday.core.AttributeAccessor,TestContext,Serializable
Default implementation of the
TestContext interface.- 从以下版本开始:
- 4.0
- 作者:
- Sam Brannen, Juergen Hoeller, Rob Harrop, Harry Yang
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明private final CacheAwareContextLoaderDelegateprivate final MergedContextConfigurationprivate static final longprivate final Class<?>private Throwableprivate Objectprivate Method -
构造器概要
构造器构造器说明DefaultTestContext(DefaultTestContext testContext) Copy constructor for creating a newDefaultTestContextbased on the attributes and immutable state of the supplied context.DefaultTestContext(Class<?> testClass, MergedContextConfiguration mergedConfig, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate) Construct a newDefaultTestContextfrom the supplied arguments. -
方法概要
修饰符和类型方法说明void<T> TcomputeAttribute(String name, Function<String, T> computeFunction) voidcopyAttributesFrom(cn.taketoday.core.AttributeAccessor source) cn.taketoday.context.ApplicationContextGet the application context for this test context.getAttribute(String name) String[]final Class<?>Get the test class for this test context.final ThrowableGet the exception that was thrown during execution of the test method.final ObjectGet the current test instance for this test context.final MethodGet the current test method for this test context.booleanDetermine if the application context for this test context is present in the context cache.booleanhasAttribute(String name) booleanvoidmarkApplicationContextDirty(DirtiesContext.HierarchyMode hierarchyMode) Mark the application context associated with this test context as dirty (i.e., by removing it from the context cache and closing it).removeAttribute(String name) voidsetAttribute(String name, Object value) toString()Provide a String representation of this test context's state.voidupdateState(Object testInstance, Method testMethod, Throwable testException) Update this test context to reflect the state of the currently executing test.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait从接口继承的方法 cn.taketoday.core.AttributeAccessor
attributeNames从接口继承的方法 cn.taketoday.test.context.TestContext
publishEvent
-
字段详细资料
-
serialVersionUID
private static final long serialVersionUID- 另请参阅:
-
attributes
-
cacheAwareContextLoaderDelegate
-
mergedConfig
-
testClass
-
testInstance
-
testMethod
-
testException
-
-
构造器详细资料
-
DefaultTestContext
Copy constructor for creating a newDefaultTestContextbased on the attributes and immutable state of the supplied context.Immutable state includes all arguments supplied to the standard constructor.
- 抛出:
NullPointerException- if the suppliedDefaultTestContextisnull
-
DefaultTestContext
public DefaultTestContext(Class<?> testClass, MergedContextConfiguration mergedConfig, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate) Construct a newDefaultTestContextfrom the supplied arguments.- 参数:
testClass- the test class for this test contextmergedConfig- the merged application context configuration for this test contextcacheAwareContextLoaderDelegate- the delegate to use for loading and closing the application context for this test context
-
-
方法详细资料
-
hasApplicationContext
public boolean hasApplicationContext()Determine if the application context for this test context is present in the context cache.- 指定者:
hasApplicationContext在接口中TestContext- 返回:
trueif the application context has already been loaded and stored in the context cache- 另请参阅:
-
getApplicationContext
public cn.taketoday.context.ApplicationContext getApplicationContext()Get the application context for this test context.The default implementation delegates to the
CacheAwareContextLoaderDelegatethat was supplied when thisTestContextwas constructed.- 指定者:
getApplicationContext在接口中TestContext- 返回:
- the application context (never
null) - 抛出:
IllegalStateException- if the context returned by the context loader delegate is not active (i.e., has been closed)- 另请参阅:
-
markApplicationContextDirty
Mark the application context associated with this test context as dirty (i.e., by removing it from the context cache and closing it).The default implementation delegates to the
CacheAwareContextLoaderDelegatethat was supplied when thisTestContextwas constructed.- 指定者:
markApplicationContextDirty在接口中TestContext- 参数:
hierarchyMode- the context cache clearing mode to be applied if the context is part of a hierarchy (may benull)- 另请参阅:
-
getTestClass
从接口复制的说明:TestContextGet the test class for this test context.- 指定者:
getTestClass在接口中TestContext- 返回:
- the test class (never
null)
-
getTestInstance
从接口复制的说明:TestContextGet the current test instance for this test context.Note: this is a mutable property.
- 指定者:
getTestInstance在接口中TestContext- 返回:
- the current test instance (never
null) - 另请参阅:
-
getTestMethod
从接口复制的说明:TestContextGet the current test method for this test context.Note: this is a mutable property.
- 指定者:
getTestMethod在接口中TestContext- 返回:
- the current test method (never
null) - 另请参阅:
-
getTestException
从接口复制的说明:TestContextGet the exception that was thrown during execution of the test method.Note: this is a mutable property.
- 指定者:
getTestException在接口中TestContext- 返回:
- the exception that was thrown, or
nullif no exception was thrown - 另请参阅:
-
updateState
public void updateState(@Nullable Object testInstance, @Nullable Method testMethod, @Nullable Throwable testException) 从接口复制的说明:TestContextUpdate this test context to reflect the state of the currently executing test.WARNING: This method should only be invoked by the
TestContextManager.Caution: concurrent invocations of this method might not be thread-safe, depending on the underlying implementation.
- 指定者:
updateState在接口中TestContext- 参数:
testInstance- the current test instance (may benull)testMethod- the current test method (may benull)testException- the exception that was thrown in the test method, ornullif no exception was thrown
-
setAttribute
- 指定者:
setAttribute在接口中cn.taketoday.core.AttributeAccessor
-
getAttribute
- 指定者:
getAttribute在接口中cn.taketoday.core.AttributeAccessor
-
computeAttribute
- 指定者:
computeAttribute在接口中cn.taketoday.core.AttributeAccessor
-
copyAttributesFrom
public void copyAttributesFrom(cn.taketoday.core.AttributeAccessor source) - 指定者:
copyAttributesFrom在接口中cn.taketoday.core.AttributeAccessor
-
clearAttributes
public void clearAttributes()- 指定者:
clearAttributes在接口中cn.taketoday.core.AttributeAccessor
-
removeAttribute
- 指定者:
removeAttribute在接口中cn.taketoday.core.AttributeAccessor
-
hasAttribute
- 指定者:
hasAttribute在接口中cn.taketoday.core.AttributeAccessor
-
getAttributeNames
- 指定者:
getAttributeNames在接口中cn.taketoday.core.AttributeAccessor
-
hasAttributes
public boolean hasAttributes()- 指定者:
hasAttributes在接口中cn.taketoday.core.AttributeAccessor
-
getAttributes
- 指定者:
getAttributes在接口中cn.taketoday.core.AttributeAccessor
-
toString
Provide a String representation of this test context's state.
-