Mercurial > hg > mercurial
view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/BaseMercurialTestCase.java @ 128:5ff5ff61f7d4
Extract Util class and method getHgPath(). Now tests can be ran using installed hg in the system.
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Tue, 28 Sep 2010 15:00:50 +0400 |
parents | 1c7e94c0ad2f |
children | 5198b02fc5e9 |
line wrap: on
line source
/* * Copyright 2000-2010 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.MockSupport; import jetbrains.buildServer.TempFiles; import jetbrains.buildServer.vcs.impl.VcsRootImpl; import jetbrains.buildServer.vcs.patches.PatchTestCase; import org.jetbrains.annotations.NotNull; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import java.io.File; import java.io.IOException; /** * @author Pavel.Sher * Date: 31.07.2008 */ public abstract class BaseMercurialTestCase extends PatchTestCase { protected TempFiles myTempFiles; protected MockSupport myMockSupport; @Override @BeforeMethod protected void setUp() throws Exception { super.setUp(); myMockSupport = new MockSupport(); myMockSupport.setUpMocks(); myTempFiles = new TempFiles(); } @AfterMethod protected void tearDown() throws Exception { myMockSupport.tearDownMocks(); myTempFiles.cleanup(); } protected VcsRootImpl createVcsRoot(@NotNull String repPath) throws IOException { VcsRootImpl vcsRoot = new VcsRootImpl(1, Constants.VCS_NAME); vcsRoot.addProperty(Constants.HG_COMMAND_PATH_PROP, new File(Util.getHgPath()).getAbsolutePath()); File repository = LocalRepositoryUtil.prepareRepository(repPath); vcsRoot.addProperty(Constants.REPOSITORY_PROP, repository.getAbsolutePath()); return vcsRoot; } protected VcsRootImpl createVcsRoot(@NotNull String repPath, @NotNull String branchName) throws IOException { VcsRootImpl vcsRoot = createVcsRoot(repPath); vcsRoot.addProperty(Constants.BRANCH_NAME_PROP, branchName); return vcsRoot; } protected void cleanRepositoryAfterTest(@NotNull String repPath) { LocalRepositoryUtil.forgetRepository(repPath); } protected String simpleRepo() { return new File("mercurial-tests/testData/rep1").getAbsolutePath(); } }