Skip to content

Commit

Permalink
Fix for setting name of StaxEventItemReader at build
Browse files Browse the repository at this point in the history
  • Loading branch information
parikshitdutta authored and fmbenhassine committed Sep 25, 2020
1 parent 67a0c7a commit 8e821fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,10 @@ public StaxEventItemReader<T> build() {
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
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
Expand Down Expand Up @@ -119,6 +120,9 @@ public void testConfiguration() throws Exception {
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)
Expand Down

0 comments on commit 8e821fe

Please sign in to comment.