HoneyMoose
  • 首页
  • Java
  • Jersey
  • Jira
  • Confluence
  • U.S.
    • USRealEstate
    • USVisaTrack
    • H1B
  • 项目和网站
    • CWIKI.US
    • OSSEZ 社区
    • WIKI.OSSEZ.COM
    • BUG.OSSEZ.COM
    • RSS.OSSEZ.COM
BLOG.OSSEZ.COM
A responsive blog theme focused om user reading experience
  1. Home
  2. Computer Science
  3. Spring
  4. This article

Spring Batch @SpringBatchTest 注解

2019年01月18日 1004Browse 0Like 0Comments

Spring Batch 提供了一些非常有用的工具类(例如 JobLauncherTestUtils 和 JobRepositoryTestUtils)和测试执行监听器(StepScopeTestExecutionListener 和 JobScopeTestExecutionListener)来测试批量组件。然而, 为了能够使用这些工具类,你必须明确的对它们进行配置。这个发布介绍了一个新的注解,这个注解被命名为 @SpringBatchTest 能够自动的添加工具 bean(utility beans)和监听器(listeners)来测试上下文并且为自动写入来标记为可用,下面是一个示例代码:

@RunWith(SpringRunner.class)
@SpringBatchTest
@ContextConfiguration(classes = {JobConfiguration.class})
public class JobTest {
   @Autowired
   private JobLauncherTestUtils jobLauncherTestUtils;
   @Autowired
   private JobRepositoryTestUtils jobRepositoryTestUtils;
   @Before
   public void clearMetadata() {
      jobRepositoryTestUtils.removeJobExecutions();
   }
   @Test
   public void testJob() throws Exception {
      // given
      JobParameters jobParameters =
            jobLauncherTestUtils.getUniqueJobParameters();
      // when
      JobExecution jobExecution =
            jobLauncherTestUtils.launchJob(jobParameters);
      // then
      Assert.assertEquals(ExitStatus.COMPLETED,
                          jobExecution.getExitStatus());
   }
}

有关这个新注解的更多细节,请参考 Unit Testing 章节中的内容。

 

https://www.cwiki.us/display/SpringBatchZH/@SpringBatchTest+Annotation

Tags: Spring Spring Batch
Last updated:2019年01月18日

Kratos

stay absorbed stay excellent

Like
< Previous
Next >

Comments

Cancel reply

Newest Hotspots Random
Newest Hotspots Random
1月14号的 UA857 PowerShell 中运行 maven 参数无法识别 Java 8 使用 Stream 把 List 转换为 map FAA 真的应该换换系统了 说说这 48 小时核酸检测的时间 Jenkins 构建过程中提示 GPG 错误
美联航悄然在 2023 年恢复前往中国航班美联储在加息的路上一路狂奔2023 年美国住房买家的购买意愿HAVC 无电池温控器(Thermostat)的电源接线方法ChatGPT 使用 API 进行 Postman 调用测试ChatGPT 最近火得不要不要的
Python 的 RST 文件是什么 Discourse 云平台安装 Confluence 6.15 使用附件宏 Confluence 6 从其他备份中恢复数据 Druid 官方文档列表 美国房产税是怎么算的
Categories
  • Algorithm(算法)
  • AMQP
  • Angular
  • CI
  • Compile And CI
  • Computer Science
  • Confluence
  • DataBase
  • Gradle
  • H1B
  • Hibernate
  • IDE
  • Java
  • Jersey
  • Jira
  • MariaDB
  • PrestaShop
  • Spring
  • Spring Batch
  • U.S.
  • USRealEstate
  • USVisaTrack
  • 我的小厨

COPYRIGHT © 2020 HoneyMoose. ALL RIGHTS RESERVED.

THEME CWIKIUS.CN MADE BY VTROIS