]> source.dussan.org Git - gitblit.git/commitdiff
Fix Lucene tests and drop problematic test repository
authorJames Moger <james.moger@gitblit.com>
Tue, 2 Jul 2013 18:55:43 +0000 (14:55 -0400)
committerJames Moger <james.moger@gitblit.com>
Tue, 2 Jul 2013 18:55:43 +0000 (14:55 -0400)
src/test/java/com/gitblit/tests/GitBlitSuite.java
src/test/java/com/gitblit/tests/LuceneExecutorTest.java

index d5e37075d98185326a0d8e296b45ddf7d2f740f7..a62220bb97b9335beab4a5ad2bbbfdfb2421414c 100644 (file)
@@ -97,10 +97,6 @@ public class GitBlitSuite {
                return getRepository("test/ambition.git");\r
        }\r
 \r
-       public static Repository getTheoreticalPhysicsRepository() throws Exception {\r
-               return getRepository("test/theoretical-physics.git");\r
-       }\r
-\r
        public static Repository getIssuesTestRepository() throws Exception {\r
                JGitUtils.createRepository(REPOSITORIES, "gb-issues.git").close();\r
                return getRepository("gb-issues.git");\r
@@ -160,7 +156,6 @@ public class GitBlitSuite {
                        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/theoretical-physics.git", "https://github.com/certik/theoretical-physics.git");\r
                        cloneOrFetch("test/gitective.git", "https://github.com/kevinsawicki/gitective.git");\r
                        \r
                        enableTickets("ticgit.git");\r
index 6b45b9fede3030595e22cbaba51be2fa81ec77e1..0b67f5dd88ca36f08e24febc9207574c548c2d79 100644 (file)
@@ -25,6 +25,8 @@ import java.util.List;
 import java.util.Map;\r
 \r
 import org.eclipse.jgit.lib.Repository;\r
+import org.junit.After;\r
+import org.junit.Before;\r
 import org.junit.Test;\r
 \r
 import com.gitblit.LuceneExecutor;\r
@@ -43,6 +45,8 @@ import com.gitblit.utils.JGitUtils;
  */\r
 public class LuceneExecutorTest {\r
 \r
+       LuceneExecutor lucene;\r
+       \r
        private LuceneExecutor newLuceneExecutor() {\r
                Map<String, Object> map = new HashMap<String, Object>();\r
                MemorySettings settings = new MemorySettings(map);              \r
@@ -62,10 +66,18 @@ public class LuceneExecutorTest {
                return model;\r
        }\r
        \r
+       @Before\r
+       public void setup() {\r
+               lucene = newLuceneExecutor();\r
+       }\r
+       \r
+       @After\r
+       public void tearDown() {\r
+               lucene.close();\r
+       }\r
+       \r
        @Test\r
        public void testIndex() throws Exception {\r
-               LuceneExecutor lucene = newLuceneExecutor();\r
-               \r
                // reindex helloworld\r
                Repository repository = GitBlitSuite.getHelloworldRepository();\r
                RepositoryModel model = newRepositoryModel(repository);\r
@@ -77,25 +89,15 @@ public class LuceneExecutorTest {
                result = lucene.search("type:blob AND path:clipper.prg", 1, 1, model.name).get(0);              \r
                assertEquals("tinogomes", result.author);               \r
 \r
-               // reindex theoretical physics\r
-               repository = GitBlitSuite.getTheoreticalPhysicsRepository();\r
-               model = newRepositoryModel(repository);\r
-               lucene.reindex(model, repository);\r
-               repository.close();\r
-               \r
                // reindex JGit\r
                repository = GitBlitSuite.getJGitRepository();\r
                model = newRepositoryModel(repository);\r
                lucene.reindex(model, repository);\r
                repository.close();\r
-               \r
-               lucene.close();\r
        }\r
 \r
        @Test\r
        public void testQuery() throws Exception {\r
-               LuceneExecutor lucene = new LuceneExecutor(null, GitBlitSuite.REPOSITORIES);\r
-               \r
                // 2 occurrences on the master branch\r
                Repository repository = GitBlitSuite.getHelloworldRepository();                         \r
                RepositoryModel model = newRepositoryModel(repository);\r
@@ -116,42 +118,33 @@ public class LuceneExecutorTest {
                assertEquals(1, results.size());\r
                assertEquals("d.D", results.get(0).path);\r
                \r
-               // 1 occurrence on the gh-pages branch\r
-               repository = GitBlitSuite.getTheoreticalPhysicsRepository();\r
+               // commit test\r
+               repository = GitBlitSuite.getJGitRepository();\r
                model = newRepositoryModel(repository);\r
                repository.close();\r
                \r
-               results = lucene.search("\"add the .nojekyll file\"", 1, 10, model.name);\r
+               results = lucene.search("\"initial jgit contribution to eclipse.org\"", 1, 10, model.name);\r
                assertEquals(1, results.size());\r
-               assertEquals("Ondrej Certik", results.get(0).author);\r
-               assertEquals("2648c0c98f2101180715b4d432fc58d0e21a51d7", results.get(0).commitId);\r
-               assertEquals("refs/heads/gh-pages", results.get(0).branch);\r
-               \r
-               results = lucene.search("type:blob AND \"src/intro.rst\"", 1, 10, model.name);\r
-               assertEquals(4, results.size());\r
+               assertEquals("Git Development Community", results.get(0).author);\r
+               assertEquals("1a6964c8274c50f0253db75f010d78ef0e739343", results.get(0).commitId);\r
+               assertEquals("refs/heads/master", results.get(0).branch);\r
                \r
                // hash id tests\r
-               results = lucene.search("commit:57c4f26f157ece24b02f4f10f5f68db1d2ce7ff5", 1, 10, model.name);\r
+               results = lucene.search("type:commit AND commit:1a6964c8274c50f0253db75f010d78ef0e739343", 1, 10, model.name);\r
                assertEquals(1, results.size());\r
 \r
-               results = lucene.search("commit:57c4f26f157*", 1, 10, model.name);\r
+               results = lucene.search("type:commit AND commit:1a6964c8274*", 1, 10, model.name);\r
+               assertEquals("Shawn O. Pearce", results.get(0).committer);\r
                assertEquals(1, results.size());                \r
                \r
                // annotated tag test\r
-               repository = GitBlitSuite.getJGitRepository();\r
-               model = newRepositoryModel(repository);\r
-               repository.close();\r
-               \r
                results = lucene.search("I663208919f297836a9c16bf458e4a43ffaca4c12", 1, 10, model.name);\r
                assertEquals(1, results.size());\r
                assertEquals("[v1.3.0.201202151440-r]", results.get(0).tags.toString());                \r
-               \r
-               lucene.close();\r
        }\r
        \r
        @Test\r
        public void testMultiSearch() throws Exception {\r
-               LuceneExecutor lucene = newLuceneExecutor();\r
                List<String> list = new ArrayList<String>();\r
                Repository repository = GitBlitSuite.getHelloworldRepository();\r
                list.add(newRepositoryModel(repository).name);\r
@@ -162,14 +155,12 @@ public class LuceneExecutorTest {
                repository.close();\r
 \r
                List<SearchResult> results = lucene.search("test", 1, 10, list);\r
-               lucene.close();\r
                assertEquals(10, results.size());\r
        }\r
        \r
        @Test\r
        public void testDeleteBlobFromIndex() throws Exception {\r
                // start with a fresh reindex of entire repository\r
-               LuceneExecutor lucene = newLuceneExecutor();\r
                Repository repository = GitBlitSuite.getHelloworldRepository();\r
                RepositoryModel model = newRepositoryModel(repository);\r
                lucene.reindex(model, repository);\r