public class JobScopeTestExecutionListener
extends java.lang.Object
implements org.springframework.test.context.TestExecutionListener
TestExecutionListener
。JobContext
は、テストメソッドの期間中に作成され、注入されたすべての依存関係で使用できるようになります。デフォルトの動作は、固定プロパティを持つ 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()); } }
コンストラクターと説明 |
---|
JobScopeTestExecutionListener() |
修飾子と型 | メソッドと説明 |
---|---|
void | afterTestClass(org.springframework.test.context.TestContext testContext) |
void | afterTestMethod(org.springframework.test.context.TestContext testContext) |
void | beforeTestClass(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 をテストコンテキスト属性として設定します。 |
public void prepareTestInstance(org.springframework.test.context.TestContext testContext) throws java.lang.Exception
JobExecution
をテストコンテキスト属性として設定します。org.springframework.test.context.TestExecutionListener
の prepareTestInstance
testContext
- 現在のテストコンテキスト java.lang.Exception
- 問題がある場合 TestExecutionListener.prepareTestInstance(TestContext)
public void beforeTestMethod(org.springframework.test.context.TestContext testContext) throws java.lang.Exception
org.springframework.test.context.TestExecutionListener
の beforeTestMethod
testContext
- 現在のテストコンテキスト java.lang.Exception
- 問題がある場合 TestExecutionListener.beforeTestMethod(TestContext)
public void afterTestMethod(org.springframework.test.context.TestContext testContext) throws java.lang.Exception
org.springframework.test.context.TestExecutionListener
の afterTestMethod
testContext
- 現在のテストコンテキスト java.lang.Exception
- 問題がある場合 TestExecutionListener.afterTestMethod(TestContext)
public void afterTestClass(org.springframework.test.context.TestContext testContext) throws java.lang.Exception
org.springframework.test.context.TestExecutionListener
の afterTestClass
java.lang.Exception
public void beforeTestClass(org.springframework.test.context.TestContext testContext) throws java.lang.Exception
org.springframework.test.context.TestExecutionListener
の beforeTestClass
java.lang.Exception
protected JobExecution getJobExecution(org.springframework.test.context.TestContext testContext)
JobExecution
をテストケースのフィールドとして検出するか、利用できない場合は作成します。testContext
- 現在のテストコンテキスト JobExecution