Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ public void whenJavaGotFromXmlStr_thenCorrect() throws IOException {
public void whenJavaGotFromXmlFile_thenCorrect() throws IOException {
File file = new File("src/test/resources/simple_bean.xml");
XmlMapper xmlMapper = new XmlMapper();
String xml = inputStreamToString(new FileInputStream(file));
SimpleBean value = xmlMapper.readValue(xml, SimpleBean.class);
SimpleBean value = xmlMapper.readValue(file, SimpleBean.class);
assertTrue(value.getX() == 1 && value.getY() == 2);
}

Expand Down Expand Up @@ -122,19 +121,6 @@ public void whenJavaSerializedToXmlFile_thenSuccess() throws IOException {
xmlMapper.writeValue(byteArrayOutputStream, person);
assertEquals(expectedXml, byteArrayOutputStream.toString());
}

private static String inputStreamToString(InputStream is) throws IOException {
BufferedReader br;
StringBuilder sb = new StringBuilder();

String line;
br = new BufferedReader(new InputStreamReader(is));
while ((line = br.readLine()) != null) {
sb.append(line);
}
br.close();
return sb.toString();
}
}

class SimpleBean {
Expand Down