summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorMilos Cubrilo <milos.cubrilo@gmail.com>2015-01-11 13:41:29 +0100
committerMilos Cubrilo <milos.cubrilo@gmail.com>2015-01-11 13:41:29 +0100
commita9a2ffcf9a34bd25fe2e05bfdd4cde74725bb17d (patch)
tree69489cfef9060831b3c802bbb237f9d70f4a13ac /src/test
parentde6f6625cb96775b640240ed2e57499743670fe2 (diff)
downloadgitblit-a9a2ffcf9a34bd25fe2e05bfdd4cde74725bb17d.tar.gz
gitblit-a9a2ffcf9a34bd25fe2e05bfdd4cde74725bb17d.zip
#230 - Improve empty folder navigation.
Empty folders are automatically skipped when browsing repository tree (similar to github "folder jumping" feature).
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/gitblit/tests/GitBlitSuite.java14
-rw-r--r--src/test/java/com/gitblit/tests/JGitUtilsTest.java9
-rw-r--r--src/test/java/com/gitblit/tests/PathUtilsTest.java66
3 files changed, 82 insertions, 7 deletions
diff --git a/src/test/java/com/gitblit/tests/GitBlitSuite.java b/src/test/java/com/gitblit/tests/GitBlitSuite.java
index f2dfcc0c..bf6834d3 100644
--- a/src/test/java/com/gitblit/tests/GitBlitSuite.java
+++ b/src/test/java/com/gitblit/tests/GitBlitSuite.java
@@ -63,9 +63,9 @@ import com.gitblit.utils.JGitUtils;
GitBlitTest.class, FederationTests.class, RpcTests.class, GitServletTest.class, GitDaemonTest.class,
SshDaemonTest.class, GroovyScriptTest.class, LuceneExecutorTest.class, RepositoryModelTest.class,
FanoutServiceTest.class, Issue0259Test.class, Issue0271Test.class, HtpasswdAuthenticationTest.class,
- ModelUtilsTest.class, JnaUtilsTest.class, LdapSyncServiceTest.class, FileTicketServiceTest.class,
+ ModelUtilsTest.class, JnaUtilsTest.class, LdapSyncServiceTest.class, FileTicketServiceTest.class,
BranchTicketServiceTest.class, RedisTicketServiceTest.class, AuthenticationManagerTest.class,
- SshKeysDispatcherTest.class, UITicketTest.class })
+ SshKeysDispatcherTest.class, UITicketTest.class, PathUtilsTest.class })
public class GitBlitSuite {
public static final File BASEFOLDER = new File("data");
@@ -110,11 +110,11 @@ public class GitBlitSuite {
return getRepository("test/gitective.git");
}
- public static Repository getTicketsTestRepository() {
- JGitUtils.createRepository(REPOSITORIES, "gb-tickets.git").close();
- return getRepository("gb-tickets.git");
- }
-
+ public static Repository getTicketsTestRepository() {
+ JGitUtils.createRepository(REPOSITORIES, "gb-tickets.git").close();
+ return getRepository("gb-tickets.git");
+ }
+
private static Repository getRepository(String name) {
try {
File gitDir = FileKey.resolve(new File(REPOSITORIES, name), FS.DETECTED);
diff --git a/src/test/java/com/gitblit/tests/JGitUtilsTest.java b/src/test/java/com/gitblit/tests/JGitUtilsTest.java
index c2cfb331..2cf4a5a1 100644
--- a/src/test/java/com/gitblit/tests/JGitUtilsTest.java
+++ b/src/test/java/com/gitblit/tests/JGitUtilsTest.java
@@ -476,6 +476,15 @@ public class JGitUtilsTest extends GitblitUnitTest {
}
@Test
+ public void testFilesInPath2() throws Exception {
+ assertEquals(0, JGitUtils.getFilesInPath2(null, null, null).size());
+ Repository repository = GitBlitSuite.getHelloworldRepository();
+ List<PathModel> files = JGitUtils.getFilesInPath2(repository, null, null);
+ repository.close();
+ assertTrue(files.size() > 10);
+ }
+
+ @Test
public void testDocuments() throws Exception {
Repository repository = GitBlitSuite.getTicgitRepository();
List<String> extensions = Arrays.asList(new String[] { ".mkd", ".md" });
diff --git a/src/test/java/com/gitblit/tests/PathUtilsTest.java b/src/test/java/com/gitblit/tests/PathUtilsTest.java
new file mode 100644
index 00000000..209b8ee6
--- /dev/null
+++ b/src/test/java/com/gitblit/tests/PathUtilsTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2011 gitblit.com.
+ *
+ * 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 com.gitblit.tests;
+
+import com.gitblit.utils.PathUtils;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+public class PathUtilsTest extends GitblitUnitTest {
+
+ private static final String[][][] testData = {
+
+ {
+ // Folder contents
+ {".gitignore","src/main/java/a.java", "src/main/java/b.java", "docs/c.md"},
+ // Expected after compressing
+ {".gitignore", "src/main/java/", "docs/"}
+ },
+
+ {
+ {".gitignore","src/main/java/a.java", "src/main/b.java", "docs/c.md"},
+ {".gitignore", "src/main/", "docs/"}
+ },
+
+ {
+ {".gitignore","src/x.java","src/main/java/a.java", "src/main/java/b.java", "docs/c.md"},
+ {".gitignore", "src/", "docs/"}
+ },
+ };
+
+
+
+
+ @Test
+ public void testCompressPaths() throws Exception {
+
+ for (String[][] test : testData ) {
+ assertArrayEquals(test[1], PathUtils.compressPaths(Arrays.asList(test[0])).toArray(new String[]{}));
+ }
+
+ }
+
+ @Test
+ public void testGetLastPathComponent() {
+ assertEquals(PathUtils.getLastPathComponent("/a/b/c/d/e.out"), "e.out");
+ assertEquals(PathUtils.getLastPathComponent("e.out"), "e.out");
+ assertEquals(PathUtils.getLastPathComponent("/a/b/c/d/"), "d");
+ assertEquals(PathUtils.getLastPathComponent("/a/b/c/d"), "d");
+ assertEquals(PathUtils.getLastPathComponent("/"), "/");
+ }
+
+} \ No newline at end of file