类 ApplicationEventsHolder
java.lang.Object
cn.taketoday.test.context.event.ApplicationEventsHolder
Holder class to expose the application events published during the execution
of a test in the form of a thread-bound
ApplicationEvents object.
ApplicationEvents are registered in this holder and managed by
the ApplicationEventsTestExecutionListener.
Although this class is public, it is only intended for use within
the TestContext Framework or in the implementation of
third-party extensions. Test authors should therefore allow the current
instance of ApplicationEvents to be
@Autowired
into a field in the test class or injected via a parameter in test and
lifecycle methods when using JUnit Jupiter and the ApplicationExtension.
- 从以下版本开始:
- 4.0
- 作者:
- Sam Brannen, Oliver Drotbohm
- 另请参阅:
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static ApplicationEventsGet theApplicationEventsfor the current thread.static ApplicationEventsGet theApplicationEventsfor the current thread.(专用程序包) static voidRegister a newDefaultApplicationEventsinstance to be used for the current thread.(专用程序包) static voidRegister a newDefaultApplicationEventsinstance to be used for the current thread, if necessary.(专用程序包) static voidRemove the registration of theApplicationEventsfor the current thread.
-
字段详细资料
-
applicationEvents
-
-
构造器详细资料
-
ApplicationEventsHolder
private ApplicationEventsHolder()
-
-
方法详细资料
-
getApplicationEvents
Get theApplicationEventsfor the current thread.- 返回:
- the current
ApplicationEvents, ornullif not registered
-
getRequiredApplicationEvents
Get theApplicationEventsfor the current thread.- 返回:
- the current
ApplicationEvents - 抛出:
IllegalStateException- if an instance ofApplicationEventshas not been registered for the current thread
-
registerApplicationEventsIfNecessary
static void registerApplicationEventsIfNecessary()Register a newDefaultApplicationEventsinstance to be used for the current thread, if necessary.If
registerApplicationEvents()has already been called for the current thread, this method does not do anything. -
registerApplicationEvents
static void registerApplicationEvents()Register a newDefaultApplicationEventsinstance to be used for the current thread. -
unregisterApplicationEvents
static void unregisterApplicationEvents()Remove the registration of theApplicationEventsfor the current thread.
-