Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 056ef01

Browse files
authored
Merge pull request #281 from SThomasP/main
Add the option to load a reader as an Unknown parameter
2 parents 9f221f7 + 6218462 commit 056ef01

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

xmlunit-core/src/main/java/org/xmlunit/builder/Input.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ public static Builder from(Object object) {
150150
xml = Input.fromChannel((ReadableByteChannel) object);
151151
} else if (object instanceof Path) {
152152
xml = Input.fromPath((Path) object);
153+
} else if (object instanceof Reader) {
154+
xml = Input.fromReader((Reader) object);
153155
} else {
154156
// assume it is a JaxB-Object.
155157
xml = Input.fromJaxb(object);

xmlunit-core/src/test/java/org/xmlunit/builder/InputTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ private static Document parse(Source s) throws Exception {
164164
FileChannel fc = is.getChannel()) {
165165
allIsWellFor(Input.from(fc).build());
166166
}
167+
//from Reader
168+
try (FileReader r = new FileReader(TestResources.ANIMAL_FILE)) {
169+
allIsWellFor(Input.from(r).build());
170+
}
167171
// from Path
168172
allIsWellFor(Input.from(new File(TestResources.ANIMAL_FILE).toPath()).build());
169173
}

0 commit comments

Comments
 (0)