Search in sources :

Example 26 with SAXBuilder

use of org.jdom2.input.SAXBuilder in project gocd by gocd.

the class SvnLogXmlParserTest method shouldReportSvnOutputWhenErrorsHappen.

@Test
public void shouldReportSvnOutputWhenErrorsHappen() {
    SvnLogXmlParser parser = new SvnLogXmlParser();
    try {
        parser.parse("invalid xml", "", new SAXBuilder());
        fail("should have failed when invalid xml is parsed");
    } catch (Exception e) {
        assertThat(e.getMessage(), containsString("invalid xml"));
    }
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) IOException(java.io.IOException) ParseException(java.text.ParseException) Test(org.junit.Test)

Example 27 with SAXBuilder

use of org.jdom2.input.SAXBuilder in project gocd by gocd.

the class SvnLogXmlParserTest method shouldFilterModifiedFilesByPath.

@Test
public void shouldFilterModifiedFilesByPath() {
    SvnLogXmlParser parser = new SvnLogXmlParser();
    List<Modification> materialRevisions = parser.parse(MULTIPLE_FILES, "/branch", new SAXBuilder());
    Modification mod = materialRevisions.get(0);
    List<ModifiedFile> files = mod.getModifiedFiles();
    assertThat(files.size(), is(1));
    ModifiedFile file = files.get(0);
    assertThat(file.getFileName(), is("/branch/1.1/readme.txt"));
    assertThat(file.getAction(), is(ModifiedAction.deleted));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) SAXBuilder(org.jdom2.input.SAXBuilder) ModifiedFile(com.thoughtworks.go.domain.materials.ModifiedFile) Test(org.junit.Test)

Example 28 with SAXBuilder

use of org.jdom2.input.SAXBuilder in project gocd by gocd.

the class SvnLogXmlParserTest method shouldThrowUpWhenSvnInfoOutputIsInvalidToMapUrlToUUID.

@Test(expected = RuntimeException.class)
public void shouldThrowUpWhenSvnInfoOutputIsInvalidToMapUrlToUUID() {
    final SvnLogXmlParser svnLogXmlParser = new SvnLogXmlParser();
    svnLogXmlParser.parseInfoToGetUUID("Svn threw up and it's drunk", "does not matter", new SAXBuilder());
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) Test(org.junit.Test)

Example 29 with SAXBuilder

use of org.jdom2.input.SAXBuilder in project gocd by gocd.

the class SvnLogXmlParserTest method shouldParseSvnLogContainingNullComments.

@Test
public void shouldParseSvnLogContainingNullComments() throws IOException {
    String xml;
    try (InputStream stream = getClass().getResourceAsStream("jemstep_svn_log.xml")) {
        xml = IOUtils.toString(stream, UTF_8);
    }
    SvnLogXmlParser parser = new SvnLogXmlParser();
    List<Modification> revisions = parser.parse(xml, "", new SAXBuilder());
    assertThat(revisions.size(), is(43));
    Modification modWithoutComment = null;
    for (Modification revision : revisions) {
        if (revision.getRevision().equals("7815")) {
            modWithoutComment = revision;
        }
    }
    assertThat(modWithoutComment.getComment(), is(nullValue()));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) SAXBuilder(org.jdom2.input.SAXBuilder) InputStream(java.io.InputStream) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 30 with SAXBuilder

use of org.jdom2.input.SAXBuilder in project gocd by gocd.

the class SvnLogXmlParserTest method shouldParseBJCruiseLogCorrectly.

@Test
public void shouldParseBJCruiseLogCorrectly() {
    String firstChangeLog = "<?xml version=\"1.0\"?>\n" + "<log>\n" + "<logentry\n" + "   revision=\"11238\">\n" + "<author>yxchu</author>\n" + "<date>2008-10-21T14:00:16.598195Z</date>\n" + "<paths>\n" + "<path\n" + "   action=\"M\">/trunk/test/unit/card_selection_test.rb</path>\n" + "<path\n" + "   action=\"M\">/trunk/test/functional/cards_controller_quick_add_test.rb</path>\n" + "<path\n" + "   action=\"M\">/trunk/app/controllers/cards_controller.rb</path>\n" + "</paths>\n" + "<msg>#2761, fix random test failure and add quick add card type to session</msg>\n" + "</logentry>\n" + "</log>";
    String secondChangeLog = "<?xml version=\"1.0\"?>\n" + "<log>\n" + "<logentry\n" + "   revision=\"11239\">\n" + "<author>yxchu</author>\n" + "<date>2008-10-21T14:00:36.209014Z</date>\n" + "<paths>\n" + "<path\n" + "   action=\"M\">/trunk/test/unit/card_selection_test.rb</path>\n" + "</paths>\n" + "<msg>still fix test</msg>\n" + "</logentry>\n" + "<logentry\n" + "   revision=\"11240\">\n" + "<author>yxchu</author>\n" + "<date>2008-10-21T14:00:47.614448Z</date>\n" + "<paths>\n" + "<path\n" + "   action=\"M\">/trunk/test/unit/card_selection_test.rb</path>\n" + "</paths>\n" + "<msg>fix test remove messaging helper</msg>\n" + "</logentry>\n" + "</log>";
    SvnLogXmlParser parser = new SvnLogXmlParser();
    List<Modification> mods = parser.parse(firstChangeLog, ".", new SAXBuilder());
    assertThat(mods.get(0).getUserName(), is("yxchu"));
    List<Modification> mods2 = parser.parse(secondChangeLog, ".", new SAXBuilder());
    assertThat(mods2.size(), is(2));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) SAXBuilder(org.jdom2.input.SAXBuilder) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Aggregations

SAXBuilder (org.jdom2.input.SAXBuilder)60 Document (org.jdom2.Document)35 Element (org.jdom2.Element)21 Test (org.junit.Test)20 IOException (java.io.IOException)14 File (java.io.File)12 JDOMException (org.jdom2.JDOMException)10 Modification (com.thoughtworks.go.domain.materials.Modification)7 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)7 BufferedInputStream (java.io.BufferedInputStream)5 ParseException (java.text.ParseException)5 FileInputStream (java.io.FileInputStream)4 InputStream (java.io.InputStream)4 StringReader (java.io.StringReader)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ModifiedFile (com.thoughtworks.go.domain.materials.ModifiedFile)3 NoProcessSpecifiedException (de.hpi.bpt.scylla.creation.SimulationConfiguration.SimulationConfigurationCreator.NoProcessSpecifiedException)3 NotAuthorizedToOverrideException (de.hpi.bpt.scylla.creation.SimulationConfiguration.SimulationConfigurationCreator.NotAuthorizedToOverrideException)3 FileNotFoundException (java.io.FileNotFoundException)3