クラス ApplicationEventsHolder

java.lang.ObjectSE
org.springframework.test.context.event.ApplicationEventsHolder

public abstract class ApplicationEventsHolder extends ObjectSE
テストの実行中に公開されたアプリケーションイベントをスレッドバインドされた ApplicationEvents オブジェクトの形式で公開するホルダークラス。

ApplicationEvents はこのホルダーに登録され、ApplicationEventsTestExecutionListener によって管理されます。

このクラスは public ですが、Spring TestContext フレームワーク内またはサードパーティの拡張機能の実装での使用のみを目的としています。テスト作成者は、ApplicationEvents の現在のインスタンスをテストクラスのフィールドに @Autowired にするか、JUnit Jupiter と SpringExtension を使用するときに、テストメソッドとライフサイクルメソッドのパラメーターを介して注入できるようにする必要があります。

導入:
5.3.3
作成者:
Sam Brannen, Oliver Drotbohm, Simon Basl é
関連事項:
  • メソッドの詳細

    • getApplicationEvents

      @Nullable public static ApplicationEvents getApplicationEvents()
      現在のスレッドの ApplicationEvents を取得します。
      戻り値:
      現在の ApplicationEvents、または登録されていない場合は null 
    • getRequiredApplicationEvents

      public static ApplicationEvents getRequiredApplicationEvents()
      現在のスレッドの ApplicationEvents を取得します。
      戻り値:
      現在の ApplicationEvents
      例外:
      IllegalStateExceptionSE - ApplicationEvents のインスタンスが現在のスレッドに登録されていない場合