### Question:
ChangeSetReader extends ChangeLogParser { @Override public ChangeLogSet parse(final Run build, final RepositoryBrowser<?> browser, final File changelogFile) throws IOException, SAXException { try (FileInputStream stream = new FileInputStream(changelogFile); Reader reader = new InputStreamReader(stream, Charset.defaultCharset())) { return parse(build, browser, reader); } }  @Override ChangeLogSet parse(final Run build, final RepositoryBrowser<?> browser, final File changelogFile); ChangeLogSet parse(final Run build, final RepositoryBrowser<?> browser, final Reader reader);  }### Answer:
@Test public void assertParsingTwoXmlChangeSets() throws Exception { Reader reader = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?><changelog>" + "<changeset version=\"1122\">" + "<date>2009-01-12T00:00:00Z</date>" + "<user>snd\\user</user>" + "<comment>comment</comment>" + "<items>" + "<item action=\"add\">path</item>" + "<item action=\"delete\">path2</item>" + "</items>" + "</changeset>" + "</changelog>"); ChangeSetReader changesetReader = new ChangeSetReader(); ChangeLogSet logset = changesetReader.parse(null, null, reader); ChangeSet changeset = logset.iterator().next(); assertEquals("User is incorrect", "user", changeset.getUser()); assertEquals("Domain is incorrect", "snd", changeset.getDomain()); assertEquals("Comment is incorrect", "comment", changeset.getComment()); assertEquals("Version is incorrect", "1122", changeset.getVersion()); assertEquals("Date is incorrect", Util.getCalendar(2009, 1, 12).getTime(), changeset.getDate()); assertEquals("Number of items in change set was incorrect", 2, changeset.getItems().size()); Item item = changeset.getItems().get(0); assertEquals("Action is incorrect", "add", item.getAction()); assertEquals("Path is incorrect", "path", item.getPath()); item = changeset.getItems().get(1); assertEquals("Action is incorrect", "delete", item.getAction()); assertEquals("Path is incorrect", "path2", item.getPath()); }
@Test public void assertItemHasParent() throws Exception { Reader reader = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?><changelog>" + "<changeset version=\"1122\">" + "<date>2009-01-12T00:00:00Z</date>" + "<user>snd\\user</user>" + "<comment>comment</comment>" + "<items>" + "<item action=\"add\">path</item>" + "<item action=\"delete\">path2</item>" + "</items>" + "</changeset>" + "</changelog>"); ChangeSetReader changesetReader = new ChangeSetReader(); ChangeLogSet logset = changesetReader.parse(null, null, reader); ChangeSet changeset = logset.iterator().next(); Item item = changeset.getItems().get(0); assertNotNull("The item's parent change set cant be null", item.getParent()); assertSame("The item's parent is not the same as the change set it belongs to", changeset, item.getParent()); }
@Test public void assertParsingOfKeywordCheckedInByIsParsed() throws Exception { Reader reader = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?><changelog>" + "<changeset version=\"1122\">" + "<date>2009-01-12T00:00:00Z</date>" + "<user>snd\\user</user>" + "<checked_in_by_user>snd\\other_user</checked_in_by_user>" + "<comment>comment</comment>" + "<items>" + "<item action=\"add\">path</item>" + "<item action=\"delete\">path2</item>" + "</items>" + "</changeset>" + "</changelog>"); ChangeSetReader changesetReader = new ChangeSetReader(); ChangeLogSet logset = changesetReader.parse(null, null, reader); ChangeSet changeset = logset.iterator().next(); assertEquals("Checked in by user is incorrect", "other_user", changeset.getCheckedInBy()); }