summaryrefslogtreecommitdiffstats
path: root/tests/com/gitblit
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2012-02-17 18:43:40 -0500
committerJames Moger <james.moger@gitblit.com>2012-02-17 18:43:40 -0500
commit36ee2307ea083cfe8994b13a3023bc779b2b23ec (patch)
tree7d40aa082abc8070b9c3d367eb2156ef9ef8eb84 /tests/com/gitblit
parent0c2ea45eb400b1ded16223c03e63cec0c40564b8 (diff)
downloadgitblit-36ee2307ea083cfe8994b13a3023bc779b2b23ec.tar.gz
gitblit-36ee2307ea083cfe8994b13a3023bc779b2b23ec.zip
Implemented multi-repository Lucene search
Diffstat (limited to 'tests/com/gitblit')
-rw-r--r--tests/com/gitblit/tests/IssuesTest.java4
-rw-r--r--tests/com/gitblit/tests/LuceneUtilsTest.java27
2 files changed, 20 insertions, 11 deletions
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<SearchResult> hits = LuceneUtils.search(repository, "working");
+ List<SearchResult> 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<SearchResult> hits = LuceneUtils.search(repository, "working");
+ List<SearchResult> 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<SearchResult> results = LuceneUtils.search(repository, "ada");
+ List<SearchResult> 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<SearchResult> results = LuceneUtils.search("test", 10,
+ GitBlitSuite.getHelloworldRepository(),
+ GitBlitSuite.getBluezGnomeRepository());
+ LuceneUtils.close();
+ assertEquals(10, results.size());
+ }
} \ No newline at end of file