Mercurial > hg > mercurial
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 | 1 /* |
2 * Copyright 2000-2010 JetBrains s.r.o. | |
3 * | |
4 * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 * you may not use this file except in compliance with the License. | |
6 * You may obtain a copy of the License at | |
7 * | |
8 * http://www.apache.org/licenses/LICENSE-2.0 | |
9 * | |
10 * Unless required by applicable law or agreed to in writing, software | |
11 * distributed under the License is distributed on an "AS IS" BASIS, | |
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 * See the License for the specific language governing permissions and | |
14 * limitations under the License. | |
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 | 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 | 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 | 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 | 60 |
90 | 61 protected VcsRootImpl createVcsRoot(@NotNull String repPath, @NotNull String branchName) throws IOException { |
62 VcsRootImpl vcsRoot = createVcsRoot(repPath); | |
57 | 63 vcsRoot.addProperty(Constants.BRANCH_NAME_PROP, branchName); |
64 return vcsRoot; | |
65 } | |
66 | |
90 | 67 protected void cleanRepositoryAfterTest(@NotNull String repPath) { |
68 LocalRepositoryUtil.forgetRepository(repPath); | |
44 | 69 } |
70 | |
90 | 71 protected String simpleRepo() { |
72 return new File("mercurial-tests/testData/rep1").getAbsolutePath(); | |
44 | 73 } |
34
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
74 } |