From 7e8873a14ccc2cb25213489d7d7ba97f09673831 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 07 Dec 2011 19:14:34 -0500
Subject: [PATCH] Unit testing overhaul.
---
tests/com/gitblit/tests/TicgitUtilsTest.java | 29 +++++++++++++++++++----------
1 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/tests/com/gitblit/tests/TicgitUtilsTest.java b/tests/com/gitblit/tests/TicgitUtilsTest.java
index 9f5a488..a77dae4 100644
--- a/tests/com/gitblit/tests/TicgitUtilsTest.java
+++ b/tests/com/gitblit/tests/TicgitUtilsTest.java
@@ -15,31 +15,38 @@
*/
package com.gitblit.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.List;
-import junit.framework.TestCase;
-
import org.eclipse.jgit.lib.Repository;
+import org.junit.Test;
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 class TicgitUtilsTest {
+ @Test
public void testTicgitBranch() throws Exception {
Repository repository = GitBlitSuite.getTicgitRepository();
RefModel branch = TicgitUtils.getTicketsBranch(repository);
repository.close();
- assertTrue("Ticgit branch does not exist!", branch != null);
+ assertNotNull("Ticgit branch does not exist!", branch);
repository = GitBlitSuite.getHelloworldRepository();
branch = TicgitUtils.getTicketsBranch(repository);
repository.close();
- assertTrue("Ticgit branch exists!", branch == null);
+ assertNull("Ticgit branch exists!", branch);
}
+ @Test
public void testRetrieveTickets() throws Exception {
Repository repository = GitBlitSuite.getTicgitRepository();
List<TicketModel> ticketsA = TicgitUtils.getTickets(repository);
@@ -57,24 +64,26 @@
Comment commentB = ticketB.comments.get(j);
assertTrue("Comments are not equal!", commentA.equals(commentB));
assertFalse(commentA.equals(""));
- assertTrue(commentA.hashCode() == commentA.text.hashCode());
+ assertEquals(commentA.hashCode(), commentA.text.hashCode());
}
}
repository = GitBlitSuite.getHelloworldRepository();
List<TicketModel> ticketsC = TicgitUtils.getTickets(repository);
repository.close();
- assertTrue(ticketsC == null);
+ assertNull(ticketsC);
}
+ @Test
public void testReadTicket() throws Exception {
Repository repository = GitBlitSuite.getTicgitRepository();
List<TicketModel> tickets = TicgitUtils.getTickets(repository);
TicketModel ticket = TicgitUtils
.getTicket(repository, tickets.get(tickets.size() - 1).name);
repository.close();
- assertTrue(ticket != null);
- assertTrue(ticket.name
- .equals("1254123752_comments-on-ticgits-longer-than-5-lines-can-t-be-viewed-entirely_266"));
+ assertNotNull(ticket);
+ assertEquals(
+ "1254123752_comments-on-ticgits-longer-than-5-lines-can-t-be-viewed-entirely_266",
+ ticket.name);
}
}
\ No newline at end of file
--
Gitblit v1.9.1