Mercurial > hg > mercurial
view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialXmlLogParserTest.java @ 1124:a14a2f7e74d8 development/2024.03.x tip
2024.03.x branch is created
author | Nadia Burnasheva <nadezhda.burnasheva@jetbrains.com> |
---|---|
date | Thu, 15 Feb 2024 11:33:35 +0100 |
parents | 10dc26b32c35 |
children |
line wrap: on
line source
/* * Copyright 2000-2018 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ 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.nio.charset.StandardCharsets; 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<>(); final CountDownLatch countDown = new CountDownLatch(1); Runnable parseLog = () -> { 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(StandardCharsets.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); } }