From c7bf84f79a03613368447ca87d86f033f0fedb7d Mon Sep 17 00:00:00 2001 From: chirontt Date: Sat, 27 Apr 2019 14:51:26 -0400 Subject: Zips of recreated hello-world.git and all external repositories for testing. This hello-world.git repo is created using the native Git for Windows software. Various test classes in the GitBlitSuite test suite require the presence of the hello-world.git repo in github.com/git/ which has been missing, hence causing many test failures in the suite. This recreation of the hello-world.git repo aims to conform to the many test cases' requirements in the suite, and to be checked in as part of the gitblit repo, thus eliminates the requirement of a remote hello-world.git repo during the test run. The repo is now stored is a zip ball in the new src/test/data folder. The hello-world repo's various commit IDs were hard-coded in various test classes. These commit IDs, which must now have new values in the recreated repo, are now extracted out to the src/test/data/hello-world.properties file. The gitblit's build.xml is modified to generate the HelloworldKeys.java file containing the hello-world.properties file's key strings, in similar fashion as the existing generation of the com.gitblit.Keys.java file. And these key strings in HelloworldKeys.java are now used in the various test classes, thus eliminating the hard-coding of the hello-world repo's commit IDs in the test code. During the test run by GitBlitSuite test suite, some repos from GitHub were cloned and became part of the test data. These repos are now zipped to be part of gitblit repo itself, thus eliminating the network fetch at the start of test run which can be slow, especially with the JGit repo cloning which is huge and time consuming. The cloned JGit repo is now zipped and checked in to gitblit, along with the other 4 repos (hello-world, ambition, gitective and ticgit). They will be unzipped during the test suite run and be available in the local file system, thus avoiding the need for some network fetch. Special note on the zipped JGit repo: this repo is big (and growing all the time on GitHub), and takes up about 32MB of disk space after cloning from GitHub. I've made it smaller by resetting HEAD back to a commit of 5 years ago (with git reset --hard command), to put it back to roughly where/when the tests were written for it (which is not quite, because there are tons of commit history since which can't be removed.) The local JGit repo is then garbage-collected (with git gc --prune --aggressive) to reduce its size to about 19MB. Zipped it is still 17MB. This is a lot of MBs for a few tests. So the JGit repo is not included in this commit. Fixes #1275 --- src/test/data/.gitignore | 1 + src/test/data/ambition.git.zip | Bin 0 -> 199401 bytes src/test/data/gitective.git.zip | Bin 0 -> 2974989 bytes src/test/data/hello-world.git.zip | Bin 0 -> 55129 bytes src/test/data/hello-world.properties | 9 ++ src/test/data/ticgit.git.zip | Bin 0 -> 364736 bytes src/test/java/com/gitblit/tests/.gitignore | 1 + src/test/java/com/gitblit/tests/DiffUtilsTest.java | 22 ++--- src/test/java/com/gitblit/tests/GitBlitSuite.java | 94 +++++++++++++++++++-- .../java/com/gitblit/tests/GroovyScriptTest.java | 46 +++++----- src/test/java/com/gitblit/tests/JGitUtilsTest.java | 11 +-- .../java/com/gitblit/tests/MetricUtilsTest.java | 4 +- 12 files changed, 142 insertions(+), 46 deletions(-) create mode 100644 src/test/data/.gitignore create mode 100644 src/test/data/ambition.git.zip create mode 100644 src/test/data/gitective.git.zip create mode 100644 src/test/data/hello-world.git.zip create mode 100644 src/test/data/hello-world.properties create mode 100644 src/test/data/ticgit.git.zip create mode 100644 src/test/java/com/gitblit/tests/.gitignore (limited to 'src') 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 new file mode 100644 index 00000000..9aaa4997 Binary files /dev/null and b/src/test/data/ambition.git.zip differ diff --git a/src/test/data/gitective.git.zip b/src/test/data/gitective.git.zip new file mode 100644 index 00000000..1071d911 Binary files /dev/null and b/src/test/data/gitective.git.zip differ diff --git a/src/test/data/hello-world.git.zip b/src/test/data/hello-world.git.zip new file mode 100644 index 00000000..e1057a6b Binary files /dev/null and b/src/test/data/hello-world.git.zip differ 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 new file mode 100644 index 00000000..18df11cc Binary files /dev/null and b/src/test/data/ticgit.git.zip differ 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 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 commands = new ArrayList(); 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(); @@ -96,11 +96,11 @@ public class GroovyScriptTest extends GitblitUnitTest { MockClientLogger clientLogger = new MockClientLogger(); List commands = new ArrayList(); 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 commands = new ArrayList(); 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 commands = new ArrayList(); 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 commands = new ArrayList(); 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 commands = new ArrayList(); 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 commands = new ArrayList(); 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 commands = new ArrayList(); 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 commands = new ArrayList(); 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 commands = new ArrayList(); 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 commands = new ArrayList(); 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 paths = JGitUtils.getFilesInCommit(repository, commit); - commit = JGitUtils.getCommit(repository, "af0e9b2891fda85afc119f04a69acf7348922830"); + commit = JGitUtils.getCommit(repository, GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)); List 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 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 byEmail = MetricUtils.getAuthorMetrics(repository, null, true); List 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 -- cgit v1.2.3