From 27ae9095639bb228a1b7ff86a3ebe4264abf05be Mon Sep 17 00:00:00 2001
From: mschaefers <mschaefers@scoop-gmbh.de>
Date: Thu, 29 Nov 2012 12:33:09 -0500
Subject: [PATCH] feature: when using LdapUserService one can configure Gitblit to fetch all users from ldap that can possibly login. This allows to see newly generated LDAP users instantly in Gitblit. By now an LDAP user had to log in once to appear in GitBlit.
---
tests/com/gitblit/tests/TicgitUtilsTest.java | 45 +++++++++++++++++++++++++++++++++++++++------
1 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/tests/com/gitblit/tests/TicgitUtilsTest.java b/tests/com/gitblit/tests/TicgitUtilsTest.java
index 25dba2c..74f9e44 100644
--- a/tests/com/gitblit/tests/TicgitUtilsTest.java
+++ b/tests/com/gitblit/tests/TicgitUtilsTest.java
@@ -15,23 +15,40 @@
*/
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 {
- public void testTicGit() throws Exception {
+ @Test
+ public void testTicgitBranch() throws Exception {
Repository repository = GitBlitSuite.getTicgitRepository();
RefModel branch = TicgitUtils.getTicketsBranch(repository);
- assertTrue("Ticgit branch does not exist!", branch != null);
+ repository.close();
+ assertNotNull("Ticgit branch does not exist!", branch);
+
+ repository = GitBlitSuite.getHelloworldRepository();
+ branch = TicgitUtils.getTicketsBranch(repository);
+ repository.close();
+ assertNull("Ticgit branch exists!", branch);
+ }
+
+ @Test
+ public void testRetrieveTickets() throws Exception {
+ Repository repository = GitBlitSuite.getTicgitRepository();
List<TicketModel> ticketsA = TicgitUtils.getTickets(repository);
List<TicketModel> ticketsB = TicgitUtils.getTickets(repository);
repository.close();
@@ -47,8 +64,24 @@
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();
+ 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();
+ assertNotNull(ticket);
+ assertEquals("1206206148_add-attachment-to-ticket_138", ticket.name);
}
}
\ No newline at end of file
--
Gitblit v1.9.1