summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2013-09-17 16:13:53 -0400
committerJames Moger <james.moger@gitblit.com>2013-09-17 17:04:29 -0400
commitbb6b148bfc2d4a22b4fd3bdbafebadccaccf6661 (patch)
tree7f7fee92dd29e82e436043a546aef731d25a465c /src/test
parent5f8d99338e63c68839e3ddf34f54486e1d1128f1 (diff)
downloadgitblit-bb6b148bfc2d4a22b4fd3bdbafebadccaccf6661.tar.gz
gitblit-bb6b148bfc2d4a22b4fd3bdbafebadccaccf6661.zip
Revisions and documentation for personal repository prefix change
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/gitblit/tests/GitBlitSuite.java3
-rw-r--r--src/test/java/com/gitblit/tests/ModelUtilsTest.java82
2 files changed, 25 insertions, 60 deletions
diff --git a/src/test/java/com/gitblit/tests/GitBlitSuite.java b/src/test/java/com/gitblit/tests/GitBlitSuite.java
index 64398b22..5f03ec5a 100644
--- a/src/test/java/com/gitblit/tests/GitBlitSuite.java
+++ b/src/test/java/com/gitblit/tests/GitBlitSuite.java
@@ -60,7 +60,8 @@ import com.gitblit.utils.JGitUtils;
DiffUtilsTest.class, MetricUtilsTest.class, TicgitUtilsTest.class, X509UtilsTest.class,
GitBlitTest.class, FederationTests.class, RpcTests.class, GitServletTest.class, GitDaemonTest.class,
GroovyScriptTest.class, LuceneExecutorTest.class, IssuesTest.class, RepositoryModelTest.class,
- FanoutServiceTest.class, Issue0259Test.class, Issue0271Test.class, HtpasswdUserServiceTest.class })
+ FanoutServiceTest.class, Issue0259Test.class, Issue0271Test.class, HtpasswdUserServiceTest.class,
+ ModelUtilsTest.class })
public class GitBlitSuite {
public static final File REPOSITORIES = new File("data/git");
diff --git a/src/test/java/com/gitblit/tests/ModelUtilsTest.java b/src/test/java/com/gitblit/tests/ModelUtilsTest.java
index 988f681c..95743bba 100644
--- a/src/test/java/com/gitblit/tests/ModelUtilsTest.java
+++ b/src/test/java/com/gitblit/tests/ModelUtilsTest.java
@@ -4,48 +4,25 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import java.util.HashMap;
-import java.util.Map;
-
import org.junit.After;
import org.junit.Test;
-import com.gitblit.Keys;
-import com.gitblit.tests.mock.MemorySettings;
+import com.gitblit.Constants;
import com.gitblit.utils.ModelUtils;
public class ModelUtilsTest {
- private static final String DEFAULT_USER_REPO_PREFIX = "~";
-
- private static final Map<String, Object> backingMap = new HashMap<String, Object>();
- private static final MemorySettings ms = new MemorySettings(backingMap);
-
-
- private static void setPrefix(String prefix)
- {
- backingMap.put(Keys.git.userRepositoryPrefix, prefix);
- }
-
-
- private static void setRepoPrefix(String prefix)
- {
- backingMap.put(Keys.git.userRepositoryPrefix, prefix);
- ModelUtils.setUserRepoPrefix(ms);
- }
-
-
@After
public void resetPrefix()
{
- setRepoPrefix(DEFAULT_USER_REPO_PREFIX);
+ ModelUtils.setUserRepoPrefix(null);
}
@Test
public void testGetUserRepoPrefix()
{
- assertEquals(DEFAULT_USER_REPO_PREFIX, ModelUtils.getUserRepoPrefix());
+ assertEquals(Constants.DEFAULT_USER_REPOSITORY_PREFIX, ModelUtils.getUserRepoPrefix());
}
@@ -53,38 +30,25 @@ public class ModelUtilsTest {
public void testSetUserRepoPrefix()
{
- assertEquals(DEFAULT_USER_REPO_PREFIX, ModelUtils.getUserRepoPrefix());
+ assertEquals(Constants.DEFAULT_USER_REPOSITORY_PREFIX, ModelUtils.getUserRepoPrefix());
- setPrefix("@");
- ModelUtils.setUserRepoPrefix(ms);
+ ModelUtils.setUserRepoPrefix("@");
assertEquals("@", ModelUtils.getUserRepoPrefix());
- backingMap.remove(Keys.git.userRepositoryPrefix);
- ModelUtils.setUserRepoPrefix(ms);
- assertEquals(DEFAULT_USER_REPO_PREFIX, ModelUtils.getUserRepoPrefix());
+ ModelUtils.setUserRepoPrefix("");
+ assertEquals(Constants.DEFAULT_USER_REPOSITORY_PREFIX, ModelUtils.getUserRepoPrefix());
- setPrefix("user/");
- ModelUtils.setUserRepoPrefix(ms);
+ ModelUtils.setUserRepoPrefix("user/");
assertEquals("user/", ModelUtils.getUserRepoPrefix());
- setPrefix("");
- ModelUtils.setUserRepoPrefix(ms);
- assertEquals(DEFAULT_USER_REPO_PREFIX, ModelUtils.getUserRepoPrefix());
-
- setPrefix("u_");
- ModelUtils.setUserRepoPrefix(ms);
+ ModelUtils.setUserRepoPrefix("u_");
assertEquals("u_", ModelUtils.getUserRepoPrefix());
ModelUtils.setUserRepoPrefix(null);
- assertEquals(DEFAULT_USER_REPO_PREFIX, ModelUtils.getUserRepoPrefix());
+ assertEquals(Constants.DEFAULT_USER_REPOSITORY_PREFIX, ModelUtils.getUserRepoPrefix());
- setPrefix("/somedir/otherdir/");
- ModelUtils.setUserRepoPrefix(ms);
+ ModelUtils.setUserRepoPrefix("/somedir/otherdir/");
assertEquals("somedir/otherdir/", ModelUtils.getUserRepoPrefix());
-
- setPrefix(DEFAULT_USER_REPO_PREFIX);
- ModelUtils.setUserRepoPrefix(ms);
- assertEquals(DEFAULT_USER_REPO_PREFIX, ModelUtils.getUserRepoPrefix());
}
@@ -92,12 +56,12 @@ public class ModelUtilsTest {
public void testGetPersonalPath()
{
String username = "rob";
- assertEquals(DEFAULT_USER_REPO_PREFIX+username.toLowerCase(), ModelUtils.getPersonalPath(username));
+ assertEquals(Constants.DEFAULT_USER_REPOSITORY_PREFIX+username.toLowerCase(), ModelUtils.getPersonalPath(username));
username = "James";
- assertEquals(DEFAULT_USER_REPO_PREFIX+username.toLowerCase(), ModelUtils.getPersonalPath(username));
+ assertEquals(Constants.DEFAULT_USER_REPOSITORY_PREFIX+username.toLowerCase(), ModelUtils.getPersonalPath(username));
- setRepoPrefix("usr/");
+ ModelUtils.setUserRepoPrefix("usr/");
username = "noMan";
assertEquals("usr/"+username.toLowerCase(), ModelUtils.getPersonalPath(username));
}
@@ -106,17 +70,17 @@ public class ModelUtilsTest {
@Test
public void testIsPersonalRepository()
{
- String reponame = DEFAULT_USER_REPO_PREFIX + "one";
+ String reponame = Constants.DEFAULT_USER_REPOSITORY_PREFIX + "one";
assertTrue(ModelUtils.isPersonalRepository(reponame));
reponame = "none";
assertFalse(ModelUtils.isPersonalRepository(reponame));
- setRepoPrefix("@@");
+ ModelUtils.setUserRepoPrefix("@@");
reponame = "@@two";
assertTrue(ModelUtils.isPersonalRepository(reponame));
- setRepoPrefix("users/");
+ ModelUtils.setUserRepoPrefix("users/");
reponame = "users/three";
assertTrue(ModelUtils.isPersonalRepository(reponame));
@@ -128,18 +92,18 @@ public class ModelUtilsTest {
@Test
public void testIsUsersPersonalRepository()
{
- String reponame = DEFAULT_USER_REPO_PREFIX + "lynn";
+ String reponame = Constants.DEFAULT_USER_REPOSITORY_PREFIX + "lynn";
assertTrue(ModelUtils.isUsersPersonalRepository("lynn", reponame));
reponame = "prjB";
assertFalse(ModelUtils.isUsersPersonalRepository("lynn", reponame));
- setRepoPrefix("@@");
+ ModelUtils.setUserRepoPrefix("@@");
reponame = "@@newton";
assertTrue(ModelUtils.isUsersPersonalRepository("newton", reponame));
assertFalse(ModelUtils.isUsersPersonalRepository("hertz", reponame));
- setRepoPrefix("users/");
+ ModelUtils.setUserRepoPrefix("users/");
reponame = "users/fee";
assertTrue(ModelUtils.isUsersPersonalRepository("fee", reponame));
assertFalse(ModelUtils.isUsersPersonalRepository("gnome", reponame));
@@ -152,14 +116,14 @@ public class ModelUtilsTest {
@Test
public void testGetUserNameFromRepoPath()
{
- String reponame = DEFAULT_USER_REPO_PREFIX + "lynn";
+ String reponame = Constants.DEFAULT_USER_REPOSITORY_PREFIX + "lynn";
assertEquals("lynn", ModelUtils.getUserNameFromRepoPath(reponame));
- setRepoPrefix("@@");
+ ModelUtils.setUserRepoPrefix("@@");
reponame = "@@newton";
assertEquals("newton", ModelUtils.getUserNameFromRepoPath(reponame));
- setRepoPrefix("users/");
+ ModelUtils.setUserRepoPrefix("users/");
reponame = "users/fee";
assertEquals("fee", ModelUtils.getUserNameFromRepoPath(reponame));
}