クラス ApplicationEventsHolder
java.lang.ObjectSE
org.springframework.test.context.event.ApplicationEventsHolder
テストの実行中に公開されたアプリケーションイベントをスレッドバインドされた
ApplicationEvents
オブジェクトの形式で公開するホルダークラス。ApplicationEvents
はこのホルダーに登録され、ApplicationEventsTestExecutionListener
によって管理されます。
このクラスは public
ですが、Spring TestContext フレームワーク内またはサードパーティの拡張機能の実装での使用のみを目的としています。テスト作成者は、ApplicationEvents
の現在のインスタンスをテストクラスのフィールドに @Autowired
にするか、JUnit Jupiter と SpringExtension
を使用するときに、テストメソッドとライフサイクルメソッドのパラメーターを介して注入できるようにする必要があります。
- 導入:
- 5.3.3
- 作成者:
- Sam Brannen, Oliver Drotbohm, Simon Basl é
- 関連事項:
方法の概要
修飾子と型メソッド説明static ApplicationEvents
現在のスレッドのApplicationEvents
を取得します。static ApplicationEvents
現在のスレッドのApplicationEvents
を取得します。
メソッドの詳細
getApplicationEvents
現在のスレッドのApplicationEvents
を取得します。- 戻り値:
- 現在の
ApplicationEvents
、または登録されていない場合はnull
getRequiredApplicationEvents
現在のスレッドのApplicationEvents
を取得します。- 戻り値:
- 現在の
ApplicationEvents
- 例外:
IllegalStateExceptionSE
-ApplicationEvents
のインスタンスが現在のスレッドに登録されていない場合