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