changeset 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 2159ab641618
children 021589a73f03
files mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/BaseMercurialTestCase.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Util.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTestCase.java
diffstat 3 files changed, 26 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/BaseMercurialTestCase.java	Tue Sep 28 13:38:23 2010 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/BaseMercurialTestCase.java	Tue Sep 28 15:00:50 2010 +0400
@@ -52,21 +52,12 @@
 
   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(getHgPath()).getAbsolutePath());
+    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;
   }
 
-  private String getHgPath() throws IOException {
-    String providedHg = System.getenv(Constants.HG_PATH_ENV);
-    if (providedHg != null) {
-      return providedHg;
-    } else {
-      return "mercurial-tests/testData/bin/hg.exe";
-    }
-  }
-
   protected VcsRootImpl createVcsRoot(@NotNull String repPath, @NotNull String branchName) throws IOException {
     VcsRootImpl vcsRoot = createVcsRoot(repPath);
     vcsRoot.addProperty(Constants.BRANCH_NAME_PROP, branchName);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Util.java	Tue Sep 28 15:00:50 2010 +0400
@@ -0,0 +1,21 @@
+package jetbrains.buildServer.buildTriggers.vcs.mercurial;
+
+import java.io.IOException;
+
+/**
+ * @author dmitry.neverov
+ */
+public final class Util {
+
+  private Util() {}
+
+  public static String getHgPath() throws IOException {
+    String providedHg = System.getenv(Constants.HG_PATH_ENV);
+    if (providedHg != null) {
+      return providedHg;
+    } else {
+      return "mercurial-tests/testData/bin/hg.exe";
+    }
+  }
+
+}
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTestCase.java	Tue Sep 28 13:38:23 2010 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTestCase.java	Tue Sep 28 15:00:50 2010 +0400
@@ -17,8 +17,9 @@
 
 import jetbrains.buildServer.BaseTestCase;
 import jetbrains.buildServer.TempFiles;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.Constants;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.LocalRepositoryUtil;
-import jetbrains.buildServer.buildTriggers.vcs.mercurial.Constants;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.Util;
 import jetbrains.buildServer.vcs.VcsException;
 import jetbrains.buildServer.vcs.VcsRoot;
 import jetbrains.buildServer.vcs.impl.VcsRootImpl;
@@ -26,8 +27,8 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.Map;
-import java.util.HashMap;
 
 public class BaseCommandTestCase extends BaseTestCase {
   private String myRepository;
@@ -58,7 +59,7 @@
       vcsRootProps.put(Constants.REPOSITORY_PROP, repository.getAbsolutePath());
     }
 
-    vcsRootProps.put(Constants.HG_COMMAND_PATH_PROP, "mercurial-tests/testData/bin/hg.exe");
+    vcsRootProps.put(Constants.HG_COMMAND_PATH_PROP, Util.getHgPath());
     if (myUsername != null) {
       vcsRootProps.put(Constants.USERNAME, myUsername);
     }