### Question:
StoreXML { void save(List<Entry> list) { JAXBContext jaxbContext; try { jaxbContext = JAXBContext.newInstance(Entries.class); Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); jaxbMarshaller.marshal(new Entries(list), this.target); } catch (JAXBException e) { e.printStackTrace(); } } StoreXML(File target);   }### Answer:
@Test public void testSave() { List<StoreXML.Entry> inputData = new ArrayList<>(); for (int i = 0; i < 2; i++) { inputData.add(new StoreXML.Entry(i)); } File target = new File(getClass().getClassLoader().getResource("StoreXMLTest.xml").getFile()); StoreXML testStore = new StoreXML(target); testStore.save(inputData); StringBuilder result = new StringBuilder(); try (Scanner scanner = new Scanner(target)) { while (scanner.hasNext()) { result.append(scanner.nextLine()); } } catch (FileNotFoundException e) { e.printStackTrace(); } StringBuilder expect = new StringBuilder(); expect .append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>") .append("<entries>") .append(" <entry>") .append(" <field>0</field>") .append(" </entry>") .append(" <entry>") .append(" <field>1</field>") .append(" </entry>") .append("</entries>"); assertThat(result.toString(), is(expect.toString())); }