|
1 | 1 | /*
|
2 |
| - * Copyright 2021 the original author or authors. |
| 2 | + * Copyright 2021-2022 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
15 | 15 | */
|
16 | 16 | package org.springframework.batch.core.step.builder;
|
17 | 17 |
|
| 18 | +import org.junit.Assert; |
18 | 19 | import org.junit.Test;
|
19 | 20 |
|
20 |
| -import static org.junit.Assert.assertEquals; |
| 21 | +import org.springframework.batch.core.Step; |
| 22 | +import org.springframework.batch.core.configuration.xml.DummyItemReader; |
| 23 | +import org.springframework.batch.core.configuration.xml.DummyItemWriter; |
| 24 | +import org.springframework.batch.core.configuration.xml.DummyJobRepository; |
| 25 | +import org.springframework.batch.support.transaction.ResourcelessTransactionManager; |
21 | 26 |
|
| 27 | +import static org.junit.Assert.assertEquals; |
22 | 28 | public class FaultTolerantStepBuilderTests {
|
23 | 29 |
|
24 |
| - @Test |
25 |
| - public void faultTolerantReturnsSameInstance() { |
26 |
| - FaultTolerantStepBuilder<Object, Object> builder = new FaultTolerantStepBuilder<>(new StepBuilder("test")); |
27 |
| - assertEquals(builder, builder.faultTolerant()); |
28 |
| - } |
| 30 | + @Test |
| 31 | + public void faultTolerantReturnsSameInstance() { |
| 32 | + FaultTolerantStepBuilder<Object, Object> builder = new FaultTolerantStepBuilder<>(new StepBuilder("test")); |
| 33 | + assertEquals(builder, builder.faultTolerant()); |
| 34 | + } |
| 35 | + |
| 36 | + @Test |
| 37 | + public void testAnnotationBasedStepExecutionListenerRegistration() { |
| 38 | + // given |
| 39 | + FaultTolerantStepBuilder<Object, Object> faultTolerantStepBuilder = new StepBuilder("myStep") |
| 40 | + .repository(new DummyJobRepository()) |
| 41 | + .transactionManager(new ResourcelessTransactionManager()) |
| 42 | + .<Object, Object>chunk(5).reader(new DummyItemReader()).writer(new DummyItemWriter()).faultTolerant() |
| 43 | + .listener(new StepBuilderTests.AnnotationBasedStepExecutionListener()); |
| 44 | + |
| 45 | + // when |
| 46 | + Step step = faultTolerantStepBuilder.build(); |
| 47 | + |
| 48 | + // then |
| 49 | + Assert.assertNotNull(step); |
| 50 | + } |
| 51 | + |
29 | 52 | }
|
0 commit comments