Search in sources :

Example 46 with SAXBuilder

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

the class SvnLogXmlParserTest method shouldParseLogEntryWithoutComment.

@Test
public void shouldParseLogEntryWithoutComment() throws ParseException {
    SvnLogXmlParser parser = new SvnLogXmlParser();
    List<Modification> materialRevisions = parser.parse("<?xml version=\"1.0\"?>\n" + "<log>\n" + "<logentry\n" + "   revision=\"3\">\n" + "<author>cceuser</author>\n" + "<date>2008-03-11T07:52:41.162075Z</date>\n" + "<paths>\n" + "<path\n" + "   action=\"A\">/trunk/revision3.txt</path>\n" + "</paths>\n" + "</logentry>\n" + "</log>", "", new SAXBuilder());
    assertThat(materialRevisions.size(), is(1));
    Modification mod = materialRevisions.get(0);
    assertThat(mod.getRevision(), is("3"));
    assertThat(mod.getComment(), is(nullValue()));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) SAXBuilder(org.jdom2.input.SAXBuilder) Test(org.junit.Test)

Example 47 with SAXBuilder

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

the class SvnLogXmlParserTest method shouldParseLogWithEmptyRevision.

@Test
public void shouldParseLogWithEmptyRevision() throws ParseException {
    SvnLogXmlParser parser = new SvnLogXmlParser();
    List<Modification> materialRevisions = parser.parse("<?xml version=\"1.0\"?>\n" + "<log>\n" + "<logentry\n" + "   revision=\"2\">\n" + "</logentry>\n" + "<logentry\n" + "   revision=\"3\">\n" + "<author>cceuser</author>\n" + "<date>2008-03-11T07:52:41.162075Z</date>\n" + "<paths>\n" + "<path\n" + "   action=\"A\">/trunk/revision3.txt</path>\n" + "</paths>\n" + "</logentry>\n" + "</log>", "", new SAXBuilder());
    assertThat(materialRevisions.size(), is(1));
    Modification mod = materialRevisions.get(0);
    assertThat(mod.getRevision(), is("3"));
    assertThat(mod.getComment(), is(nullValue()));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) SAXBuilder(org.jdom2.input.SAXBuilder) Test(org.junit.Test)

Example 48 with SAXBuilder

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

the class SvnCommandRemoteTest method shouldMaskPassword_remoteInfo.

@Test
public void shouldMaskPassword_remoteInfo() {
    try {
        badUserNameCommand().remoteInfo(new SAXBuilder());
        fail("should have failed");
    } catch (Exception e) {
        assertThat("Plain text password detected!", e.getMessage().contains(HARRYS_PASSWORD), Is.is(false));
    }
    try {
        badPasswordCommand().remoteInfo(new SAXBuilder());
        fail("should have failed");
    } catch (Exception e) {
        assertThat("Plain text password detected!", e.getMessage().contains("some_bad_password"), Is.is(false));
    }
    try {
        badUrlCommand().remoteInfo(new SAXBuilder());
        fail("should have failed");
    } catch (Exception e) {
        assertThat("Plain text password detected!", e.getMessage().contains(HARRYS_PASSWORD), Is.is(false));
    }
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) IOException(java.io.IOException) Test(org.junit.Test)

Example 49 with SAXBuilder

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

the class SvnCommandRemoteTest method shouldSupportSvnInfo.

@Test
public void shouldSupportSvnInfo() throws Exception {
    SvnCommand.SvnInfo info = command.remoteInfo(new SAXBuilder());
    assertThat(info.getUrl(), is(repository.getUrl()));
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) Test(org.junit.Test)

Example 50 with SAXBuilder

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

the class SvnCommandTest method shouldParseSvnInfoWithUTF8ChineseNameInUrl.

@Test
public void shouldParseSvnInfoWithUTF8ChineseNameInUrl() throws Exception {
    String output = "<?xml version=\"1.0\"?>\n" + "<info>\n" + "<entry\n" + "  kind=\"dir\"\n" + "  path=\"司徒空在此\"\n" + "  revision=\"4\">\n" + "<url>file:///home/cceuser/bigfs/projects/cruise/common/test-resources/unit/data/svnrepo/end2end/%E5%8F%B8%E5%BE%92%E7%A9%BA%E5%9C%A8%E6%AD%A4</url>\n" + "<repository>\n" + "<root>file:///home/cceuser/bigfs/projects/cruise/common/test-resources/unit/data/svnrepo/end2end</root>\n" + "<uuid>f953918e-915c-4459-8d4c-83860cce9d9a</uuid>\n" + "</repository>\n" + "<commit\n" + "  revision=\"4\">\n" + "<author></author>\n" + "<date>2009-05-31T04:14:44.223393Z</date>\n" + "</commit>\n" + "</entry>\n" + "</info>";
    SvnCommand.SvnInfo svnInfo = new SvnCommand.SvnInfo();
    svnInfo.parse(output, new SAXBuilder());
    assertThat(svnInfo.getPath(), is("/司徒空在此"));
    assertThat(svnInfo.getUrl(), is("file:///home/cceuser/bigfs/projects/cruise/common/test-resources/unit/data/svnrepo/end2end/%E5%8F%B8%E5%BE%92%E7%A9%BA%E5%9C%A8%E6%AD%A4"));
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) CoreMatchers.containsString(org.hamcrest.CoreMatchers.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