diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/data/.gitignore | 1 | ||||
-rw-r--r-- | src/test/data/ambition.git.zip | bin | 0 -> 199401 bytes | |||
-rw-r--r-- | src/test/data/gitective.git.zip | bin | 0 -> 2974989 bytes | |||
-rw-r--r-- | src/test/data/hello-world.git.zip | bin | 0 -> 55129 bytes | |||
-rw-r--r-- | src/test/data/hello-world.properties | 9 | ||||
-rw-r--r-- | src/test/data/ticgit.git.zip | bin | 0 -> 364736 bytes | |||
-rw-r--r-- | src/test/java/com/gitblit/tests/.gitignore | 1 | ||||
-rw-r--r-- | src/test/java/com/gitblit/tests/DiffUtilsTest.java | 22 | ||||
-rw-r--r-- | src/test/java/com/gitblit/tests/GitBlitSuite.java | 94 | ||||
-rw-r--r-- | src/test/java/com/gitblit/tests/GroovyScriptTest.java | 46 | ||||
-rw-r--r-- | src/test/java/com/gitblit/tests/JGitUtilsTest.java | 11 | ||||
-rw-r--r-- | src/test/java/com/gitblit/tests/MetricUtilsTest.java | 4 |
12 files changed, 142 insertions, 46 deletions
diff --git a/src/test/data/.gitignore b/src/test/data/.gitignore new file mode 100644 index 00000000..7056b036 --- /dev/null +++ b/src/test/data/.gitignore @@ -0,0 +1 @@ +/*.git/ diff --git a/src/test/data/ambition.git.zip b/src/test/data/ambition.git.zip Binary files differnew file mode 100644 index 00000000..9aaa4997 --- /dev/null +++ b/src/test/data/ambition.git.zip diff --git a/src/test/data/gitective.git.zip b/src/test/data/gitective.git.zip Binary files differnew file mode 100644 index 00000000..1071d911 --- /dev/null +++ b/src/test/data/gitective.git.zip diff --git a/src/test/data/hello-world.git.zip b/src/test/data/hello-world.git.zip Binary files differnew file mode 100644 index 00000000..e1057a6b --- /dev/null +++ b/src/test/data/hello-world.git.zip diff --git a/src/test/data/hello-world.properties b/src/test/data/hello-world.properties new file mode 100644 index 00000000..99ed126b --- /dev/null +++ b/src/test/data/hello-world.properties @@ -0,0 +1,9 @@ +commit.first=192cdede1cc81da7b393aeb7aba9f88998b04713 +commit.second=8caad51 +commit.fifth=55f6796044dc51f0bb9301f07920f0fb64c3d12c +commit.fifteen=5ebfaca +commit.added=192cded +commit.changed=b2c50ce +commit.deleted=8613bee10bde27a0fbaca66447cdc3f0f9483365 +users.byEmail=9 +users.byName=8 diff --git a/src/test/data/ticgit.git.zip b/src/test/data/ticgit.git.zip Binary files differnew file mode 100644 index 00000000..18df11cc --- /dev/null +++ b/src/test/data/ticgit.git.zip diff --git a/src/test/java/com/gitblit/tests/.gitignore b/src/test/java/com/gitblit/tests/.gitignore new file mode 100644 index 00000000..44874597 --- /dev/null +++ b/src/test/java/com/gitblit/tests/.gitignore @@ -0,0 +1 @@ +/HelloworldKeys.java diff --git a/src/test/java/com/gitblit/tests/DiffUtilsTest.java b/src/test/java/com/gitblit/tests/DiffUtilsTest.java index e8e839a5..9ba7202f 100644 --- a/src/test/java/com/gitblit/tests/DiffUtilsTest.java +++ b/src/test/java/com/gitblit/tests/DiffUtilsTest.java @@ -40,7 +40,7 @@ public class DiffUtilsTest extends GitblitUnitTest { public void testParentCommitDiff() throws Exception {
Repository repository = GitBlitSuite.getHelloworldRepository();
RevCommit commit = JGitUtils.getCommit(repository,
- "1d0c2933a4ae69c362f76797d42d6bd182d05176");
+ GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.second));
String diff = DiffUtils.getCommitDiff(repository, commit, DiffComparator.SHOW_WHITESPACE, DiffOutputType.PLAIN, 3).content;
repository.close();
assertTrue(diff != null && diff.length() > 0);
@@ -52,9 +52,9 @@ public class DiffUtilsTest extends GitblitUnitTest { public void testArbitraryCommitDiff() throws Exception {
Repository repository = GitBlitSuite.getHelloworldRepository();
RevCommit baseCommit = JGitUtils.getCommit(repository,
- "8baf6a833b5579384d9b9ceb8a16b5d0ea2ec4ca");
+ GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.first));
RevCommit commit = JGitUtils.getCommit(repository,
- "1d0c2933a4ae69c362f76797d42d6bd182d05176");
+ GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.second));
String diff = DiffUtils.getDiff(repository, baseCommit, commit, DiffComparator.SHOW_WHITESPACE, DiffOutputType.PLAIN, 3).content;
repository.close();
assertTrue(diff != null && diff.length() > 0);
@@ -66,7 +66,7 @@ public class DiffUtilsTest extends GitblitUnitTest { public void testPlainFileDiff() throws Exception {
Repository repository = GitBlitSuite.getHelloworldRepository();
RevCommit commit = JGitUtils.getCommit(repository,
- "1d0c2933a4ae69c362f76797d42d6bd182d05176");
+ GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.second));
String diff = DiffUtils.getDiff(repository, commit, "java.java", DiffComparator.SHOW_WHITESPACE, DiffOutputType.PLAIN, 3).content;
repository.close();
assertTrue(diff != null && diff.length() > 0);
@@ -78,7 +78,7 @@ public class DiffUtilsTest extends GitblitUnitTest { public void testFilePatch() throws Exception {
Repository repository = GitBlitSuite.getHelloworldRepository();
RevCommit commit = JGitUtils.getCommit(repository,
- "1d0c2933a4ae69c362f76797d42d6bd182d05176");
+ GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.second));
String patch = DiffUtils.getCommitPatch(repository, null, commit, "java.java");
repository.close();
assertTrue(patch != null && patch.length() > 0);
@@ -90,9 +90,9 @@ public class DiffUtilsTest extends GitblitUnitTest { public void testArbitraryFilePatch() throws Exception {
Repository repository = GitBlitSuite.getHelloworldRepository();
RevCommit baseCommit = JGitUtils.getCommit(repository,
- "8baf6a833b5579384d9b9ceb8a16b5d0ea2ec4ca");
+ GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.first));
RevCommit commit = JGitUtils.getCommit(repository,
- "1d0c2933a4ae69c362f76797d42d6bd182d05176");
+ GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.second));
String patch = DiffUtils.getCommitPatch(repository, baseCommit, commit, "java.java");
repository.close();
assertTrue(patch != null && patch.length() > 0);
@@ -104,9 +104,9 @@ public class DiffUtilsTest extends GitblitUnitTest { public void testArbitraryCommitPatch() throws Exception {
Repository repository = GitBlitSuite.getHelloworldRepository();
RevCommit baseCommit = JGitUtils.getCommit(repository,
- "8baf6a833b5579384d9b9ceb8a16b5d0ea2ec4ca");
+ GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.first));
RevCommit commit = JGitUtils.getCommit(repository,
- "1d0c2933a4ae69c362f76797d42d6bd182d05176");
+ GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.second));
String patch = DiffUtils.getCommitPatch(repository, baseCommit, commit, null);
repository.close();
assertTrue(patch != null && patch.length() > 0);
@@ -118,9 +118,9 @@ public class DiffUtilsTest extends GitblitUnitTest { public void testBlame() throws Exception {
Repository repository = GitBlitSuite.getHelloworldRepository();
List<AnnotatedLine> lines = DiffUtils.blame(repository, "java.java",
- "1d0c2933a4ae69c362f76797d42d6bd182d05176");
+ GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.second));
repository.close();
assertTrue(lines.size() > 0);
- assertEquals("c6d31dccf5cc75e8e46299fc62d38f60ec6d41e0", lines.get(0).commitId);
+ assertEquals(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.first), lines.get(0).commitId);
}
}
diff --git a/src/test/java/com/gitblit/tests/GitBlitSuite.java b/src/test/java/com/gitblit/tests/GitBlitSuite.java index 133be77f..3292d090 100644 --- a/src/test/java/com/gitblit/tests/GitBlitSuite.java +++ b/src/test/java/com/gitblit/tests/GitBlitSuite.java @@ -16,10 +16,15 @@ package com.gitblit.tests;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
import java.lang.reflect.Field;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.Repository;
@@ -27,12 +32,14 @@ import org.eclipse.jgit.lib.RepositoryCache; import org.eclipse.jgit.lib.RepositoryCache.FileKey;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.util.FS;
+import org.eclipse.jgit.util.FileUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
+import com.gitblit.FileSettings;
import com.gitblit.GitBlitException;
import com.gitblit.GitBlitServer;
import com.gitblit.manager.IRepositoryManager;
@@ -77,6 +84,18 @@ public class GitBlitSuite { public static final File USERSCONF = new File("src/test/config/test-users.conf");
+ private static final File AMBITION_REPO_SOURCE = new File("src/test/data/ambition.git");
+
+ private static final File TICGIT_REPO_SOURCE = new File("src/test/data/ticgit.git");
+
+ private static final File GITECTIVE_REPO_SOURCE = new File("src/test/data/gitective.git");
+
+ private static final File HELLOWORLD_REPO_SOURCE = new File("src/test/data/hello-world.git");
+
+ private static final File HELLOWORLD_REPO_PROPERTIES = new File("src/test/data/hello-world.properties");
+
+ public static final FileSettings helloworldSettings = new FileSettings(HELLOWORLD_REPO_PROPERTIES.getAbsolutePath());
+
static int port = 8280;
static int gitPort = 8300;
static int shutdownPort = 8281;
@@ -167,17 +186,39 @@ public class GitBlitSuite { Thread.sleep(5000);
}
+ public static void deleteRefChecksFolder() throws IOException {
+ File refChecks = new File(GitBlitSuite.REPOSITORIES, "refchecks");
+ if (refChecks.exists()) {
+ FileUtils.delete(refChecks, FileUtils.RECURSIVE | FileUtils.RETRY);
+ }
+ }
+
@BeforeClass
public static void setUp() throws Exception {
+ //"refchecks" folder is used in GitServletTest;
+ //need be deleted before Gitblit server instance is started
+ deleteRefChecksFolder();
startGitblit();
if (REPOSITORIES.exists() || REPOSITORIES.mkdirs()) {
- cloneOrFetch("helloworld.git", "https://github.com/git/hello-world.git");
- cloneOrFetch("ticgit.git", "https://github.com/schacon/ticgit.git");
+ if (!HELLOWORLD_REPO_SOURCE.exists()) {
+ unzipRepository(HELLOWORLD_REPO_SOURCE.getPath() + ".zip", HELLOWORLD_REPO_SOURCE.getParentFile());
+ }
+ if (!TICGIT_REPO_SOURCE.exists()) {
+ unzipRepository(TICGIT_REPO_SOURCE.getPath() + ".zip", TICGIT_REPO_SOURCE.getParentFile());
+ }
+ if (!AMBITION_REPO_SOURCE.exists()) {
+ unzipRepository(AMBITION_REPO_SOURCE.getPath() + ".zip", AMBITION_REPO_SOURCE.getParentFile());
+ }
+ if (!GITECTIVE_REPO_SOURCE.exists()) {
+ unzipRepository(GITECTIVE_REPO_SOURCE.getPath() + ".zip", GITECTIVE_REPO_SOURCE.getParentFile());
+ }
+ cloneOrFetch("helloworld.git", HELLOWORLD_REPO_SOURCE.getAbsolutePath());
+ cloneOrFetch("ticgit.git", TICGIT_REPO_SOURCE.getAbsolutePath());
cloneOrFetch("test/jgit.git", "https://github.com/eclipse/jgit.git");
- cloneOrFetch("test/helloworld.git", "https://github.com/git/hello-world.git");
- cloneOrFetch("test/ambition.git", "https://github.com/defunkt/ambition.git");
- cloneOrFetch("test/gitective.git", "https://github.com/kevinsawicki/gitective.git");
+ cloneOrFetch("test/helloworld.git", HELLOWORLD_REPO_SOURCE.getAbsolutePath());
+ cloneOrFetch("test/ambition.git", AMBITION_REPO_SOURCE.getAbsolutePath());
+ cloneOrFetch("test/gitective.git", GITECTIVE_REPO_SOURCE.getAbsolutePath());
showRemoteBranches("ticgit.git");
automaticallyTagBranchTips("ticgit.git");
@@ -254,4 +295,47 @@ public class GitBlitSuite { r.close();
}
}
+
+ private static void unzipRepository(String zippedRepo, File destDir) throws IOException {
+ System.out.print("Unzipping " + zippedRepo + "... ");
+ if (!destDir.exists()) {
+ destDir.mkdir();
+ }
+ byte[] buffer = new byte[1024];
+ ZipInputStream zis = new ZipInputStream(new FileInputStream(zippedRepo));
+ ZipEntry zipEntry = zis.getNextEntry();
+ while (zipEntry != null) {
+ File newFile = newFile(destDir, zipEntry);
+ if (zipEntry.isDirectory()) {
+ newFile.mkdirs();
+ }
+ else {
+ FileOutputStream fos = new FileOutputStream(newFile);
+ int len;
+ while ((len = zis.read(buffer)) > 0) {
+ fos.write(buffer, 0, len);
+ }
+ fos.close();
+ }
+ zipEntry = zis.getNextEntry();
+ }
+ zis.closeEntry();
+ zis.close();
+ System.out.println("done.");
+ }
+
+ private static File newFile(File destinationDir, ZipEntry zipEntry) throws IOException {
+ File destFile = new File(destinationDir, zipEntry.getName());
+
+ String destDirPath = destinationDir.getCanonicalPath();
+ String destFilePath = destFile.getCanonicalPath();
+ //guards against writing files to the file system outside of the target folder
+ //to prevent Zip Slip exploit
+ if (!destFilePath.startsWith(destDirPath + File.separator)) {
+ throw new IOException("Entry is outside of the target dir: " + zipEntry.getName());
+ }
+
+ return destFile;
+ }
+
}
diff --git a/src/test/java/com/gitblit/tests/GroovyScriptTest.java b/src/test/java/com/gitblit/tests/GroovyScriptTest.java index ff40972f..81c6c23a 100644 --- a/src/test/java/com/gitblit/tests/GroovyScriptTest.java +++ b/src/test/java/com/gitblit/tests/GroovyScriptTest.java @@ -74,11 +74,11 @@ public class GroovyScriptTest extends GitblitUnitTest { MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
commands.add(new ReceiveCommand(ObjectId
- .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
- .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifth)), ObjectId
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master"));
commands.add(new ReceiveCommand(ObjectId
- .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
- .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master2"));
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifth)), ObjectId
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master2"));
RepositoryModel repository = repositories().getRepositoryModel("helloworld.git");
repository.customFields = new HashMap<String,String>();
@@ -96,11 +96,11 @@ public class GroovyScriptTest extends GitblitUnitTest { MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
commands.add(new ReceiveCommand(ObjectId
- .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
- .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifth)), ObjectId
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master"));
commands.add(new ReceiveCommand(ObjectId
- .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
- .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master2"));
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifth)), ObjectId
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master2"));
RepositoryModel repository = repositories().getRepositoryModel("helloworld.git");
repository.mailingLists.add("list@helloworld.git");
@@ -121,11 +121,11 @@ public class GroovyScriptTest extends GitblitUnitTest { MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
commands.add(new ReceiveCommand(ObjectId
- .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
- .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifth)), ObjectId
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master"));
commands.add(new ReceiveCommand(ObjectId
- .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
- .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master2"));
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifth)), ObjectId
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master2"));
RepositoryModel repository = repositories().getRepositoryModel("helloworld.git");
repository.mailingLists.add("list@helloworld.git");
@@ -145,7 +145,7 @@ public class GroovyScriptTest extends GitblitUnitTest { MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
commands.add(new ReceiveCommand(ObjectId.zeroId(), ObjectId
- .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master"));
RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
@@ -159,7 +159,7 @@ public class GroovyScriptTest extends GitblitUnitTest { MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
commands.add(new ReceiveCommand(ObjectId.zeroId(), ObjectId
- .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/tags/v1.0"));
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/tags/v1.0"));
RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
@@ -174,8 +174,8 @@ public class GroovyScriptTest extends GitblitUnitTest { MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
commands.add(new ReceiveCommand(ObjectId
- .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
- .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifth)), ObjectId
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master"));
RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
@@ -190,7 +190,7 @@ public class GroovyScriptTest extends GitblitUnitTest { MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
ReceiveCommand command = new ReceiveCommand(ObjectId
- .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), ObjectId.zeroId(),
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), ObjectId.zeroId(),
"refs/heads/master");
commands.add(command);
@@ -208,7 +208,7 @@ public class GroovyScriptTest extends GitblitUnitTest { MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
commands.add(new ReceiveCommand(ObjectId
- .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), ObjectId.zeroId(),
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), ObjectId.zeroId(),
"refs/heads/other"));
RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
@@ -224,7 +224,7 @@ public class GroovyScriptTest extends GitblitUnitTest { MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
ReceiveCommand command = new ReceiveCommand(ObjectId
- .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), ObjectId.zeroId(),
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), ObjectId.zeroId(),
"refs/tags/v1.0");
commands.add(command);
@@ -242,8 +242,8 @@ public class GroovyScriptTest extends GitblitUnitTest { MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
commands.add(new ReceiveCommand(ObjectId
- .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
- .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifth)), ObjectId
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master"));
RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
@@ -262,8 +262,8 @@ public class GroovyScriptTest extends GitblitUnitTest { MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
commands.add(new ReceiveCommand(ObjectId
- .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
- .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifth)), ObjectId
+ .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master"));
RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
diff --git a/src/test/java/com/gitblit/tests/JGitUtilsTest.java b/src/test/java/com/gitblit/tests/JGitUtilsTest.java index c273e860..b133a8c8 100644 --- a/src/test/java/com/gitblit/tests/JGitUtilsTest.java +++ b/src/test/java/com/gitblit/tests/JGitUtilsTest.java @@ -108,7 +108,8 @@ public class JGitUtilsTest extends GitblitUnitTest { Date firstChange = JGitUtils.getFirstChange(repository, null);
repository.close();
assertNotNull("Could not get first commit!", commit);
- assertEquals("Incorrect first commit!", "f554664a346629dc2b839f7292d06bad2db4aece",
+ assertEquals("Incorrect first commit!",
+ GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.first),
commit.getName());
assertTrue(firstChange.equals(new Date(commit.getCommitTime() * 1000L)));
}
@@ -442,10 +443,10 @@ public class JGitUtilsTest extends GitblitUnitTest { public void testFilesInCommit() throws Exception {
Repository repository = GitBlitSuite.getHelloworldRepository();
RevCommit commit = JGitUtils.getCommit(repository,
- "1d0c2933a4ae69c362f76797d42d6bd182d05176");
+ GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifteen));
List<PathChangeModel> paths = JGitUtils.getFilesInCommit(repository, commit);
- commit = JGitUtils.getCommit(repository, "af0e9b2891fda85afc119f04a69acf7348922830");
+ commit = JGitUtils.getCommit(repository, GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted));
List<PathChangeModel> deletions = JGitUtils.getFilesInCommit(repository, commit);
commit = JGitUtils.getFirstCommit(repository, null);
@@ -537,8 +538,8 @@ public class JGitUtilsTest extends GitblitUnitTest { public void testRevLogRange() throws Exception {
Repository repository = GitBlitSuite.getHelloworldRepository();
List<RevCommit> commits = JGitUtils.getRevLog(repository,
- "fbd14fa6d1a01d4aefa1fca725792683800fc67e",
- "85a0e4087b8439c0aa6b1f4f9e08c26052ab7e87");
+ GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.second),
+ GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifteen));
repository.close();
assertEquals(14, commits.size());
}
diff --git a/src/test/java/com/gitblit/tests/MetricUtilsTest.java b/src/test/java/com/gitblit/tests/MetricUtilsTest.java index 4d620ae6..c5b943d4 100644 --- a/src/test/java/com/gitblit/tests/MetricUtilsTest.java +++ b/src/test/java/com/gitblit/tests/MetricUtilsTest.java @@ -45,7 +45,7 @@ public class MetricUtilsTest extends GitblitUnitTest { List<Metric> byEmail = MetricUtils.getAuthorMetrics(repository, null, true);
List<Metric> byName = MetricUtils.getAuthorMetrics(repository, null, false);
repository.close();
- assertEquals("No author metrics found!", 9, byEmail.size());
- assertEquals("No author metrics found!", 8, byName.size());
+ assertEquals("No author metrics found!", GitBlitSuite.helloworldSettings.getInteger(HelloworldKeys.users.byEmail, -1), byEmail.size());
+ assertEquals("No author metrics found!", GitBlitSuite.helloworldSettings.getInteger(HelloworldKeys.users.byName, -1), byName.size());
}
}
\ No newline at end of file |