diff options
author | James Moger <james.moger@gitblit.com> | 2011-06-01 21:01:51 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2011-06-01 21:01:51 -0400 |
commit | 793f76563d4bb3f58fa62ff53985e20561c6e330 (patch) | |
tree | 15ce25c40c0a4198f1a47f890250430ed9b6e941 /tests | |
parent | a3bde69e9b3f3cc6212b0cd5fd7310b6a3301d8c (diff) | |
download | gitblit-793f76563d4bb3f58fa62ff53985e20561c6e330.tar.gz gitblit-793f76563d4bb3f58fa62ff53985e20561c6e330.zip |
Refactored some unit tests and utils.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/com/gitblit/tests/GitBlitSuite.java | 2 | ||||
-rw-r--r-- | tests/com/gitblit/tests/JGitUtilsTest.java | 35 | ||||
-rw-r--r-- | tests/com/gitblit/tests/MetricUtilsTest.java | 35 | ||||
-rw-r--r-- | tests/com/gitblit/tests/TicgitUtilsTest.java | 54 |
4 files changed, 91 insertions, 35 deletions
diff --git a/tests/com/gitblit/tests/GitBlitSuite.java b/tests/com/gitblit/tests/GitBlitSuite.java index d9963646..fcb57239 100644 --- a/tests/com/gitblit/tests/GitBlitSuite.java +++ b/tests/com/gitblit/tests/GitBlitSuite.java @@ -44,6 +44,8 @@ public class GitBlitSuite extends TestSetup { suite.addTestSuite(ByteFormatTest.class);
suite.addTestSuite(JGitUtilsTest.class);
suite.addTestSuite(DiffUtilsTest.class);
+ suite.addTestSuite(MetricUtilsTest.class);
+ suite.addTestSuite(TicgitUtilsTest.class);
suite.addTestSuite(GitBlitTest.class);
return new GitBlitSuite(suite);
}
diff --git a/tests/com/gitblit/tests/JGitUtilsTest.java b/tests/com/gitblit/tests/JGitUtilsTest.java index 14d318f3..f1dcaac4 100644 --- a/tests/com/gitblit/tests/JGitUtilsTest.java +++ b/tests/com/gitblit/tests/JGitUtilsTest.java @@ -30,13 +30,9 @@ import org.eclipse.jgit.revwalk.RevObject; import org.eclipse.jgit.revwalk.RevTree;
import com.gitblit.GitBlit;
-import com.gitblit.models.Metric;
import com.gitblit.models.PathModel.PathChangeModel;
import com.gitblit.models.RefModel;
-import com.gitblit.models.TicketModel;
-import com.gitblit.models.TicketModel.Comment;
import com.gitblit.utils.JGitUtils;
-import com.gitblit.utils.MetricUtils;
public class JGitUtilsTest extends TestCase {
@@ -182,35 +178,4 @@ public class JGitUtilsTest extends TestCase { zipFile.delete();
repository.close();
}
-
- public void testMetrics() throws Exception {
- Repository repository = GitBlitSuite.getHelloworldRepository();
- List<Metric> metrics = MetricUtils.getDateMetrics(repository, true);
- repository.close();
- assertTrue("No metrics found!", metrics.size() > 0);
- }
-
- public void testTicGit() throws Exception {
- Repository repository = GitBlitSuite.getTicgitRepository();
- RefModel branch = JGitUtils.getTicketsBranch(repository);
- assertTrue("Ticgit branch does not exist!", branch != null);
- List<TicketModel> ticketsA = JGitUtils.getTickets(repository);
- List<TicketModel> ticketsB = JGitUtils.getTickets(repository);
- repository.close();
- assertTrue("No tickets found!", ticketsA.size() > 0);
- for (int i = 0; i < ticketsA.size(); i++) {
- TicketModel ticketA = ticketsA.get(i);
- TicketModel ticketB = ticketsB.get(i);
- assertTrue("Tickets are not equal!", ticketA.equals(ticketB));
- assertFalse(ticketA.equals(""));
- assertTrue(ticketA.hashCode() == ticketA.id.hashCode());
- for (int j = 0; j < ticketA.comments.size(); j++) {
- Comment commentA = ticketA.comments.get(j);
- Comment commentB = ticketB.comments.get(j);
- assertTrue("Comments are not equal!", commentA.equals(commentB));
- assertFalse(commentA.equals(""));
- assertTrue(commentA.hashCode() == commentA.text.hashCode());
- }
- }
- }
}
\ No newline at end of file diff --git a/tests/com/gitblit/tests/MetricUtilsTest.java b/tests/com/gitblit/tests/MetricUtilsTest.java new file mode 100644 index 00000000..77f43a16 --- /dev/null +++ b/tests/com/gitblit/tests/MetricUtilsTest.java @@ -0,0 +1,35 @@ +/*
+ * Copyright 2011 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gitblit.tests;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jgit.lib.Repository;
+
+import com.gitblit.models.Metric;
+import com.gitblit.utils.MetricUtils;
+
+public class MetricUtilsTest extends TestCase {
+
+ public void testMetrics() throws Exception {
+ Repository repository = GitBlitSuite.getHelloworldRepository();
+ List<Metric> metrics = MetricUtils.getDateMetrics(repository, true);
+ repository.close();
+ assertTrue("No metrics found!", metrics.size() > 0);
+ }
+}
\ No newline at end of file diff --git a/tests/com/gitblit/tests/TicgitUtilsTest.java b/tests/com/gitblit/tests/TicgitUtilsTest.java new file mode 100644 index 00000000..25dba2c6 --- /dev/null +++ b/tests/com/gitblit/tests/TicgitUtilsTest.java @@ -0,0 +1,54 @@ +/*
+ * Copyright 2011 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gitblit.tests;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jgit.lib.Repository;
+
+import com.gitblit.models.RefModel;
+import com.gitblit.models.TicketModel;
+import com.gitblit.models.TicketModel.Comment;
+import com.gitblit.utils.TicgitUtils;
+
+public class TicgitUtilsTest extends TestCase {
+
+ public void testTicGit() throws Exception {
+ Repository repository = GitBlitSuite.getTicgitRepository();
+ RefModel branch = TicgitUtils.getTicketsBranch(repository);
+ assertTrue("Ticgit branch does not exist!", branch != null);
+ List<TicketModel> ticketsA = TicgitUtils.getTickets(repository);
+ List<TicketModel> ticketsB = TicgitUtils.getTickets(repository);
+ repository.close();
+ assertTrue("No tickets found!", ticketsA.size() > 0);
+ for (int i = 0; i < ticketsA.size(); i++) {
+ TicketModel ticketA = ticketsA.get(i);
+ TicketModel ticketB = ticketsB.get(i);
+ assertTrue("Tickets are not equal!", ticketA.equals(ticketB));
+ assertFalse(ticketA.equals(""));
+ assertTrue(ticketA.hashCode() == ticketA.id.hashCode());
+ for (int j = 0; j < ticketA.comments.size(); j++) {
+ Comment commentA = ticketA.comments.get(j);
+ Comment commentB = ticketB.comments.get(j);
+ assertTrue("Comments are not equal!", commentA.equals(commentB));
+ assertFalse(commentA.equals(""));
+ assertTrue(commentA.hashCode() == commentA.text.hashCode());
+ }
+ }
+ }
+}
\ No newline at end of file |