From 7b04a90472d103ba35f5a943f6a7ec60c286de92 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Thu, 26 Feb 2015 08:33:21 -0500
Subject: [PATCH] Merge branch 'ticket/239' into develop
---
src/test/java/com/gitblit/tests/JGitUtilsTest.java | 32 ++++++++++++++++----------------
1 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/test/java/com/gitblit/tests/JGitUtilsTest.java b/src/test/java/com/gitblit/tests/JGitUtilsTest.java
index 9f7cb31..2cf4a5a 100644
--- a/src/test/java/com/gitblit/tests/JGitUtilsTest.java
+++ b/src/test/java/com/gitblit/tests/JGitUtilsTest.java
@@ -15,12 +15,6 @@
*/
package com.gitblit.tests;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
@@ -48,8 +42,6 @@
import org.junit.Test;
import com.gitblit.Constants.SearchType;
-import com.gitblit.GitBlit;
-import com.gitblit.Keys;
import com.gitblit.models.GitNote;
import com.gitblit.models.PathModel;
import com.gitblit.models.PathModel.PathChangeModel;
@@ -59,7 +51,7 @@
import com.gitblit.utils.JnaUtils;
import com.gitblit.utils.StringUtils;
-public class JGitUtilsTest {
+public class JGitUtilsTest extends GitblitUnitTest {
@Test
public void testDisplayName() throws Exception {
@@ -428,6 +420,11 @@
String contentA = JGitUtils.getStringContent(repository, (RevTree) null, "java.java");
RevCommit commit = JGitUtils.getCommit(repository, Constants.HEAD);
String contentB = JGitUtils.getStringContent(repository, commit.getTree(), "java.java");
+
+ assertTrue("ContentA is null!", contentA != null && contentA.length() > 0);
+ assertTrue("ContentB is null!", contentB != null && contentB.length() > 0);
+ assertTrue(contentA.equals(contentB));
+
String contentC = JGitUtils.getStringContent(repository, commit.getTree(), "missing.txt");
// manually construct a blob, calculate the hash, lookup the hash in git
@@ -437,9 +434,6 @@
String sha1 = StringUtils.getSHA1(sb.toString());
String contentD = JGitUtils.getStringContent(repository, sha1);
repository.close();
- assertTrue("ContentA is null!", contentA != null && contentA.length() > 0);
- assertTrue("ContentB is null!", contentB != null && contentB.length() > 0);
- assertTrue(contentA.equals(contentB));
assertNull(contentC);
assertTrue(contentA.equals(contentD));
}
@@ -482,16 +476,22 @@
}
@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 = GitBlit.getStrings(Keys.web.markdownExtensions);
+ List<String> extensions = Arrays.asList(new String[] { ".mkd", ".md" });
List<PathModel> markdownDocs = JGitUtils.getDocuments(repository, extensions);
- List<PathModel> markdownDocs2 = JGitUtils.getDocuments(repository,
- Arrays.asList(new String[] { ".mkd", ".md" }));
List<PathModel> allFiles = JGitUtils.getDocuments(repository, null);
repository.close();
assertTrue(markdownDocs.size() > 0);
- assertTrue(markdownDocs2.size() > 0);
assertTrue(allFiles.size() > markdownDocs.size());
}
--
Gitblit v1.9.1