소스 검색

Fix Lucene tests and drop problematic test repository

tags/v1.3.0
James Moger 11 년 전
부모
커밋
2aa1317dae
2개의 변경된 파일23개의 추가작업 그리고 37개의 파일을 삭제
  1. 0
    5
      src/test/java/com/gitblit/tests/GitBlitSuite.java
  2. 23
    32
      src/test/java/com/gitblit/tests/LuceneExecutorTest.java

+ 0
- 5
src/test/java/com/gitblit/tests/GitBlitSuite.java 파일 보기

return getRepository("test/ambition.git"); return getRepository("test/ambition.git");
} }
public static Repository getTheoreticalPhysicsRepository() throws Exception {
return getRepository("test/theoretical-physics.git");
}
public static Repository getIssuesTestRepository() throws Exception { public static Repository getIssuesTestRepository() throws Exception {
JGitUtils.createRepository(REPOSITORIES, "gb-issues.git").close(); JGitUtils.createRepository(REPOSITORIES, "gb-issues.git").close();
return getRepository("gb-issues.git"); return getRepository("gb-issues.git");
cloneOrFetch("test/jgit.git", "https://github.com/eclipse/jgit.git"); cloneOrFetch("test/jgit.git", "https://github.com/eclipse/jgit.git");
cloneOrFetch("test/helloworld.git", "https://github.com/git/hello-world.git"); cloneOrFetch("test/helloworld.git", "https://github.com/git/hello-world.git");
cloneOrFetch("test/ambition.git", "https://github.com/defunkt/ambition.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"); cloneOrFetch("test/gitective.git", "https://github.com/kevinsawicki/gitective.git");
enableTickets("ticgit.git"); enableTickets("ticgit.git");

+ 23
- 32
src/test/java/com/gitblit/tests/LuceneExecutorTest.java 파일 보기

import java.util.Map; import java.util.Map;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import org.junit.After;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import com.gitblit.LuceneExecutor; import com.gitblit.LuceneExecutor;
*/ */
public class LuceneExecutorTest { public class LuceneExecutorTest {
LuceneExecutor lucene;
private LuceneExecutor newLuceneExecutor() { private LuceneExecutor newLuceneExecutor() {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
MemorySettings settings = new MemorySettings(map); MemorySettings settings = new MemorySettings(map);
return model; return model;
} }
@Before
public void setup() {
lucene = newLuceneExecutor();
}
@After
public void tearDown() {
lucene.close();
}
@Test @Test
public void testIndex() throws Exception { public void testIndex() throws Exception {
LuceneExecutor lucene = newLuceneExecutor();
// reindex helloworld // reindex helloworld
Repository repository = GitBlitSuite.getHelloworldRepository(); Repository repository = GitBlitSuite.getHelloworldRepository();
RepositoryModel model = newRepositoryModel(repository); RepositoryModel model = newRepositoryModel(repository);
result = lucene.search("type:blob AND path:clipper.prg", 1, 1, model.name).get(0); result = lucene.search("type:blob AND path:clipper.prg", 1, 1, model.name).get(0);
assertEquals("tinogomes", result.author); assertEquals("tinogomes", result.author);
// reindex theoretical physics
repository = GitBlitSuite.getTheoreticalPhysicsRepository();
model = newRepositoryModel(repository);
lucene.reindex(model, repository);
repository.close();
// reindex JGit // reindex JGit
repository = GitBlitSuite.getJGitRepository(); repository = GitBlitSuite.getJGitRepository();
model = newRepositoryModel(repository); model = newRepositoryModel(repository);
lucene.reindex(model, repository); lucene.reindex(model, repository);
repository.close(); repository.close();
lucene.close();
} }
@Test @Test
public void testQuery() throws Exception { public void testQuery() throws Exception {
LuceneExecutor lucene = new LuceneExecutor(null, GitBlitSuite.REPOSITORIES);
// 2 occurrences on the master branch // 2 occurrences on the master branch
Repository repository = GitBlitSuite.getHelloworldRepository(); Repository repository = GitBlitSuite.getHelloworldRepository();
RepositoryModel model = newRepositoryModel(repository); RepositoryModel model = newRepositoryModel(repository);
assertEquals(1, results.size()); assertEquals(1, results.size());
assertEquals("d.D", results.get(0).path); 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); model = newRepositoryModel(repository);
repository.close(); 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(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 // 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()); 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()); assertEquals(1, results.size());
// annotated tag test // annotated tag test
repository = GitBlitSuite.getJGitRepository();
model = newRepositoryModel(repository);
repository.close();
results = lucene.search("I663208919f297836a9c16bf458e4a43ffaca4c12", 1, 10, model.name); results = lucene.search("I663208919f297836a9c16bf458e4a43ffaca4c12", 1, 10, model.name);
assertEquals(1, results.size()); assertEquals(1, results.size());
assertEquals("[v1.3.0.201202151440-r]", results.get(0).tags.toString()); assertEquals("[v1.3.0.201202151440-r]", results.get(0).tags.toString());
lucene.close();
} }
@Test @Test
public void testMultiSearch() throws Exception { public void testMultiSearch() throws Exception {
LuceneExecutor lucene = newLuceneExecutor();
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();
Repository repository = GitBlitSuite.getHelloworldRepository(); Repository repository = GitBlitSuite.getHelloworldRepository();
list.add(newRepositoryModel(repository).name); list.add(newRepositoryModel(repository).name);
repository.close(); repository.close();
List<SearchResult> results = lucene.search("test", 1, 10, list); List<SearchResult> results = lucene.search("test", 1, 10, list);
lucene.close();
assertEquals(10, results.size()); assertEquals(10, results.size());
} }
@Test @Test
public void testDeleteBlobFromIndex() throws Exception { public void testDeleteBlobFromIndex() throws Exception {
// start with a fresh reindex of entire repository // start with a fresh reindex of entire repository
LuceneExecutor lucene = newLuceneExecutor();
Repository repository = GitBlitSuite.getHelloworldRepository(); Repository repository = GitBlitSuite.getHelloworldRepository();
RepositoryModel model = newRepositoryModel(repository); RepositoryModel model = newRepositoryModel(repository);
lucene.reindex(model, repository); lucene.reindex(model, repository);

Loading…
취소
저장