]> source.dussan.org Git - gitblit.git/commitdiff
Revised unit tests. Swapped BlueZGnome repo (unacessible) for Gitective.
authorJames Moger <james.moger@gitblit.com>
Tue, 21 Feb 2012 13:00:27 +0000 (08:00 -0500)
committerJames Moger <james.moger@gitblit.com>
Tue, 21 Feb 2012 13:00:27 +0000 (08:00 -0500)
test-gitblit.properties
tests/com/gitblit/tests/GitBlitSuite.java
tests/com/gitblit/tests/IssuesTest.java
tests/com/gitblit/tests/JGitUtilsTest.java
tests/com/gitblit/tests/LuceneUtilsTest.java
tests/com/gitblit/tests/MetricUtilsTest.java

index 9249bbd0a2a0ebf65a47bfd345a565f56a8deccc..6997dde72fa39e4c51ef7205b9be0574fe865e37 100644 (file)
@@ -69,13 +69,13 @@ federation.allowProposals = false
 federation.proposalsFolder = proposals
 federation.defaultFrequency = 60 mins
 federation.sets = animal mineral vegetable
-federation.example1.url = https://go.gitblit.com
-federation.example1.token = 6f3b8a24bf970f17289b234284c94f43eb42f0e4
-federation.example1.frequency = 120 mins
-federation.example1.folder =
-federation.example1.bare = true 
-federation.example1.mirror = true 
-federation.example1.mergeAccounts = true
+#federation.example1.url = https://go.gitblit.com
+#federation.example1.token = 6f3b8a24bf970f17289b234284c94f43eb42f0e4
+#federation.example1.frequency = 120 mins
+#federation.example1.folder =
+#federation.example1.bare = true 
+#federation.example1.mirror = true 
+#federation.example1.mergeAccounts = true
 
 server.tempFolder = temp
 server.useNio = true
index 8fac212cd6a4dc853fed885fab872936b837a4d2..210a7dac0e3cd226e565a9d6570b183d3617d806 100644 (file)
@@ -78,10 +78,6 @@ public class GitBlitSuite {
                return new FileRepository(new File(REPOSITORIES, "test/jgit.git"));\r
        }\r
 \r
-       public static Repository getBluezGnomeRepository() throws Exception {\r
-               return new FileRepository(new File(REPOSITORIES, "test/bluez-gnome.git"));\r
-       }\r
-\r
        public static Repository getAmbitionRepository() throws Exception {\r
                return new FileRepository(new File(REPOSITORIES, "test/ambition.git"));\r
        }\r
@@ -93,6 +89,10 @@ public class GitBlitSuite {
        public static Repository getIssuesTestRepository() throws Exception {\r
                return new FileRepository(new File(REPOSITORIES, "gb-issues.git"));\r
        }\r
+       \r
+       public static Repository getGitectiveRepository() throws Exception {\r
+               return new FileRepository(new File("test/gitective.git"));\r
+       }\r
 \r
        public static boolean startGitblit() throws Exception {\r
                if (started.get()) {\r
@@ -137,6 +137,7 @@ public class GitBlitSuite {
                        cloneOrFetch("test/helloworld.git", "https://github.com/git/hello-world.git");\r
                        cloneOrFetch("test/ambition.git", "https://github.com/defunkt/ambition.git");\r
                        cloneOrFetch("test/theoretical-physics.git", "https://github.com/certik/theoretical-physics.git");\r
+                       cloneOrFetch("test/gitective.git", "https://github.com/kevinsawicki/gitective.git");\r
                        \r
                        JGitUtils.createRepository(REPOSITORIES, "gb-issues.git").close();\r
 \r
index a5d487d80f97fe8ea6869e8f4b33fd208b4bd4c0..1224a040027a996efc42817152f48b6f1a90fd8f 100644 (file)
@@ -46,9 +46,10 @@ import com.gitblit.utils.LuceneUtils;
 public class IssuesTest {\r
 \r
        @Test\r
-       public void testCreation() throws Exception {\r
+       public void testLifecycle() throws Exception {\r
                Repository repository = GitBlitSuite.getIssuesTestRepository();\r
-               // create and insert the issue\r
+               \r
+               // create and insert an issue\r
                Change c1 = newChange("testCreation() " + Long.toHexString(System.currentTimeMillis()));\r
                IssueModel issue = IssueUtils.createIssue(repository, c1);\r
                assertNotNull(issue.id);\r
@@ -58,18 +59,15 @@ public class IssuesTest {
                compare(issue, constructed);\r
 \r
                assertEquals(1, constructed.changes.size());\r
-       }\r
-\r
-       @Test\r
-       public void testUpdates() throws Exception {\r
-               Repository repository = GitBlitSuite.getIssuesTestRepository();\r
+               \r
                // C1: create the issue\r
-               Change c1 = newChange("testUpdates() " + Long.toHexString(System.currentTimeMillis()));\r
-               IssueModel issue = IssueUtils.createIssue(repository, c1);\r
+               c1 = newChange("testUpdates() " + Long.toHexString(System.currentTimeMillis()));\r
+               issue = IssueUtils.createIssue(repository, c1);\r
                assertNotNull(issue.id);\r
 \r
-               IssueModel constructed = IssueUtils.getIssue(repository, issue.id);\r
+               constructed = IssueUtils.getIssue(repository, issue.id);\r
                compare(issue, constructed);\r
+               assertEquals(1, constructed.changes.size());\r
 \r
                // C2: set owner\r
                Change c2 = new Change("C2");\r
@@ -109,21 +107,13 @@ public class IssuesTest {
                assertEquals(5, constructed.changes.size());\r
                assertTrue(constructed.status.isClosed());\r
 \r
-               repository.close();\r
-       }\r
-\r
-       @Test\r
-       public void testQuery() throws Exception {\r
-               Repository repository = GitBlitSuite.getIssuesTestRepository();\r
                List<IssueModel> allIssues = IssueUtils.getIssues(repository, null);\r
-\r
                List<IssueModel> openIssues = IssueUtils.getIssues(repository, new IssueFilter() {\r
                        @Override\r
                        public boolean accept(IssueModel issue) {\r
                                return !issue.status.isClosed();\r
                        }\r
                });\r
-\r
                List<IssueModel> closedIssues = IssueUtils.getIssues(repository, new IssueFilter() {\r
                        @Override\r
                        public boolean accept(IssueModel issue) {\r
@@ -131,57 +121,35 @@ public class IssuesTest {
                        }\r
                });\r
 \r
-               repository.close();\r
                assertTrue(allIssues.size() > 0);\r
                assertEquals(1, openIssues.size());\r
                assertEquals(1, closedIssues.size());\r
-       }\r
-\r
-       @Test\r
-       public void testLuceneIndexAndQuery() throws Exception {                \r
-               Repository repository = GitBlitSuite.getIssuesTestRepository();\r
+               \r
+               // build a new Lucene index\r
                LuceneUtils.deleteIndex(repository);\r
-               List<IssueModel> allIssues = IssueUtils.getIssues(repository, null);\r
-               assertTrue(allIssues.size() > 0);\r
-               for (IssueModel issue : allIssues) {\r
-                       LuceneUtils.index(repository, issue, false);\r
+               for (IssueModel anIssue : allIssues) {\r
+                       LuceneUtils.index(repository, anIssue, false);\r
                }\r
                List<SearchResult> hits = LuceneUtils.search("working", 10, repository);\r
                assertTrue(hits.size() > 0);\r
                \r
                // reindex an issue\r
-               IssueModel issue = allIssues.get(0);\r
+               issue = allIssues.get(0);\r
                Change change = new Change("reindex");\r
                change.comment("this is a test of reindexing an issue");\r
                IssueUtils.updateIssue(repository, issue.id, change);\r
                issue = IssueUtils.getIssue(repository, issue.id);\r
                LuceneUtils.index(repository, issue, true);\r
-               \r
-               LuceneUtils.close();\r
-               repository.close();\r
-       }\r
-       \r
-       @Test\r
-       public void testLuceneQuery() throws Exception {\r
-               Repository repository = GitBlitSuite.getIssuesTestRepository();\r
-               List<SearchResult> hits = LuceneUtils.search("working", 10, repository);\r
-               LuceneUtils.close();\r
-               repository.close();\r
-               assertTrue(hits.size() > 0);\r
-       }\r
-\r
 \r
-       @Test\r
-       public void testDelete() throws Exception {\r
-               Repository repository = GitBlitSuite.getIssuesTestRepository();\r
-               List<IssueModel> allIssues = IssueUtils.getIssues(repository, null);\r
                // delete all issues\r
-               for (IssueModel issue : allIssues) {\r
-                       assertTrue(IssueUtils.deleteIssue(repository, issue.id, "D"));\r
+               for (IssueModel anIssue : allIssues) {\r
+                       assertTrue(IssueUtils.deleteIssue(repository, anIssue.id, "D"));\r
                }\r
+                               \r
+               LuceneUtils.close();\r
                repository.close();\r
        }\r
-\r
+       \r
        @Test\r
        public void testChangeComment() throws Exception {\r
                Repository repository = GitBlitSuite.getIssuesTestRepository();\r
index d365bdea7fd83961309095725c9ee9e0d0c0e1d0..e649769e015fdfa283643a393f12db764f01ed10 100644 (file)
@@ -190,12 +190,12 @@ public class JGitUtilsTest {
                }\r
                repository.close();\r
 \r
-               repository = GitBlitSuite.getBluezGnomeRepository();\r
+               repository = GitBlitSuite.getGitectiveRepository();\r
                for (RefModel model : JGitUtils.getTags(repository, true, -1)) {\r
-                       if (model.getObjectId().getName().equals("728643ec0c438c77e182898c2f2967dbfdc231c8")) {\r
+                       if (model.getObjectId().getName().equals("035254295a9bba11f72b1f9d6791a6b957abee7b")) {\r
                                assertFalse(model.isAnnotatedTag());\r
-                               assertTrue(model.getAuthorIdent().getEmailAddress().equals("marcel@holtmann.org"));\r
-                               assertEquals("Update changelog and bump version number\n", model.getFullMessage());\r
+                               assertTrue(model.getAuthorIdent().getEmailAddress().equals("kevinsawicki@gmail.com"));\r
+                               assertEquals("Add scm and issue tracker elements to pom.xml\n", model.getFullMessage());\r
                        }\r
                }\r
                repository.close();\r
index a54462182977e75e7b8205d86a5a8680fc224b61..7075695340128b3ff22bfe727f0a294e5a7e8bf0 100644 (file)
@@ -45,8 +45,8 @@ public class LuceneUtilsTest {
                LuceneUtils.index(repository);\r
                repository.close();\r
 \r
-               // reindex bluez-gnome\r
-               repository = GitBlitSuite.getBluezGnomeRepository();\r
+               // reindex JGit\r
+               repository = GitBlitSuite.getJGitRepository();\r
                LuceneUtils.index(repository);\r
                repository.close();\r
 \r
@@ -59,6 +59,9 @@ public class LuceneUtilsTest {
                Repository repository = GitBlitSuite.getHelloworldRepository();\r
                List<SearchResult> results = LuceneUtils.search("ada", 10, repository);\r
                assertEquals(2, results.size());\r
+               for (SearchResult res : results) {\r
+                       assertEquals("refs/heads/master", res.branch);\r
+               }\r
 \r
                // author test\r
                results = LuceneUtils.search("author: tinogomes", 10, repository);\r
@@ -76,6 +79,7 @@ public class LuceneUtilsTest {
                assertEquals(1, results.size());\r
                assertEquals("Ondrej Certik", results.get(0).author);\r
                assertEquals("2648c0c98f2101180715b4d432fc58d0e21a51d7", results.get(0).id);\r
+               assertEquals("refs/heads/gh-pages", results.get(0).branch);\r
                \r
                // tag test\r
                results = LuceneUtils.search("\"qft split\"", 10, repository);\r
@@ -97,10 +101,10 @@ public class LuceneUtilsTest {
                repository.close();\r
                \r
                // annotated tag test\r
-               repository = GitBlitSuite.getBluezGnomeRepository();\r
-               results = LuceneUtils.search("\"release 1.8\"", 10, repository);\r
+               repository = GitBlitSuite.getJGitRepository();\r
+               results = LuceneUtils.search("I663208919f297836a9c16bf458e4a43ffaca4c12", 10, repository);\r
                assertEquals(1, results.size());\r
-               assertEquals("[1.8]", results.get(0).labels.toString());\r
+               assertEquals("[v1.3.0.201202151440-r]", results.get(0).labels.toString());\r
 \r
                repository.close();\r
                \r
@@ -111,7 +115,7 @@ public class LuceneUtilsTest {
        public void testMultiSearch() throws Exception {\r
                List<SearchResult> results = LuceneUtils.search("test", 10,\r
                                GitBlitSuite.getHelloworldRepository(), \r
-                               GitBlitSuite.getBluezGnomeRepository());\r
+                               GitBlitSuite.getJGitRepository());\r
                LuceneUtils.close();\r
                assertEquals(10, results.size());\r
        }\r
index 71bf2ed7c6d61c4f0dfbca34b9c9190cc2d272f5..43d02ebea39ed1d0680229c1da42012c69cb66a5 100644 (file)
@@ -31,7 +31,7 @@ public class MetricUtilsTest {
        @Test\r
        public void testMetrics() throws Exception {\r
                testMetrics(GitBlitSuite.getHelloworldRepository());\r
-               testMetrics(GitBlitSuite.getBluezGnomeRepository());\r
+               testMetrics(GitBlitSuite.getJGitRepository());\r
        }\r
 \r
        private void testMetrics(Repository repository) throws Exception {\r