Search in sources :

Example 21 with SAXBuilder

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

the class SvnCommand method getAllExternalURLs.

public List<SvnExternal> getAllExternalURLs() {
    CommandLine svnExternalCommand = svn(true).withArgs("propget", "--non-interactive", "svn:externals", "-R").withArg(repositoryUrl);
    ConsoleResult result = executeCommand(svnExternalCommand);
    String svnExternalConsoleOut = result.outputAsString();
    SvnInfo remoteInfo = remoteInfo(new SAXBuilder());
    String repoUrl = remoteInfo.getUrl();
    String repoRoot = remoteInfo.getRoot();
    List<SvnExternal> svnExternalList = null;
    try {
        svnExternalList = new SvnExternalParser().parse(svnExternalConsoleOut, repoUrl, repoRoot);
    } catch (RuntimeException e) {
        throw (RuntimeException) result.smudgedException(e);
    }
    return svnExternalList;
}
Also used : CommandLine.createCommandLine(com.thoughtworks.go.util.command.CommandLine.createCommandLine) SAXBuilder(org.jdom2.input.SAXBuilder)

Example 22 with SAXBuilder

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

the class SvnCommand method getBuilder.

private SAXBuilder getBuilder() {
    SAXBuilder saxBuilder = saxBuilderThreadLocal.get();
    if (saxBuilder == null) {
        saxBuilder = new SAXBuilder();
        saxBuilderThreadLocal.set(saxBuilder);
    }
    return saxBuilder;
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder)

Example 23 with SAXBuilder

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

the class SvnLogXmlParserTest method shouldGetAllModifiedFilesUnderRootPath.

@Test
public void shouldGetAllModifiedFilesUnderRootPath() {
    SvnLogXmlParser parser = new SvnLogXmlParser();
    List<Modification> materialRevisions = parser.parse(MULTIPLE_FILES, "", new SAXBuilder());
    Modification mod = materialRevisions.get(0);
    List<ModifiedFile> files = mod.getModifiedFiles();
    assertThat(files.size(), is(2));
    ModifiedFile file = files.get(0);
    assertThat(file.getFileName(), is("/trunk/revision3.txt"));
    assertThat(file.getAction(), is(ModifiedAction.added));
    file = files.get(1);
    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 24 with SAXBuilder

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

the class SvnLogXmlParserTest method shouldParse.

@Test
public void shouldParse() throws ParseException {
    SvnLogXmlParser parser = new SvnLogXmlParser();
    List<Modification> materialRevisions = parser.parse(XML, "", new SAXBuilder());
    assertThat(materialRevisions.size(), is(1));
    Modification mod = materialRevisions.get(0);
    assertThat(mod.getRevision(), is("3"));
    assertThat(mod.getUserName(), is("cceuser"));
    assertThat(mod.getModifiedTime(), is(convertDate("2008-03-11T07:52:41.162075Z")));
    assertThat(mod.getComment(), is("[Liyanhui & Gabbar] Checked in new file for test"));
    List<ModifiedFile> files = mod.getModifiedFiles();
    assertThat(files.size(), is(1));
    ModifiedFile file = files.get(0);
    assertThat(file.getFileName(), is("/trunk/revision3.txt"));
    assertThat(file.getAction(), is(ModifiedAction.added));
}
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 25 with SAXBuilder

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

the class SvnLogXmlParserTest method shouldParseSvnInfoOutputToConstructUrlToRemoteUUIDMapping.

@Test
public void shouldParseSvnInfoOutputToConstructUrlToRemoteUUIDMapping() {
    final SvnLogXmlParser svnLogXmlParser = new SvnLogXmlParser();
    final String svnInfoOutput = "<?xml version=\"1.0\"?>\n" + "<info>\n" + "<entry\n" + "   kind=\"dir\"\n" + "   path=\"trunk\"\n" + "   revision=\"3432\">\n" + "<url>http://gears.googlecode.com/svn/trunk</url>\n" + "<repository>\n" + "<root>http://gears.googlecode.com/svn</root>\n" + "<uuid>fe895e04-df30-0410-9975-d76d301b4276</uuid>\n" + "</repository>\n" + "<commit\n" + "   revision=\"3430\">\n" + "<author>gears.daemon</author>\n" + "<date>2010-10-06T02:00:50.517477Z</date>\n" + "</commit>\n" + "</entry>\n" + "</info>";
    final HashMap<String, String> map = svnLogXmlParser.parseInfoToGetUUID(svnInfoOutput, "http://gears.googlecode.com/svn/trunk", new SAXBuilder());
    assertThat(map.size(), is(1));
    assertThat(map.get("http://gears.googlecode.com/svn/trunk"), is("fe895e04-df30-0410-9975-d76d301b4276"));
}
Also used : 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