クラス TestContextTransactionUtils

java.lang.ObjectSE
org.springframework.test.context.transaction.TestContextTransactionUtils

public abstract class TestContextTransactionUtils extends ObjectSE
Spring TestContext フレームワーク内のトランザクションおよびデータアクセス関連の Bean を操作するためのユーティリティメソッド。

主にフレームワーク内での内部使用向け。

導入:
4.1
作成者:
Sam Brannen, Juergen Hoeller, Andreas Ahlenstorf
  • フィールドの詳細

  • コンストラクターの詳細

    • TestContextTransactionUtils

      public TestContextTransactionUtils()
  • メソッドの詳細

    • retrieveDataSource

      @Nullable public static DataSourceSE retrieveDataSource(TestContext testContext, @Nullable StringSE name)
      指定されたテストコンテキストに使用する DataSourceSE を取得します。

      次のアルゴリズムを使用して、提供されたテストコンテキストの ApplicationContext から DataSource を取得します。

      1. 指定された name が空でない場合は、型と名前で DataSource を検索し、指定された DataSource が存在しない場合は BeansException をスローします。
      2. 型別に単一の DataSource を検索してみます。
      3. 型でプライマリ  DataSource を検索してみます。
      4. 型とデフォルトのデータソース名で DataSource を検索してみます。
      パラメーター:
      testContext - DataSource を取得する必要があるテストコンテキスト。null
      name - 取得する DataSource の名前 (null または空の可能性があります )
      戻り値:
      使用する DataSource、または見つからない場合は null 
      例外:
      BeansException - 明示的に指定された DataSource の取得中にエラーが発生した場合
    • retrieveTransactionManager

      @Nullable public static PlatformTransactionManager retrieveTransactionManager(TestContext testContext, @Nullable StringSE name)
      指定されたテストコンテキストに使用するトランザクションマネージャーを取得します。

      次のアルゴリズムは、提供されたテストコンテキストの ApplicationContext からトランザクションマネージャーを取得するために使用されます。

      1. 指定された name が空でない場合は、型と明示的な名前でトランザクションマネージャーを検索し、指定されたトランザクションマネージャーが存在しない場合は BeansException をスローします。
      2. 存在する場合は、TransactionManagementConfigurer を介してトランザクションマネージャーを検索してみます。
      3. 型で単一のトランザクションマネージャーを検索してみます。
      4. 型でプライマリトランザクションマネージャーを検索してみます。
      5. 型とデフォルトのトランザクションマネージャー名でトランザクションマネージャーを検索してみます。
      パラメーター:
      testContext - トランザクションマネージャーを取得する必要があるテストコンテキスト。null
      name - 取得するトランザクションマネージャーの名前 (null または空の可能性があります )
      戻り値:
      使用するトランザクションマネージャー。見つからない場合は null 
      例外:
      BeansException - 明示的に名前が付けられたトランザクションマネージャーの取得中にエラーが発生した場合
      IllegalStateExceptionSE - ApplicationContext に複数の TransactionManagementConfigurer が存在する場合
    • createDelegatingTransactionAttribute

      public static TransactionAttribute createDelegatingTransactionAttribute(TestContext testContext, TransactionAttribute targetAttribute)
      テストクラスの名前とテストメソッドを使用してトランザクションの名前を作成し、提供されたターゲット TransactionAttribute および TestContext の委譲 TransactionAttribute を作成します。
      パラメーター:
      testContext - 名前のベースとなる TestContext 
      targetAttribute - 委譲する TransactionAttribute 
      戻り値:
      委譲 TransactionAttribute
    • createDelegatingTransactionAttribute

      public static TransactionAttribute createDelegatingTransactionAttribute(TestContext testContext, TransactionAttribute targetAttribute, boolean includeMethodName)
      テストクラスの名前とテストメソッド (リクエストされた場合) を使用してトランザクションの名前を構築し、指定されたターゲット TransactionAttribute および TestContext の委譲 TransactionAttribute を作成します。
      パラメーター:
      testContext - 名前のベースとなる TestContext 
      targetAttribute - 委譲する TransactionAttribute 
      includeMethodName - true テストメソッドの名前をトランザクション名に含める必要がある場合
      戻り値:
      委譲 TransactionAttribute
      導入:
      6.1