Mercurial > hg > mercurial
changeset 524:2ffa2c6cbaa4
Merge branch Faradi-7.1.x
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Mon, 17 Dec 2012 15:52:39 +0400 |
parents | 686b04d58c6e (current diff) 64d3b1f5ae6b (diff) |
children | 6de7b8ad3f8d |
files | mercurial-tests/src/testng.xml |
diffstat | 3 files changed, 64 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/MercurialXmlLogParser.java Thu Dec 13 12:43:31 2012 +0400 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/MercurialXmlLogParser.java Mon Dec 17 15:52:39 2012 +0400 @@ -18,7 +18,7 @@ public class MercurialXmlLogParser extends DefaultHandler { private static final String DATE_FORMAT = "EEE MMM d HH:mm:ss yyyy Z"; - private static final SimpleDateFormat ourSimpleDateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH); + private final SimpleDateFormat mySimpleDateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH); private List<ChangeSet> myChangeSets = new ArrayList<ChangeSet>(); private ChangeSet myCset = null; private StringBuilder myText = new StringBuilder(); @@ -81,7 +81,7 @@ private Date parseDate() throws SAXException { try { - return ourSimpleDateFormat.parse(getText()); + return mySimpleDateFormat.parse(getText()); } catch (ParseException e) { throw new SAXException(e); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialXmlLogParserTest.java Mon Dec 17 15:52:39 2012 +0400 @@ -0,0 +1,61 @@ +package jetbrains.buildServer.buildTriggers.vcs.mercurial; + +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.MercurialXmlLogParser; +import jetbrains.buildServer.util.TestFor; +import org.testng.annotations.Test; + +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import java.io.ByteArrayInputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.*; + +@Test +public class MercurialXmlLogParserTest { + + @TestFor(issues = {"TW-24864", "TW-24214"}) + public void parse_date() throws Exception { + final SAXParserFactory saxFactory = SAXParserFactory.newInstance(); + final List<Exception> errors = new ArrayList<Exception>(); + final CountDownLatch countDown = new CountDownLatch(1); + Runnable parseLog = new Runnable() { + public void run() { + try { + countDown.await(); + MercurialXmlLogParser parser = new MercurialXmlLogParser(); + SAXParser saxParser = saxFactory.newSAXParser(); + String logOutput = + "<?xml version=\"1.0\"?>" + + "<log>" + + "<logentry revision=\"11774\" shortnode=\"b1b6ed3cd705\">" + + "<parent revision=\"11770\" shortnode=\"7e30fc4a3cda\"/>" + + "<author original=\"Mikhail.Pilin\"/>" + + "<date>Fri Dec 14 12:22:31 2012 +0100</date>" + + "<msg xml:space=\"preserve\">Fix SDK installer.</msg>" + + "<paths>" + + "<path action=\"M\">.hgsubstate</path>" + + "</paths>" + + "</logentry>" + + "</log>"; + saxParser.parse(new ByteArrayInputStream(logOutput.getBytes("UTF-8")), parser); + parser.getChangeSets(); + } catch (Exception e) { + errors.add(e); + } + } + }; + + ExecutorService exec = Executors.newFixedThreadPool(10); + for (int i = 0; i < 10; i++) + exec.execute(parseLog); + + countDown.countDown(); + exec.shutdown(); + exec.awaitTermination(10, TimeUnit.SECONDS); + + if (!errors.isEmpty()) + throw errors.get(0); + } + +}
--- a/mercurial-tests/src/testng.xml Thu Dec 13 12:43:31 2012 +0400 +++ b/mercurial-tests/src/testng.xml Mon Dec 17 15:52:39 2012 +0400 @@ -28,6 +28,7 @@ <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.HgFileUtilTest"/> <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.SubrepoChangesTest"/> <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.HgRepoTest"/> + <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialXmlLogParserTest"/> </classes> </test> </suite>