]> source.dussan.org Git - gitblit.git/commitdiff
Zips of recreated hello-world.git and all external repositories for testing.
authorchirontt <chirontt@chirontt.org>
Sat, 27 Apr 2019 18:51:26 +0000 (14:51 -0400)
committerFlorian Zschocke <florian.zschocke@devolo.de>
Fri, 7 Jun 2019 19:28:31 +0000 (21:28 +0200)
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 <commitId> 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

13 files changed:
build.xml
src/test/data/.gitignore [new file with mode: 0644]
src/test/data/ambition.git.zip [new file with mode: 0644]
src/test/data/gitective.git.zip [new file with mode: 0644]
src/test/data/hello-world.git.zip [new file with mode: 0644]
src/test/data/hello-world.properties [new file with mode: 0644]
src/test/data/ticgit.git.zip [new file with mode: 0644]
src/test/java/com/gitblit/tests/.gitignore [new file with mode: 0644]
src/test/java/com/gitblit/tests/DiffUtilsTest.java
src/test/java/com/gitblit/tests/GitBlitSuite.java
src/test/java/com/gitblit/tests/GroovyScriptTest.java
src/test/java/com/gitblit/tests/JGitUtilsTest.java
src/test/java/com/gitblit/tests/MetricUtilsTest.java

index f3414d7fb44ac0da8967b70a1831ff003839d678..4db5d9f1ea6db89a863d3648c708303b5b9cc53e 100644 (file)
--- a/build.xml
+++ b/build.xml
        -->\r
        <target name="test" depends="compile" description="compiles Gitblit from source and runs unit tests">\r
                \r
+               <!-- Generate the HelloworldKeys class from the hello-world.properties file -->\r
+               <mx:keys propertiesfile="${basedir}/src/test/data/hello-world.properties"\r
+                               outputclass="com.gitblit.tests.HelloworldKeys"\r
+                               todir="${basedir}/src/test/java" />\r
+\r
                <!-- Compile unit tests -->\r
                <mx:javac scope="test" />\r
                \r
diff --git a/src/test/data/.gitignore b/src/test/data/.gitignore
new file mode 100644 (file)
index 0000000..7056b03
--- /dev/null
@@ -0,0 +1 @@
+/*.git/
diff --git a/src/test/data/ambition.git.zip b/src/test/data/ambition.git.zip
new file mode 100644 (file)
index 0000000..9aaa499
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 (file)
index 0000000..1071d91
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 (file)
index 0000000..e1057a6
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 (file)
index 0000000..99ed126
--- /dev/null
@@ -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 (file)
index 0000000..18df11c
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 (file)
index 0000000..4487459
--- /dev/null
@@ -0,0 +1 @@
+/HelloworldKeys.java
index e8e839a512145ed3fd74279b63b4a08a5d750cdb..9ba7202fe409afa3c4956cc0c7416a266cc8e226 100644 (file)
@@ -40,7 +40,7 @@ public class DiffUtilsTest extends GitblitUnitTest {
        public void testParentCommitDiff() throws Exception {\r
                Repository repository = GitBlitSuite.getHelloworldRepository();\r
                RevCommit commit = JGitUtils.getCommit(repository,\r
-                               "1d0c2933a4ae69c362f76797d42d6bd182d05176");\r
+                               GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.second));\r
                String diff = DiffUtils.getCommitDiff(repository, commit, DiffComparator.SHOW_WHITESPACE, DiffOutputType.PLAIN, 3).content;\r
                repository.close();\r
                assertTrue(diff != null && diff.length() > 0);\r
@@ -52,9 +52,9 @@ public class DiffUtilsTest extends GitblitUnitTest {
        public void testArbitraryCommitDiff() throws Exception {\r
                Repository repository = GitBlitSuite.getHelloworldRepository();\r
                RevCommit baseCommit = JGitUtils.getCommit(repository,\r
-                               "8baf6a833b5579384d9b9ceb8a16b5d0ea2ec4ca");\r
+                               GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.first));\r
                RevCommit commit = JGitUtils.getCommit(repository,\r
-                               "1d0c2933a4ae69c362f76797d42d6bd182d05176");\r
+                               GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.second));\r
                String diff = DiffUtils.getDiff(repository, baseCommit, commit, DiffComparator.SHOW_WHITESPACE, DiffOutputType.PLAIN, 3).content;\r
                repository.close();\r
                assertTrue(diff != null && diff.length() > 0);\r
@@ -66,7 +66,7 @@ public class DiffUtilsTest extends GitblitUnitTest {
        public void testPlainFileDiff() throws Exception {\r
                Repository repository = GitBlitSuite.getHelloworldRepository();\r
                RevCommit commit = JGitUtils.getCommit(repository,\r
-                               "1d0c2933a4ae69c362f76797d42d6bd182d05176");\r
+                               GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.second));\r
                String diff = DiffUtils.getDiff(repository, commit, "java.java", DiffComparator.SHOW_WHITESPACE, DiffOutputType.PLAIN, 3).content;\r
                repository.close();\r
                assertTrue(diff != null && diff.length() > 0);\r
@@ -78,7 +78,7 @@ public class DiffUtilsTest extends GitblitUnitTest {
        public void testFilePatch() throws Exception {\r
                Repository repository = GitBlitSuite.getHelloworldRepository();\r
                RevCommit commit = JGitUtils.getCommit(repository,\r
-                               "1d0c2933a4ae69c362f76797d42d6bd182d05176");\r
+                               GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.second));\r
                String patch = DiffUtils.getCommitPatch(repository, null, commit, "java.java");\r
                repository.close();\r
                assertTrue(patch != null && patch.length() > 0);\r
@@ -90,9 +90,9 @@ public class DiffUtilsTest extends GitblitUnitTest {
        public void testArbitraryFilePatch() throws Exception {\r
                Repository repository = GitBlitSuite.getHelloworldRepository();\r
                RevCommit baseCommit = JGitUtils.getCommit(repository,\r
-                               "8baf6a833b5579384d9b9ceb8a16b5d0ea2ec4ca");\r
+                               GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.first));\r
                RevCommit commit = JGitUtils.getCommit(repository,\r
-                               "1d0c2933a4ae69c362f76797d42d6bd182d05176");\r
+                               GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.second));\r
                String patch = DiffUtils.getCommitPatch(repository, baseCommit, commit, "java.java");\r
                repository.close();\r
                assertTrue(patch != null && patch.length() > 0);\r
@@ -104,9 +104,9 @@ public class DiffUtilsTest extends GitblitUnitTest {
        public void testArbitraryCommitPatch() throws Exception {\r
                Repository repository = GitBlitSuite.getHelloworldRepository();\r
                RevCommit baseCommit = JGitUtils.getCommit(repository,\r
-                               "8baf6a833b5579384d9b9ceb8a16b5d0ea2ec4ca");\r
+                               GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.first));\r
                RevCommit commit = JGitUtils.getCommit(repository,\r
-                               "1d0c2933a4ae69c362f76797d42d6bd182d05176");\r
+                               GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.second));\r
                String patch = DiffUtils.getCommitPatch(repository, baseCommit, commit, null);\r
                repository.close();\r
                assertTrue(patch != null && patch.length() > 0);\r
@@ -118,9 +118,9 @@ public class DiffUtilsTest extends GitblitUnitTest {
        public void testBlame() throws Exception {\r
                Repository repository = GitBlitSuite.getHelloworldRepository();\r
                List<AnnotatedLine> lines = DiffUtils.blame(repository, "java.java",\r
-                               "1d0c2933a4ae69c362f76797d42d6bd182d05176");\r
+                               GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.second));\r
                repository.close();\r
                assertTrue(lines.size() > 0);\r
-               assertEquals("c6d31dccf5cc75e8e46299fc62d38f60ec6d41e0", lines.get(0).commitId);\r
+               assertEquals(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.first), lines.get(0).commitId);\r
        }\r
 }\r
index 133be77fb6dc6e1f203d67947d24e28d213f3bb8..3292d09089e248105b3247ea7eb9415748933cb9 100644 (file)
 package com.gitblit.tests;\r
 \r
 import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileOutputStream;\r
+import java.io.IOException;\r
 import java.lang.reflect.Field;\r
 import java.util.concurrent.Executors;\r
 import java.util.concurrent.atomic.AtomicBoolean;\r
 import java.util.concurrent.atomic.AtomicInteger;\r
+import java.util.zip.ZipEntry;\r
+import java.util.zip.ZipInputStream;\r
 \r
 import org.eclipse.jgit.api.Git;\r
 import org.eclipse.jgit.lib.Repository;\r
@@ -27,12 +32,14 @@ import org.eclipse.jgit.lib.RepositoryCache;
 import org.eclipse.jgit.lib.RepositoryCache.FileKey;\r
 import org.eclipse.jgit.storage.file.FileRepositoryBuilder;\r
 import org.eclipse.jgit.util.FS;\r
+import org.eclipse.jgit.util.FileUtils;\r
 import org.junit.AfterClass;\r
 import org.junit.BeforeClass;\r
 import org.junit.runner.RunWith;\r
 import org.junit.runners.Suite;\r
 import org.junit.runners.Suite.SuiteClasses;\r
 \r
+import com.gitblit.FileSettings;\r
 import com.gitblit.GitBlitException;\r
 import com.gitblit.GitBlitServer;\r
 import com.gitblit.manager.IRepositoryManager;\r
@@ -77,6 +84,18 @@ public class GitBlitSuite {
 \r
        public static final File USERSCONF = new File("src/test/config/test-users.conf");\r
 \r
+       private static final File AMBITION_REPO_SOURCE = new File("src/test/data/ambition.git");\r
+\r
+       private static final File TICGIT_REPO_SOURCE = new File("src/test/data/ticgit.git");\r
+\r
+       private static final File GITECTIVE_REPO_SOURCE = new File("src/test/data/gitective.git");\r
+\r
+       private static final File HELLOWORLD_REPO_SOURCE = new File("src/test/data/hello-world.git");\r
+\r
+       private static final File HELLOWORLD_REPO_PROPERTIES = new File("src/test/data/hello-world.properties");\r
+\r
+       public static final FileSettings helloworldSettings = new FileSettings(HELLOWORLD_REPO_PROPERTIES.getAbsolutePath());\r
+\r
        static int port = 8280;\r
        static int gitPort = 8300;\r
        static int shutdownPort = 8281;\r
@@ -167,17 +186,39 @@ public class GitBlitSuite {
                Thread.sleep(5000);\r
        }\r
 \r
+       public static void deleteRefChecksFolder() throws IOException {\r
+               File refChecks = new File(GitBlitSuite.REPOSITORIES, "refchecks");\r
+               if (refChecks.exists()) {\r
+                       FileUtils.delete(refChecks, FileUtils.RECURSIVE | FileUtils.RETRY);\r
+               }\r
+       }\r
+\r
        @BeforeClass\r
        public static void setUp() throws Exception {\r
+               //"refchecks" folder is used in GitServletTest;\r
+               //need be deleted before Gitblit server instance is started\r
+               deleteRefChecksFolder();\r
                startGitblit();\r
 \r
                if (REPOSITORIES.exists() || REPOSITORIES.mkdirs()) {\r
-                       cloneOrFetch("helloworld.git", "https://github.com/git/hello-world.git");\r
-                       cloneOrFetch("ticgit.git", "https://github.com/schacon/ticgit.git");\r
+                       if (!HELLOWORLD_REPO_SOURCE.exists()) {\r
+                               unzipRepository(HELLOWORLD_REPO_SOURCE.getPath() + ".zip", HELLOWORLD_REPO_SOURCE.getParentFile());\r
+                       }\r
+                       if (!TICGIT_REPO_SOURCE.exists()) {\r
+                               unzipRepository(TICGIT_REPO_SOURCE.getPath() + ".zip", TICGIT_REPO_SOURCE.getParentFile());\r
+                       }\r
+                       if (!AMBITION_REPO_SOURCE.exists()) {\r
+                               unzipRepository(AMBITION_REPO_SOURCE.getPath() + ".zip", AMBITION_REPO_SOURCE.getParentFile());\r
+                       }\r
+                       if (!GITECTIVE_REPO_SOURCE.exists()) {\r
+                               unzipRepository(GITECTIVE_REPO_SOURCE.getPath() + ".zip", GITECTIVE_REPO_SOURCE.getParentFile());\r
+                       }\r
+                       cloneOrFetch("helloworld.git", HELLOWORLD_REPO_SOURCE.getAbsolutePath());\r
+                       cloneOrFetch("ticgit.git", TICGIT_REPO_SOURCE.getAbsolutePath());\r
                        cloneOrFetch("test/jgit.git", "https://github.com/eclipse/jgit.git");\r
-                       cloneOrFetch("test/helloworld.git", "https://github.com/git/hello-world.git");\r
-                       cloneOrFetch("test/ambition.git", "https://github.com/defunkt/ambition.git");\r
-                       cloneOrFetch("test/gitective.git", "https://github.com/kevinsawicki/gitective.git");\r
+                       cloneOrFetch("test/helloworld.git", HELLOWORLD_REPO_SOURCE.getAbsolutePath());\r
+                       cloneOrFetch("test/ambition.git", AMBITION_REPO_SOURCE.getAbsolutePath());\r
+                       cloneOrFetch("test/gitective.git", GITECTIVE_REPO_SOURCE.getAbsolutePath());\r
 \r
                        showRemoteBranches("ticgit.git");\r
                        automaticallyTagBranchTips("ticgit.git");\r
@@ -254,4 +295,47 @@ public class GitBlitSuite {
                        r.close();\r
                }\r
        }\r
+\r
+       private static void unzipRepository(String zippedRepo, File destDir) throws IOException {\r
+               System.out.print("Unzipping " + zippedRepo + "... ");\r
+               if (!destDir.exists()) {\r
+                       destDir.mkdir();\r
+               }\r
+               byte[] buffer = new byte[1024];\r
+               ZipInputStream zis = new ZipInputStream(new FileInputStream(zippedRepo));\r
+               ZipEntry zipEntry = zis.getNextEntry();\r
+               while (zipEntry != null) {\r
+                       File newFile = newFile(destDir, zipEntry);\r
+                       if (zipEntry.isDirectory()) {\r
+                               newFile.mkdirs();\r
+                       }\r
+                       else {\r
+                               FileOutputStream fos = new FileOutputStream(newFile);\r
+                               int len;\r
+                               while ((len = zis.read(buffer)) > 0) {\r
+                                       fos.write(buffer, 0, len);\r
+                               }\r
+                               fos.close();\r
+                       }\r
+                       zipEntry = zis.getNextEntry();\r
+               }\r
+               zis.closeEntry();\r
+               zis.close();            \r
+               System.out.println("done.");\r
+       }\r
+\r
+       private static File newFile(File destinationDir, ZipEntry zipEntry) throws IOException {\r
+               File destFile = new File(destinationDir, zipEntry.getName());\r
+\r
+               String destDirPath = destinationDir.getCanonicalPath();\r
+               String destFilePath = destFile.getCanonicalPath();\r
+               //guards against writing files to the file system outside of the target folder\r
+               //to prevent Zip Slip exploit\r
+               if (!destFilePath.startsWith(destDirPath + File.separator)) {\r
+                       throw new IOException("Entry is outside of the target dir: " + zipEntry.getName());\r
+               }\r
+\r
+               return destFile;\r
+       }\r
+\r
 }\r
index ff40972f4fd40cec6f338c5d78c81e2bffc20ecb..81c6c23a9b5e9e4606a810811215992c4600f4b3 100644 (file)
@@ -74,11 +74,11 @@ public class GroovyScriptTest extends GitblitUnitTest {
                MockClientLogger clientLogger = new MockClientLogger();\r
                List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();\r
                commands.add(new ReceiveCommand(ObjectId\r
-                               .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId\r
-                               .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifth)), ObjectId\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master"));\r
                commands.add(new ReceiveCommand(ObjectId\r
-                               .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId\r
-                               .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master2"));\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifth)), ObjectId\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master2"));\r
 \r
                RepositoryModel repository = repositories().getRepositoryModel("helloworld.git");\r
                repository.customFields = new HashMap<String,String>();\r
@@ -96,11 +96,11 @@ public class GroovyScriptTest extends GitblitUnitTest {
                MockClientLogger clientLogger = new MockClientLogger();\r
                List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();\r
                commands.add(new ReceiveCommand(ObjectId\r
-                               .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId\r
-                               .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifth)), ObjectId\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master"));\r
                commands.add(new ReceiveCommand(ObjectId\r
-                               .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId\r
-                               .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master2"));\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifth)), ObjectId\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master2"));\r
 \r
                RepositoryModel repository = repositories().getRepositoryModel("helloworld.git");\r
                repository.mailingLists.add("list@helloworld.git");\r
@@ -121,11 +121,11 @@ public class GroovyScriptTest extends GitblitUnitTest {
                MockClientLogger clientLogger = new MockClientLogger();\r
                List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();\r
                commands.add(new ReceiveCommand(ObjectId\r
-                               .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId\r
-                               .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifth)), ObjectId\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master"));\r
                commands.add(new ReceiveCommand(ObjectId\r
-                               .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId\r
-                               .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master2"));\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifth)), ObjectId\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master2"));\r
 \r
                RepositoryModel repository = repositories().getRepositoryModel("helloworld.git");\r
                repository.mailingLists.add("list@helloworld.git");\r
@@ -145,7 +145,7 @@ public class GroovyScriptTest extends GitblitUnitTest {
                MockClientLogger clientLogger = new MockClientLogger();\r
                List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();\r
                commands.add(new ReceiveCommand(ObjectId.zeroId(), ObjectId\r
-                               .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master"));\r
 \r
                RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());\r
 \r
@@ -159,7 +159,7 @@ public class GroovyScriptTest extends GitblitUnitTest {
                MockClientLogger clientLogger = new MockClientLogger();\r
                List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();\r
                commands.add(new ReceiveCommand(ObjectId.zeroId(), ObjectId\r
-                               .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/tags/v1.0"));\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/tags/v1.0"));\r
 \r
                RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());\r
 \r
@@ -174,8 +174,8 @@ public class GroovyScriptTest extends GitblitUnitTest {
                MockClientLogger clientLogger = new MockClientLogger();\r
                List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();\r
                commands.add(new ReceiveCommand(ObjectId\r
-                               .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId\r
-                               .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifth)), ObjectId\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master"));\r
 \r
                RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());\r
 \r
@@ -190,7 +190,7 @@ public class GroovyScriptTest extends GitblitUnitTest {
                MockClientLogger clientLogger = new MockClientLogger();\r
                List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();\r
                ReceiveCommand command = new ReceiveCommand(ObjectId\r
-                               .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), ObjectId.zeroId(),\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), ObjectId.zeroId(),\r
                                "refs/heads/master");\r
                commands.add(command);\r
 \r
@@ -208,7 +208,7 @@ public class GroovyScriptTest extends GitblitUnitTest {
                MockClientLogger clientLogger = new MockClientLogger();\r
                List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();\r
                commands.add(new ReceiveCommand(ObjectId\r
-                               .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), ObjectId.zeroId(),\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), ObjectId.zeroId(),\r
                                "refs/heads/other"));\r
 \r
                RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());\r
@@ -224,7 +224,7 @@ public class GroovyScriptTest extends GitblitUnitTest {
                MockClientLogger clientLogger = new MockClientLogger();\r
                List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();\r
                ReceiveCommand command = new ReceiveCommand(ObjectId\r
-                               .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), ObjectId.zeroId(),\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), ObjectId.zeroId(),\r
                                "refs/tags/v1.0");\r
                commands.add(command);\r
 \r
@@ -242,8 +242,8 @@ public class GroovyScriptTest extends GitblitUnitTest {
                MockClientLogger clientLogger = new MockClientLogger();\r
                List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();\r
                commands.add(new ReceiveCommand(ObjectId\r
-                               .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId\r
-                               .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifth)), ObjectId\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master"));\r
 \r
                RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());\r
 \r
@@ -262,8 +262,8 @@ public class GroovyScriptTest extends GitblitUnitTest {
                MockClientLogger clientLogger = new MockClientLogger();\r
                List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();\r
                commands.add(new ReceiveCommand(ObjectId\r
-                               .fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId\r
-                               .fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifth)), ObjectId\r
+                               .fromString(GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted)), "refs/heads/master"));\r
 \r
                RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());\r
 \r
index c273e860c223142aeb072aa21a02f5df5a821b3f..b133a8c8db0cedea0c3400622f0d540ab9c665fa 100644 (file)
@@ -108,7 +108,8 @@ public class JGitUtilsTest extends GitblitUnitTest {
                Date firstChange = JGitUtils.getFirstChange(repository, null);\r
                repository.close();\r
                assertNotNull("Could not get first commit!", commit);\r
-               assertEquals("Incorrect first commit!", "f554664a346629dc2b839f7292d06bad2db4aece",\r
+               assertEquals("Incorrect first commit!",\r
+                               GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.first),\r
                                commit.getName());\r
                assertTrue(firstChange.equals(new Date(commit.getCommitTime() * 1000L)));\r
        }\r
@@ -442,10 +443,10 @@ public class JGitUtilsTest extends GitblitUnitTest {
        public void testFilesInCommit() throws Exception {\r
                Repository repository = GitBlitSuite.getHelloworldRepository();\r
                RevCommit commit = JGitUtils.getCommit(repository,\r
-                               "1d0c2933a4ae69c362f76797d42d6bd182d05176");\r
+                               GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifteen));\r
                List<PathChangeModel> paths = JGitUtils.getFilesInCommit(repository, commit);\r
 \r
-               commit = JGitUtils.getCommit(repository, "af0e9b2891fda85afc119f04a69acf7348922830");\r
+               commit = JGitUtils.getCommit(repository, GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.deleted));\r
                List<PathChangeModel> deletions = JGitUtils.getFilesInCommit(repository, commit);\r
 \r
                commit = JGitUtils.getFirstCommit(repository, null);\r
@@ -537,8 +538,8 @@ public class JGitUtilsTest extends GitblitUnitTest {
        public void testRevLogRange() throws Exception {\r
                Repository repository = GitBlitSuite.getHelloworldRepository();\r
                List<RevCommit> commits = JGitUtils.getRevLog(repository,\r
-                               "fbd14fa6d1a01d4aefa1fca725792683800fc67e",\r
-                               "85a0e4087b8439c0aa6b1f4f9e08c26052ab7e87");\r
+                               GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.second),\r
+                               GitBlitSuite.helloworldSettings.getRequiredString(HelloworldKeys.commit.fifteen));\r
                repository.close();\r
                assertEquals(14, commits.size());\r
        }\r
index 4d620ae6aa5656c69697b22eda7b21b113c6df57..c5b943d4cfbb4c5ee057bff54c74eb8464165ea8 100644 (file)
@@ -45,7 +45,7 @@ public class MetricUtilsTest extends GitblitUnitTest {
                List<Metric> byEmail = MetricUtils.getAuthorMetrics(repository, null, true);\r
                List<Metric> byName = MetricUtils.getAuthorMetrics(repository, null, false);\r
                repository.close();\r
-               assertEquals("No author metrics found!", 9, byEmail.size());\r
-               assertEquals("No author metrics found!", 8, byName.size());\r
+               assertEquals("No author metrics found!", GitBlitSuite.helloworldSettings.getInteger(HelloworldKeys.users.byEmail, -1), byEmail.size());\r
+               assertEquals("No author metrics found!", GitBlitSuite.helloworldSettings.getInteger(HelloworldKeys.users.byName, -1), byName.size());\r
        }\r
 }
\ No newline at end of file