Mercurial > hg > mercurial
view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootFactoryTest.java @ 908:b39494a5ff96
TW-39095 handle commit messages with non-ascii symbols
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Fri, 05 Dec 2014 14:59:15 +0100 |
parents | 31a1aca3305c |
children | 7bf4d943d5bb |
line wrap: on
line source
/* * Copyright 2000-2014 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.TempFiles; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot; import jetbrains.buildServer.util.TestFor; import jetbrains.buildServer.vcs.VcsRoot; import org.testng.annotations.Test; import java.io.File; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.ServerPluginConfigBuilder.serverPluginConfig; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.VcsRootBuilder.vcsRoot; import static org.testng.AssertJUnit.assertFalse; import static org.testng.AssertJUnit.assertNull; import static org.testng.AssertJUnit.assertTrue; @Test public class HgVcsRootFactoryTest extends BaseMercurialTestCase { @TestFor(issues = "TW-25057") public void vcs_root_custom_clone_dir_should_not_contain_password() throws Exception { TempFiles tmp = new TempFiles(); String urlWithoutPath = "http://only.host/"; String password = "pwd"; VcsRoot root = vcsRoot() .withUrl(urlWithoutPath) .withUserName("user") .withPassword(password) .withCloneRepositoryTo(tmp.createTempDir()) .build(); HgVcsRoot hgRoot = new HgVcsRootFactory(serverPluginConfig().cachesDir(tmp.createTempDir()).build()).createHgRoot(root); assertFalse("Custom clone dir contains password", hgRoot.getCustomWorkingDir().getName().contains(password)); } @TestFor(issues = "TW-32540") public void custom_clone_dir_should_contain_only_valid_characters() throws Exception { TempFiles tmp = new TempFiles(); String urlWithoutPath = "http://acme:8000/"; VcsRoot root = vcsRoot() .withUrl(urlWithoutPath) .withCloneRepositoryTo(tmp.createTempDir()) .build(); HgVcsRoot hgRoot = new HgVcsRootFactory(serverPluginConfig().cachesDir(tmp.createTempDir()).build()).createHgRoot(root); hgRoot.getCustomWorkingDir().mkdirs(); assertTrue(hgRoot.getCustomWorkingDir().exists()); } @TestFor(issues = "TW-28974") public void should_use_default_dirs() throws Exception { TempFiles tmp = new TempFiles(); File cachesDir = tmp.createTempDir(); File nonCanonicalCachesDir = new File(cachesDir.getCanonicalPath() + "/../" + cachesDir.getName()); ServerPluginConfig pluginConfig = serverPluginConfig().cachesDir(cachesDir).build(); VcsRoot root = vcsRoot() .withUrl("http://acme.com/repo") .withCloneRepositoryTo(nonCanonicalCachesDir) .build(); HgVcsRoot hgRoot = new HgVcsRootFactory(pluginConfig).createHgRoot(root); assertNull("Custom working dir is used instead of default one", hgRoot.getCustomWorkingDir()); } }