diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/com/gitblit/tests/GitBlitSuite.java | 9 | ||||
-rw-r--r-- | tests/com/gitblit/tests/IssuesTest.java | 68 | ||||
-rw-r--r-- | tests/com/gitblit/tests/JGitUtilsTest.java | 8 | ||||
-rw-r--r-- | tests/com/gitblit/tests/LuceneUtilsTest.java | 16 | ||||
-rw-r--r-- | tests/com/gitblit/tests/MetricUtilsTest.java | 2 |
5 files changed, 38 insertions, 65 deletions
diff --git a/tests/com/gitblit/tests/GitBlitSuite.java b/tests/com/gitblit/tests/GitBlitSuite.java index 8fac212c..210a7dac 100644 --- a/tests/com/gitblit/tests/GitBlitSuite.java +++ b/tests/com/gitblit/tests/GitBlitSuite.java @@ -78,10 +78,6 @@ public class GitBlitSuite { return new FileRepository(new File(REPOSITORIES, "test/jgit.git"));
}
- public static Repository getBluezGnomeRepository() throws Exception {
- return new FileRepository(new File(REPOSITORIES, "test/bluez-gnome.git"));
- }
-
public static Repository getAmbitionRepository() throws Exception {
return new FileRepository(new File(REPOSITORIES, "test/ambition.git"));
}
@@ -93,6 +89,10 @@ public class GitBlitSuite { public static Repository getIssuesTestRepository() throws Exception {
return new FileRepository(new File(REPOSITORIES, "gb-issues.git"));
}
+
+ public static Repository getGitectiveRepository() throws Exception {
+ return new FileRepository(new File("test/gitective.git"));
+ }
public static boolean startGitblit() throws Exception {
if (started.get()) {
@@ -137,6 +137,7 @@ public class GitBlitSuite { 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");
JGitUtils.createRepository(REPOSITORIES, "gb-issues.git").close();
diff --git a/tests/com/gitblit/tests/IssuesTest.java b/tests/com/gitblit/tests/IssuesTest.java index a5d487d8..1224a040 100644 --- a/tests/com/gitblit/tests/IssuesTest.java +++ b/tests/com/gitblit/tests/IssuesTest.java @@ -46,9 +46,10 @@ import com.gitblit.utils.LuceneUtils; public class IssuesTest {
@Test
- public void testCreation() throws Exception {
+ public void testLifecycle() throws Exception {
Repository repository = GitBlitSuite.getIssuesTestRepository();
- // create and insert the issue
+
+ // create and insert an issue
Change c1 = newChange("testCreation() " + Long.toHexString(System.currentTimeMillis()));
IssueModel issue = IssueUtils.createIssue(repository, c1);
assertNotNull(issue.id);
@@ -58,18 +59,15 @@ public class IssuesTest { compare(issue, constructed);
assertEquals(1, constructed.changes.size());
- }
-
- @Test
- public void testUpdates() throws Exception {
- Repository repository = GitBlitSuite.getIssuesTestRepository();
+
// C1: create the issue
- Change c1 = newChange("testUpdates() " + Long.toHexString(System.currentTimeMillis()));
- IssueModel issue = IssueUtils.createIssue(repository, c1);
+ c1 = newChange("testUpdates() " + Long.toHexString(System.currentTimeMillis()));
+ issue = IssueUtils.createIssue(repository, c1);
assertNotNull(issue.id);
- IssueModel constructed = IssueUtils.getIssue(repository, issue.id);
+ constructed = IssueUtils.getIssue(repository, issue.id);
compare(issue, constructed);
+ assertEquals(1, constructed.changes.size());
// C2: set owner
Change c2 = new Change("C2");
@@ -109,21 +107,13 @@ public class IssuesTest { assertEquals(5, constructed.changes.size());
assertTrue(constructed.status.isClosed());
- repository.close();
- }
-
- @Test
- public void testQuery() throws Exception {
- Repository repository = GitBlitSuite.getIssuesTestRepository();
List<IssueModel> allIssues = IssueUtils.getIssues(repository, null);
-
List<IssueModel> openIssues = IssueUtils.getIssues(repository, new IssueFilter() {
@Override
public boolean accept(IssueModel issue) {
return !issue.status.isClosed();
}
});
-
List<IssueModel> closedIssues = IssueUtils.getIssues(repository, new IssueFilter() {
@Override
public boolean accept(IssueModel issue) {
@@ -131,57 +121,35 @@ public class IssuesTest { }
});
- repository.close();
assertTrue(allIssues.size() > 0);
assertEquals(1, openIssues.size());
assertEquals(1, closedIssues.size());
- }
-
- @Test
- public void testLuceneIndexAndQuery() throws Exception {
- Repository repository = GitBlitSuite.getIssuesTestRepository();
+
+ // build a new Lucene index
LuceneUtils.deleteIndex(repository);
- List<IssueModel> allIssues = IssueUtils.getIssues(repository, null);
- assertTrue(allIssues.size() > 0);
- for (IssueModel issue : allIssues) {
- LuceneUtils.index(repository, issue, false);
+ for (IssueModel anIssue : allIssues) {
+ LuceneUtils.index(repository, anIssue, false);
}
List<SearchResult> hits = LuceneUtils.search("working", 10, repository);
assertTrue(hits.size() > 0);
// reindex an issue
- IssueModel issue = allIssues.get(0);
+ issue = allIssues.get(0);
Change change = new Change("reindex");
change.comment("this is a test of reindexing an issue");
IssueUtils.updateIssue(repository, issue.id, change);
issue = IssueUtils.getIssue(repository, issue.id);
LuceneUtils.index(repository, issue, true);
-
- LuceneUtils.close();
- repository.close();
- }
-
- @Test
- public void testLuceneQuery() throws Exception {
- Repository repository = GitBlitSuite.getIssuesTestRepository();
- List<SearchResult> hits = LuceneUtils.search("working", 10, repository);
- LuceneUtils.close();
- repository.close();
- assertTrue(hits.size() > 0);
- }
-
- @Test
- public void testDelete() throws Exception {
- Repository repository = GitBlitSuite.getIssuesTestRepository();
- List<IssueModel> allIssues = IssueUtils.getIssues(repository, null);
// delete all issues
- for (IssueModel issue : allIssues) {
- assertTrue(IssueUtils.deleteIssue(repository, issue.id, "D"));
+ for (IssueModel anIssue : allIssues) {
+ assertTrue(IssueUtils.deleteIssue(repository, anIssue.id, "D"));
}
+
+ LuceneUtils.close();
repository.close();
}
-
+
@Test
public void testChangeComment() throws Exception {
Repository repository = GitBlitSuite.getIssuesTestRepository();
diff --git a/tests/com/gitblit/tests/JGitUtilsTest.java b/tests/com/gitblit/tests/JGitUtilsTest.java index d365bdea..e649769e 100644 --- a/tests/com/gitblit/tests/JGitUtilsTest.java +++ b/tests/com/gitblit/tests/JGitUtilsTest.java @@ -190,12 +190,12 @@ public class JGitUtilsTest { }
repository.close();
- repository = GitBlitSuite.getBluezGnomeRepository();
+ repository = GitBlitSuite.getGitectiveRepository();
for (RefModel model : JGitUtils.getTags(repository, true, -1)) {
- if (model.getObjectId().getName().equals("728643ec0c438c77e182898c2f2967dbfdc231c8")) {
+ if (model.getObjectId().getName().equals("035254295a9bba11f72b1f9d6791a6b957abee7b")) {
assertFalse(model.isAnnotatedTag());
- assertTrue(model.getAuthorIdent().getEmailAddress().equals("marcel@holtmann.org"));
- assertEquals("Update changelog and bump version number\n", model.getFullMessage());
+ assertTrue(model.getAuthorIdent().getEmailAddress().equals("kevinsawicki@gmail.com"));
+ assertEquals("Add scm and issue tracker elements to pom.xml\n", model.getFullMessage());
}
}
repository.close();
diff --git a/tests/com/gitblit/tests/LuceneUtilsTest.java b/tests/com/gitblit/tests/LuceneUtilsTest.java index a5446218..70756953 100644 --- a/tests/com/gitblit/tests/LuceneUtilsTest.java +++ b/tests/com/gitblit/tests/LuceneUtilsTest.java @@ -45,8 +45,8 @@ public class LuceneUtilsTest { LuceneUtils.index(repository);
repository.close();
- // reindex bluez-gnome
- repository = GitBlitSuite.getBluezGnomeRepository();
+ // reindex JGit
+ repository = GitBlitSuite.getJGitRepository();
LuceneUtils.index(repository);
repository.close();
@@ -59,6 +59,9 @@ public class LuceneUtilsTest { Repository repository = GitBlitSuite.getHelloworldRepository();
List<SearchResult> results = LuceneUtils.search("ada", 10, repository);
assertEquals(2, results.size());
+ for (SearchResult res : results) {
+ assertEquals("refs/heads/master", res.branch);
+ }
// author test
results = LuceneUtils.search("author: tinogomes", 10, repository);
@@ -76,6 +79,7 @@ public class LuceneUtilsTest { assertEquals(1, results.size());
assertEquals("Ondrej Certik", results.get(0).author);
assertEquals("2648c0c98f2101180715b4d432fc58d0e21a51d7", results.get(0).id);
+ assertEquals("refs/heads/gh-pages", results.get(0).branch);
// tag test
results = LuceneUtils.search("\"qft split\"", 10, repository);
@@ -97,10 +101,10 @@ public class LuceneUtilsTest { repository.close();
// annotated tag test
- repository = GitBlitSuite.getBluezGnomeRepository();
- results = LuceneUtils.search("\"release 1.8\"", 10, repository);
+ repository = GitBlitSuite.getJGitRepository();
+ results = LuceneUtils.search("I663208919f297836a9c16bf458e4a43ffaca4c12", 10, repository);
assertEquals(1, results.size());
- assertEquals("[1.8]", results.get(0).labels.toString());
+ assertEquals("[v1.3.0.201202151440-r]", results.get(0).labels.toString());
repository.close();
@@ -111,7 +115,7 @@ public class LuceneUtilsTest { public void testMultiSearch() throws Exception {
List<SearchResult> results = LuceneUtils.search("test", 10,
GitBlitSuite.getHelloworldRepository(),
- GitBlitSuite.getBluezGnomeRepository());
+ GitBlitSuite.getJGitRepository());
LuceneUtils.close();
assertEquals(10, results.size());
}
diff --git a/tests/com/gitblit/tests/MetricUtilsTest.java b/tests/com/gitblit/tests/MetricUtilsTest.java index 71bf2ed7..43d02ebe 100644 --- a/tests/com/gitblit/tests/MetricUtilsTest.java +++ b/tests/com/gitblit/tests/MetricUtilsTest.java @@ -31,7 +31,7 @@ public class MetricUtilsTest { @Test
public void testMetrics() throws Exception {
testMetrics(GitBlitSuite.getHelloworldRepository());
- testMetrics(GitBlitSuite.getBluezGnomeRepository());
+ testMetrics(GitBlitSuite.getJGitRepository());
}
private void testMetrics(Repository repository) throws Exception {
|