Mercurial > hg > mercurial
view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Util.java @ 430:3600b68a4c0c
TW-21403 better error message when hg not found
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Fri, 11 May 2012 19:33:48 +0400 |
parents | 743dc1646555 |
children | d0f80762461a |
line wrap: on
line source
package jetbrains.buildServer.buildTriggers.vcs.mercurial; import jetbrains.buildServer.serverSide.BuildServerListener; import jetbrains.buildServer.serverSide.SBuildServer; import jetbrains.buildServer.util.EventDispatcher; import jetbrains.buildServer.util.cache.ResetCacheRegister; import jetbrains.buildServer.vcs.VcsManager; import org.jetbrains.annotations.NotNull; import org.jmock.Expectations; import org.jmock.Mockery; import java.io.File; import java.io.IOException; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; /** * @author dmitry.neverov */ public final class Util { private Util() {} public static String getHgPath() throws IOException { String providedHg = System.getenv(Constants.HG_PATH_ENV); if (providedHg != null) { return providedHg; } else { return new File("mercurial-tests/testData/bin/hg.exe").getAbsolutePath(); } } public static MercurialVcsSupport createMercurialServerSupport(@NotNull Mockery context, ServerPluginConfig config) throws IOException { return createMercurialServerSupport(context, config, new RepoFactory(config)); } public static MercurialVcsSupport createMercurialServerSupport(@NotNull Mockery context, @NotNull ServerPluginConfig config, @NotNull RepoFactory repoFactory) throws IOException { VcsManager vcsManager = context.mock(VcsManager.class); final SBuildServer server = context.mock(SBuildServer.class); final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); context.checking(new Expectations() {{ allowing(server).getExecutor(); will(returnValue(executor)); }}); EventDispatcher<BuildServerListener> dispatcher = EventDispatcher.create(BuildServerListener.class); HgVcsRootFactory hgVcsRootFactory = new HgVcsRootFactory(config); MirrorManagerImpl mirrorManager = new MirrorManagerImpl(config); ServerHgPathProvider hgPathProvider = new ServerHgPathProvider(config); HgTestConnectionSupport testConnection = new HgTestConnectionSupport(hgVcsRootFactory, repoFactory, mirrorManager, hgPathProvider); return new MercurialVcsSupport(vcsManager, server, dispatcher, new ResetCacheRegister(), config, hgPathProvider, repoFactory, mirrorManager, hgVcsRootFactory, testConnection); } }