Fix for setting name of StaxEventItemReader at build

This commit is contained in:
Parikshit Dutta
2020-09-23 20:14:26 +05:30
committed by Mahmoud Ben Hassine
parent 342a1a35dc
commit 1ce4da5cce
2 changed files with 5 additions and 3 deletions

View File

@@ -231,12 +231,10 @@ public class StaxEventItemReaderBuilder<T> {
if (this.saveState) {
Assert.state(StringUtils.hasText(this.name), "A name is required when saveState is set to true.");
}
else {
reader.setName(this.name);
}
Assert.notEmpty(this.fragmentRootElements, "At least one fragment root element is required");
reader.setName(this.name);
reader.setSaveState(this.saveState);
reader.setResource(this.resource);
reader.setFragmentRootElementNames(

View File

@@ -37,6 +37,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static org.springframework.test.util.ReflectionTestUtils.getField;
/**
* @author Michael Minella
@@ -122,6 +123,9 @@ public class StaxEventItemReaderBuilderTests {
assertEquals("five", item.getSecond());
assertEquals("six", item.getThird());
assertEquals(2, executionContext.size());
Object executionContextUserSupport = getField(reader, "executionContextUserSupport");
assertEquals("fooReader", getField(executionContextUserSupport, "name"));
}
@Test