From 36ee2307ea083cfe8994b13a3023bc779b2b23ec Mon Sep 17 00:00:00 2001 From: James Moger Date: Fri, 17 Feb 2012 18:43:40 -0500 Subject: Implemented multi-repository Lucene search --- tests/com/gitblit/tests/IssuesTest.java | 4 ++-- tests/com/gitblit/tests/LuceneUtilsTest.java | 27 ++++++++++++++++++--------- 2 files changed, 20 insertions(+), 11 deletions(-) (limited to 'tests/com/gitblit') diff --git a/tests/com/gitblit/tests/IssuesTest.java b/tests/com/gitblit/tests/IssuesTest.java index c475c466..a5d487d8 100644 --- a/tests/com/gitblit/tests/IssuesTest.java +++ b/tests/com/gitblit/tests/IssuesTest.java @@ -146,7 +146,7 @@ public class IssuesTest { for (IssueModel issue : allIssues) { LuceneUtils.index(repository, issue, false); } - List hits = LuceneUtils.search(repository, "working"); + List hits = LuceneUtils.search("working", 10, repository); assertTrue(hits.size() > 0); // reindex an issue @@ -164,7 +164,7 @@ public class IssuesTest { @Test public void testLuceneQuery() throws Exception { Repository repository = GitBlitSuite.getIssuesTestRepository(); - List hits = LuceneUtils.search(repository, "working"); + List hits = LuceneUtils.search("working", 10, repository); LuceneUtils.close(); repository.close(); assertTrue(hits.size() > 0); diff --git a/tests/com/gitblit/tests/LuceneUtilsTest.java b/tests/com/gitblit/tests/LuceneUtilsTest.java index 648c8128..a5446218 100644 --- a/tests/com/gitblit/tests/LuceneUtilsTest.java +++ b/tests/com/gitblit/tests/LuceneUtilsTest.java @@ -57,48 +57,48 @@ public class LuceneUtilsTest { public void testQuery() throws Exception { // 2 occurrences on the master branch Repository repository = GitBlitSuite.getHelloworldRepository(); - List results = LuceneUtils.search(repository, "ada"); + List results = LuceneUtils.search("ada", 10, repository); assertEquals(2, results.size()); // author test - results = LuceneUtils.search(repository, "author: tinogomes"); + results = LuceneUtils.search("author: tinogomes", 10, repository); assertEquals(2, results.size()); repository.close(); // blob test - results = LuceneUtils.search(repository, "type: blob AND \"import std.stdio\""); + results = LuceneUtils.search("type: blob AND \"import std.stdio\"", 10, repository); assertEquals(1, results.size()); assertEquals("d.D", results.get(0).id); // 1 occurrence on the gh-pages branch repository = GitBlitSuite.getTheoreticalPhysicsRepository(); - results = LuceneUtils.search(repository, "\"add the .nojekyll file\""); + results = LuceneUtils.search("\"add the .nojekyll file\"", 10, repository); assertEquals(1, results.size()); assertEquals("Ondrej Certik", results.get(0).author); assertEquals("2648c0c98f2101180715b4d432fc58d0e21a51d7", results.get(0).id); // tag test - results = LuceneUtils.search(repository, "\"qft split\""); + results = LuceneUtils.search("\"qft split\"", 10, repository); assertEquals(1, results.size()); assertEquals("Ondrej Certik", results.get(0).author); assertEquals("57c4f26f157ece24b02f4f10f5f68db1d2ce7ff5", results.get(0).id); assertEquals("[1st-edition]", results.get(0).labels.toString()); - results = LuceneUtils.search(repository, "type:blob AND \"src/intro.rst\""); + results = LuceneUtils.search("type:blob AND \"src/intro.rst\"", 10, repository); assertEquals(4, results.size()); // hash id tests - results = LuceneUtils.search(repository, "id:57c4f26f157ece24b02f4f10f5f68db1d2ce7ff5"); + results = LuceneUtils.search("id:57c4f26f157ece24b02f4f10f5f68db1d2ce7ff5", 10, repository); assertEquals(1, results.size()); - results = LuceneUtils.search(repository, "id:57c4f26f157*"); + results = LuceneUtils.search("id:57c4f26f157*", 10, repository); assertEquals(1, results.size()); repository.close(); // annotated tag test repository = GitBlitSuite.getBluezGnomeRepository(); - results = LuceneUtils.search(repository, "\"release 1.8\""); + results = LuceneUtils.search("\"release 1.8\"", 10, repository); assertEquals(1, results.size()); assertEquals("[1.8]", results.get(0).labels.toString()); @@ -106,4 +106,13 @@ public class LuceneUtilsTest { LuceneUtils.close(); } + + @Test + public void testMultiSearch() throws Exception { + List results = LuceneUtils.search("test", 10, + GitBlitSuite.getHelloworldRepository(), + GitBlitSuite.getBluezGnomeRepository()); + LuceneUtils.close(); + assertEquals(10, results.size()); + } } \ No newline at end of file -- cgit v1.2.3