【问题标题】:How is job name getting assigned in spring batch junit如何在春季批处理junit中分配作业名称
【发布时间】:2021-04-10 14:56:33
【问题描述】:

我正在 junit 中测试 spring 批处理作业。

public void testJob() {
    JobExecution jobExecution = jobLauncherTestUtils.launchStep("processFileStep", params2, executionContext);

    JobParameters params3 = new JobParameters(setJobParams());

    jobLauncherTestUtils.launchStep("downloadResultsFile", params3, executionContext);

    Collection<StepExecution> actualStepExecutions = jobExecution.getStepExecutions();

    assertThat(actualStepExecutions.size(), is(1));

    assertThat(jobExecution.getJobInstance().getJobName(), is("TestJob"));// where is it set to TestJob?
}

我不明白作业名称是如何设置为 TestJob 的。 ?感谢您的宝贵时间。

【问题讨论】:

    标签: spring-boot junit spring-batch


    【解决方案1】:

    当您使用 JobLauncherTestUtils 启动一个步骤时,Spring Batch 将创建一个类型为 SimpleJob 的单步作业,名为 TestJob 围绕您的步骤并启动它。您可以在代码here 中看到这一点。

    这似乎没有记录,所以我创建了an issue 来改进这方面的文档。

    【讨论】:

    • 谢谢马哈茂德
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-17
    • 2012-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多