クラス StepScopeTestExecutionListener

java.lang.ObjectSE
org.springframework.batch.test.StepScopeTestExecutionListener
実装されたすべてのインターフェース:
org.springframework.test.context.TestExecutionListener

public class StepScopeTestExecutionListener extends ObjectSE implements org.springframework.test.context.TestExecutionListener
単体テストへの依存性注入のためのステップスコープコンテキストを設定する TestExecutionListenerStepContext は、テストメソッドの実行中に作成され、注入されたすべての依存関係で使用できるようになります。デフォルトの動作は、固定プロパティを持つ StepExecution を作成することです。または、正しい型を返すファクトリメソッドとしてテストケースで提供することもできます。例:
 @ContextConfiguration
 @TestExecutionListeners( { DependencyInjectionTestExecutionListener.class, StepScopeTestExecutionListener.class })
 @RunWith(SpringJUnit4ClassRunner.class)
 public class StepScopeTestExecutionListenerIntegrationTests {

        // A step-scoped dependency configured in the ApplicationContext
        @Autowired
        private ItemReader<String> reader;

  public StepExecution getStepExecution() {
    StepExecution execution = MetaDataInstanceFactory.createStepExecution();
    execution.getExecutionContext().putString("foo", "bar");
    return execution;
  }

        @Test
        public void testStepScopedReader() {
                // Step context is active here so the reader can be used,
      // and the step execution context will contain foo=bar...
                assertNotNull(reader.read());
        }

 }
 
作成者:
Dave Syer, Chris Schaefer, Mahmoud Ben Hassine
  • コンストラクターのサマリー

    コンストラクター
    コンストラクター
    説明
  • メソッドのサマリー

    修飾子と型
    メソッド
    説明
    void
    afterTestMethod(org.springframework.test.context.TestContext testContext)
    void
    beforeTestMethod(org.springframework.test.context.TestContext testContext)
    protected StepExecution
    getStepExecution(org.springframework.test.context.TestContext testContext)
    StepExecution をテストケースのフィールドとして検出するか、利用できない場合は作成します。
    void
    prepareTestInstance(org.springframework.test.context.TestContext testContext)
    StepExecution をテストコンテキスト属性として設定します。

    クラス java.lang.ObjectSE から継承されたメソッド

    clone, equalsSE, finalize, getClass, hashCode, notify, notifyAll, toString, wait, waitSE, waitSE

    インターフェース org.springframework.test.context.TestExecutionListener から継承されたメソッド

    afterTestClass, afterTestExecution, beforeTestClass, beforeTestExecution
  • コンストラクターの詳細

    • StepScopeTestExecutionListener

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

    • prepareTestInstance

      public void prepareTestInstance(org.springframework.test.context.TestContext testContext)
      StepExecution をテストコンテキスト属性として設定します。
      次で指定:
      インターフェース org.springframework.test.context.TestExecutionListenerprepareTestInstance 
      パラメーター:
      testContext - 現在のテストコンテキスト
      関連事項:
      • TestExecutionListener.prepareTestInstance(TestContext)
    • beforeTestMethod

      public void beforeTestMethod(org.springframework.test.context.TestContext testContext)
      次で指定:
      インターフェース org.springframework.test.context.TestExecutionListenerbeforeTestMethod 
      パラメーター:
      testContext - 現在のテストコンテキスト
      関連事項:
      • TestExecutionListener.beforeTestMethod(TestContext)
    • afterTestMethod

      public void afterTestMethod(org.springframework.test.context.TestContext testContext)
      次で指定:
      インターフェース org.springframework.test.context.TestExecutionListenerafterTestMethod 
      パラメーター:
      testContext - 現在のテストコンテキスト
      関連事項:
      • TestExecutionListener.afterTestMethod(TestContext)
    • getStepExecution

      protected StepExecution getStepExecution(org.springframework.test.context.TestContext testContext)
      StepExecution をテストケースのフィールドとして検出するか、利用できない場合は作成します。
      パラメーター:
      testContext - 現在のテストコンテキスト
      戻り値:
      StepExecution