クラス JobScopeTestExecutionListener

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

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

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

        public JobExecution getJobExecution() {
                JobExecution execution = MetaDataInstanceFactory.createJobExecution();
                execution.getExecutionContext().putString("foo", "bar");
                return execution;
        }

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

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

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

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

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

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

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

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

    • JobScopeTestExecutionListener

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

    • prepareTestInstance

      public void prepareTestInstance(org.springframework.test.context.TestContext testContext)
      JobExecution をテストコンテキスト属性として設定します。
      次で指定:
      インターフェース 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)
    • getJobExecution

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