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 67a0c7a372
commit 8e821fe1c5
2 changed files with 5 additions and 3 deletions

View File

@@ -215,12 +215,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

@@ -34,6 +34,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
@@ -119,6 +120,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(expected = ItemStreamException.class)