annotate 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
rev   line source
95
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 90
diff changeset
1 /*
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 90
diff changeset
2 * Copyright 2000-2010 JetBrains s.r.o.
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 90
diff changeset
3 *
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 90
diff changeset
4 * Licensed under the Apache License, Version 2.0 (the "License");
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 90
diff changeset
5 * you may not use this file except in compliance with the License.
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 90
diff changeset
6 * You may obtain a copy of the License at
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 90
diff changeset
7 *
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 90
diff changeset
8 * http://www.apache.org/licenses/LICENSE-2.0
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 90
diff changeset
9 *
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 90
diff changeset
10 * Unless required by applicable law or agreed to in writing, software
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 90
diff changeset
11 * distributed under the License is distributed on an "AS IS" BASIS,
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 90
diff changeset
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 90
diff changeset
13 * See the License for the specific language governing permissions and
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 90
diff changeset
14 * limitations under the License.
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 90
diff changeset
15 */
34
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
16 package jetbrains.buildServer.buildTriggers.vcs.mercurial;
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
17
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
18 import jetbrains.buildServer.MockSupport;
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
19 import jetbrains.buildServer.TempFiles;
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
20 import jetbrains.buildServer.vcs.impl.VcsRootImpl;
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
21 import jetbrains.buildServer.vcs.patches.PatchTestCase;
57
99e757f2527b branches support
Pavel.Sher
parents: 44
diff changeset
22 import org.jetbrains.annotations.NotNull;
34
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
23 import org.testng.annotations.AfterMethod;
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
24 import org.testng.annotations.BeforeMethod;
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
25
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
26 import java.io.File;
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
27 import java.io.IOException;
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
28
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
29 /**
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
30 * @author Pavel.Sher
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
31 * Date: 31.07.2008
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
32 */
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
33 public abstract class BaseMercurialTestCase extends PatchTestCase {
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
34 protected TempFiles myTempFiles;
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
35 protected MockSupport myMockSupport;
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
36
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
37 @Override
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
38 @BeforeMethod
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
39 protected void setUp() throws Exception {
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
40 super.setUp();
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
41
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
42 myMockSupport = new MockSupport();
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
43 myMockSupport.setUpMocks();
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
44 myTempFiles = new TempFiles();
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
45 }
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
46
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
47 @AfterMethod
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
48 protected void tearDown() throws Exception {
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
49 myMockSupport.tearDownMocks();
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
50 myTempFiles.cleanup();
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
51 }
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
52
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 57
diff changeset
53 protected VcsRootImpl createVcsRoot(@NotNull String repPath) throws IOException {
34
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
54 VcsRootImpl vcsRoot = new VcsRootImpl(1, Constants.VCS_NAME);
128
5ff5ff61f7d4 Extract Util class and method getHgPath(). Now tests can be ran using installed hg in the system.
Dmitry Neverov <dmitry.neverov@jetbrains.com>
parents: 116
diff changeset
55 vcsRoot.addProperty(Constants.HG_COMMAND_PATH_PROP, new File(Util.getHgPath()).getAbsolutePath());
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 34
diff changeset
56 File repository = LocalRepositoryUtil.prepareRepository(repPath);
34
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
57 vcsRoot.addProperty(Constants.REPOSITORY_PROP, repository.getAbsolutePath());
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
58 return vcsRoot;
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
59 }
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 34
diff changeset
60
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 57
diff changeset
61 protected VcsRootImpl createVcsRoot(@NotNull String repPath, @NotNull String branchName) throws IOException {
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 57
diff changeset
62 VcsRootImpl vcsRoot = createVcsRoot(repPath);
57
99e757f2527b branches support
Pavel.Sher
parents: 44
diff changeset
63 vcsRoot.addProperty(Constants.BRANCH_NAME_PROP, branchName);
99e757f2527b branches support
Pavel.Sher
parents: 44
diff changeset
64 return vcsRoot;
99e757f2527b branches support
Pavel.Sher
parents: 44
diff changeset
65 }
99e757f2527b branches support
Pavel.Sher
parents: 44
diff changeset
66
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 57
diff changeset
67 protected void cleanRepositoryAfterTest(@NotNull String repPath) {
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 57
diff changeset
68 LocalRepositoryUtil.forgetRepository(repPath);
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 34
diff changeset
69 }
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 34
diff changeset
70
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 57
diff changeset
71 protected String simpleRepo() {
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 57
diff changeset
72 return new File("mercurial-tests/testData/rep1").getAbsolutePath();
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 34
diff changeset
73 }
34
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff changeset
74 }