Pavel@95: /* Pavel@95: * Copyright 2000-2010 JetBrains s.r.o. Pavel@95: * Pavel@95: * Licensed under the Apache License, Version 2.0 (the "License"); Pavel@95: * you may not use this file except in compliance with the License. Pavel@95: * You may obtain a copy of the License at Pavel@95: * Pavel@95: * http://www.apache.org/licenses/LICENSE-2.0 Pavel@95: * Pavel@95: * Unless required by applicable law or agreed to in writing, software Pavel@95: * distributed under the License is distributed on an "AS IS" BASIS, Pavel@95: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Pavel@95: * See the License for the specific language governing permissions and Pavel@95: * limitations under the License. Pavel@95: */ Pavel@34: package jetbrains.buildServer.buildTriggers.vcs.mercurial; Pavel@34: Pavel@34: import jetbrains.buildServer.MockSupport; Pavel@34: import jetbrains.buildServer.TempFiles; Pavel@34: import jetbrains.buildServer.vcs.impl.VcsRootImpl; Pavel@34: import jetbrains.buildServer.vcs.patches.PatchTestCase; Pavel@57: import org.jetbrains.annotations.NotNull; Pavel@34: import org.testng.annotations.AfterMethod; Pavel@34: import org.testng.annotations.BeforeMethod; Pavel@34: Pavel@34: import java.io.File; Pavel@34: import java.io.IOException; Pavel@34: Pavel@34: /** Pavel@34: * @author Pavel.Sher Pavel@34: * Date: 31.07.2008 Pavel@34: */ Pavel@34: public abstract class BaseMercurialTestCase extends PatchTestCase { Pavel@34: protected TempFiles myTempFiles; Pavel@34: protected MockSupport myMockSupport; Pavel@34: Pavel@34: @Override Pavel@34: @BeforeMethod Pavel@34: protected void setUp() throws Exception { Pavel@34: super.setUp(); Pavel@34: Pavel@34: myMockSupport = new MockSupport(); Pavel@34: myMockSupport.setUpMocks(); Pavel@34: myTempFiles = new TempFiles(); Pavel@34: } Pavel@34: Pavel@34: @AfterMethod Pavel@34: protected void tearDown() throws Exception { Pavel@34: myMockSupport.tearDownMocks(); Pavel@34: myTempFiles.cleanup(); Pavel@34: } Pavel@34: Pavel@90: protected VcsRootImpl createVcsRoot(@NotNull String repPath) throws IOException { Pavel@34: VcsRootImpl vcsRoot = new VcsRootImpl(1, Constants.VCS_NAME); dmitry@128: vcsRoot.addProperty(Constants.HG_COMMAND_PATH_PROP, new File(Util.getHgPath()).getAbsolutePath()); Pavel@44: File repository = LocalRepositoryUtil.prepareRepository(repPath); Pavel@34: vcsRoot.addProperty(Constants.REPOSITORY_PROP, repository.getAbsolutePath()); Pavel@34: return vcsRoot; Pavel@34: } Pavel@44: Pavel@90: protected VcsRootImpl createVcsRoot(@NotNull String repPath, @NotNull String branchName) throws IOException { Pavel@90: VcsRootImpl vcsRoot = createVcsRoot(repPath); Pavel@57: vcsRoot.addProperty(Constants.BRANCH_NAME_PROP, branchName); Pavel@57: return vcsRoot; Pavel@57: } Pavel@57: Pavel@90: protected void cleanRepositoryAfterTest(@NotNull String repPath) { Pavel@90: LocalRepositoryUtil.forgetRepository(repPath); Pavel@44: } Pavel@44: Pavel@90: protected String simpleRepo() { Pavel@90: return new File("mercurial-tests/testData/rep1").getAbsolutePath(); Pavel@44: } Pavel@34: }