view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/BaseMercurialTestCase.java @ 266:643fa1236f4e

Fix file encoding * * * Fix line-endings
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Wed, 20 Jul 2011 12:04:08 +0400
parents 5198b02fc5e9
children 8c10f5cec37d
line wrap: on
line source
/*
 * Copyright 2000-2011 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();
  }
}