changeset 428:a68741340603

minor
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Fri, 11 May 2012 16:05:21 +0400
parents 144734686138
children 04eab204ba39
files mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SettingsTest.java mercurial-tests/src/testng.xml
diffstat 3 files changed, 126 insertions(+), 126 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootTest.java	Fri May 11 16:05:21 2012 +0400
@@ -0,0 +1,125 @@
+/*
+ * 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.buildTriggers.vcs.mercurial.command.HgVcsRoot;
+import jetbrains.buildServer.vcs.VcsRoot;
+import jetbrains.buildServer.vcs.impl.VcsRootImpl;
+import junit.framework.TestCase;
+import org.jetbrains.annotations.NotNull;
+import org.testng.annotations.Test;
+
+/**
+ * @author Pavel.Sher
+ */
+@Test
+public class HgVcsRootTest extends TestCase {
+
+  public void test_url_without_credentials() {
+    VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path");
+    HgVcsRoot root = createHgRoot(vcsRoot);
+    assertEquals("http://user:pwd@host.com/path", root.getRepositoryUrlWithCredentials());
+  }
+
+  public void test_url_with_credentials() {
+    VcsRootImpl vcsRoot = createVcsRoot("http://user:pwd@host.com/path");
+    HgVcsRoot root = createHgRoot(vcsRoot);
+    assertEquals("http://user:pwd@host.com/path", root.getRepositoryUrlWithCredentials());
+  }
+
+  public void test_url_with_username() {
+    VcsRootImpl vcsRoot = createVcsRoot("http://user@host.com/path");
+    HgVcsRoot root = createHgRoot(vcsRoot);
+    assertEquals("http://user:pwd@host.com/path", root.getRepositoryUrlWithCredentials());
+  }
+
+  public void test_url_with_at_after_slash() {
+    VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path@");
+    HgVcsRoot root = createHgRoot(vcsRoot);
+    assertEquals("http://user:pwd@host.com/path@", root.getRepositoryUrlWithCredentials());
+  }
+
+  public void test_url_with_at_in_username() {
+    VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path", "my.name@gmail.com", "1234");
+    HgVcsRoot root = createHgRoot(vcsRoot);
+    assertEquals("http://my.name%40gmail.com:1234@host.com/path", root.getRepositoryUrlWithCredentials());
+  }
+
+  /** TW-13768 */
+  public void test_underscore_in_host() {
+		VcsRootImpl vcsRoot = createVcsRoot("http://Klekovkin.SDK_GARANT:8000/", "my.name@gmail.com", "1234");
+    HgVcsRoot root = createHgRoot(vcsRoot);
+		assertEquals("http://my.name%40gmail.com:1234@Klekovkin.SDK_GARANT:8000/", root.getRepositoryUrlWithCredentials());
+	}
+
+  /** TW-13768 */
+  public void test_underscore_in_host_with_credentials_in_url() {
+    VcsRootImpl vcsRoot = createVcsRoot("http://me:mypass@Klekovkin.SDK_GARANT:8000/");
+    HgVcsRoot root = createHgRoot(vcsRoot);
+		assertEquals("http://me:mypass@Klekovkin.SDK_GARANT:8000/", root.getRepositoryUrlWithCredentials());
+  }
+
+  public void test_windows_path() throws Exception {
+    VcsRootImpl vcsRoot = createVcsRoot("c:\\windows\\path");
+    HgVcsRoot root = createHgRoot(vcsRoot);
+    assertEquals("c:\\windows\\path", root.getRepositoryUrlWithCredentials());
+  }
+
+  public void test_file_scheme_has_no_credentials() {
+    VcsRootImpl vcsRoot = createVcsRoot("file:///path/to/repo", "my.name@gmail.com", "1234");
+    HgVcsRoot root = createHgRoot(vcsRoot);
+    assertEquals("file:///path/to/repo", root.getRepositoryUrlWithCredentials());
+  }
+
+  public void uncompressed_transfer() {
+    VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path");
+    vcsRoot.addProperty(Constants.UNCOMPRESSED_TRANSFER, "true");
+    HgVcsRoot root = createHgRoot(vcsRoot);
+    assertTrue(root.isUncompressedTransfer());
+  }
+
+  //TW-18262
+  public void ampersand_in_password() {
+    VcsRootImpl vcsRoot = createVcsRoot("http://some.org/path", "user", "m&n");
+    HgVcsRoot root = createHgRoot(vcsRoot);
+    assertEquals("http://user:m%26n@some.org/path", root.getRepositoryUrlWithCredentials());
+  }
+
+  //TW-18835
+  public void test_ssh() {
+    VcsRootImpl vcsRoot = createVcsRoot("ssh://ourserver.com/mercurialrepo/", "user", "pwd");
+    HgVcsRoot root = createHgRoot(vcsRoot);
+    assertEquals("ssh://user:pwd@ourserver.com/mercurialrepo/", root.getRepositoryUrlWithCredentials());
+  }
+
+  private VcsRootImpl createVcsRoot(String url) {
+    return createVcsRoot(url, "user", "pwd");
+  }
+
+  private VcsRootImpl createVcsRoot(String url, String userName, String password) {
+    VcsRootImpl vcsRoot = new VcsRootImpl(1, Constants.VCS_NAME);
+    vcsRoot.addProperty(Constants.HG_COMMAND_PATH_PROP, "hg.exe");
+    vcsRoot.addProperty(Constants.REPOSITORY_PROP, url);
+    vcsRoot.addProperty(Constants.USERNAME, userName);
+    vcsRoot.addProperty(Constants.PASSWORD, password);
+    return vcsRoot;
+  }
+
+  private HgVcsRoot createHgRoot(@NotNull final VcsRoot root) {
+    ServerPluginConfig config = new ServerPluginConfigBuilder().build();
+    return new HgVcsRoot(new ServerHgPathProvider(config), root);
+  }
+}
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SettingsTest.java	Fri May 11 16:01:40 2012 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,125 +0,0 @@
-/*
- * 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.buildTriggers.vcs.mercurial.command.HgVcsRoot;
-import jetbrains.buildServer.vcs.VcsRoot;
-import jetbrains.buildServer.vcs.impl.VcsRootImpl;
-import junit.framework.TestCase;
-import org.jetbrains.annotations.NotNull;
-import org.testng.annotations.Test;
-
-/**
- * @author Pavel.Sher
- */
-@Test
-public class SettingsTest extends TestCase {
-
-  public void test_url_without_credentials() {
-    VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path");
-    HgVcsRoot root = createHgRoot(vcsRoot);
-    assertEquals("http://user:pwd@host.com/path", root.getRepositoryUrlWithCredentials());
-  }
-
-  public void test_url_with_credentials() {
-    VcsRootImpl vcsRoot = createVcsRoot("http://user:pwd@host.com/path");
-    HgVcsRoot root = createHgRoot(vcsRoot);
-    assertEquals("http://user:pwd@host.com/path", root.getRepositoryUrlWithCredentials());
-  }
-
-  public void test_url_with_username() {
-    VcsRootImpl vcsRoot = createVcsRoot("http://user@host.com/path");
-    HgVcsRoot root = createHgRoot(vcsRoot);
-    assertEquals("http://user:pwd@host.com/path", root.getRepositoryUrlWithCredentials());
-  }
-
-  public void test_url_with_at_after_slash() {
-    VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path@");
-    HgVcsRoot root = createHgRoot(vcsRoot);
-    assertEquals("http://user:pwd@host.com/path@", root.getRepositoryUrlWithCredentials());
-  }
-
-  public void test_url_with_at_in_username() {
-    VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path", "my.name@gmail.com", "1234");
-    HgVcsRoot root = createHgRoot(vcsRoot);
-    assertEquals("http://my.name%40gmail.com:1234@host.com/path", root.getRepositoryUrlWithCredentials());
-  }
-
-  /** TW-13768 */
-  public void test_underscore_in_host() {
-		VcsRootImpl vcsRoot = createVcsRoot("http://Klekovkin.SDK_GARANT:8000/", "my.name@gmail.com", "1234");
-    HgVcsRoot root = createHgRoot(vcsRoot);
-		assertEquals("http://my.name%40gmail.com:1234@Klekovkin.SDK_GARANT:8000/", root.getRepositoryUrlWithCredentials());
-	}
-
-  /** TW-13768 */
-  public void test_underscore_in_host_with_credentials_in_url() {
-    VcsRootImpl vcsRoot = createVcsRoot("http://me:mypass@Klekovkin.SDK_GARANT:8000/");
-    HgVcsRoot root = createHgRoot(vcsRoot);
-		assertEquals("http://me:mypass@Klekovkin.SDK_GARANT:8000/", root.getRepositoryUrlWithCredentials());
-  }
-
-  public void test_windows_path() throws Exception {
-    VcsRootImpl vcsRoot = createVcsRoot("c:\\windows\\path");
-    HgVcsRoot root = createHgRoot(vcsRoot);
-    assertEquals("c:\\windows\\path", root.getRepositoryUrlWithCredentials());
-  }
-
-  public void test_file_scheme_has_no_credentials() {
-    VcsRootImpl vcsRoot = createVcsRoot("file:///path/to/repo", "my.name@gmail.com", "1234");
-    HgVcsRoot root = createHgRoot(vcsRoot);
-    assertEquals("file:///path/to/repo", root.getRepositoryUrlWithCredentials());
-  }
-
-  public void uncompressed_transfer() {
-    VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path");
-    vcsRoot.addProperty(Constants.UNCOMPRESSED_TRANSFER, "true");
-    HgVcsRoot root = createHgRoot(vcsRoot);
-    assertTrue(root.isUncompressedTransfer());
-  }
-
-  //TW-18262
-  public void ampersand_in_password() {
-    VcsRootImpl vcsRoot = createVcsRoot("http://some.org/path", "user", "m&n");
-    HgVcsRoot root = createHgRoot(vcsRoot);
-    assertEquals("http://user:m%26n@some.org/path", root.getRepositoryUrlWithCredentials());
-  }
-
-  //TW-18835
-  public void test_ssh() {
-    VcsRootImpl vcsRoot = createVcsRoot("ssh://ourserver.com/mercurialrepo/", "user", "pwd");
-    HgVcsRoot root = createHgRoot(vcsRoot);
-    assertEquals("ssh://user:pwd@ourserver.com/mercurialrepo/", root.getRepositoryUrlWithCredentials());
-  }
-
-  private VcsRootImpl createVcsRoot(String url) {
-    return createVcsRoot(url, "user", "pwd");
-  }
-
-  private VcsRootImpl createVcsRoot(String url, String userName, String password) {
-    VcsRootImpl vcsRoot = new VcsRootImpl(1, Constants.VCS_NAME);
-    vcsRoot.addProperty(Constants.HG_COMMAND_PATH_PROP, "hg.exe");
-    vcsRoot.addProperty(Constants.REPOSITORY_PROP, url);
-    vcsRoot.addProperty(Constants.USERNAME, userName);
-    vcsRoot.addProperty(Constants.PASSWORD, password);
-    return vcsRoot;
-  }
-
-  private HgVcsRoot createHgRoot(@NotNull final VcsRoot root) {
-    ServerPluginConfig config = new ServerPluginConfigBuilder().build();
-    return new HgVcsRoot(new ServerHgPathProvider(config), root);
-  }
-}
--- a/mercurial-tests/src/testng.xml	Fri May 11 16:01:40 2012 +0400
+++ b/mercurial-tests/src/testng.xml	Fri May 11 16:05:21 2012 +0400
@@ -13,7 +13,7 @@
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialVcsSupportTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.AgentSideCheckoutTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.AgentSideCheckoutWithSubreposTest"/>
-      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.SettingsTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.HgVcsRootTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.MirrorManagerTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.HgVersionTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.command.VersionCommandTest"/>