From 0e44acbb2fec928a1606dc60f427a148fff405c9 Mon Sep 17 00:00:00 2001
From: Mohamed Ragab <moragab@gmail.com>
Date: Wed, 02 May 2012 11:15:01 -0400
Subject: [PATCH] Added a script to facilitate setting the proxy host and port and no proxy hosts, and then it concatenates all the java system properties for setting the java proxy configurations and puts the resulting string in an environment variable JAVA_PROXY_CONFIG, modified the scirpts gitblit,  gitblit-ubuntu, and gitblit-centos to source the java-proxy-config.sh script and then include the resulting java proxy configuration in the java command

---
 tests/com/gitblit/tests/IssuesTest.java |   67 ++++++++++++++++++---------------
 1 files changed, 37 insertions(+), 30 deletions(-)

diff --git a/tests/com/gitblit/tests/IssuesTest.java b/tests/com/gitblit/tests/IssuesTest.java
index 26b5995..11f9551 100644
--- a/tests/com/gitblit/tests/IssuesTest.java
+++ b/tests/com/gitblit/tests/IssuesTest.java
@@ -26,12 +26,15 @@
 import org.eclipse.jgit.lib.Repository;
 import org.junit.Test;
 
+import com.gitblit.LuceneExecutor;
 import com.gitblit.models.IssueModel;
 import com.gitblit.models.IssueModel.Attachment;
 import com.gitblit.models.IssueModel.Change;
 import com.gitblit.models.IssueModel.Field;
 import com.gitblit.models.IssueModel.Priority;
 import com.gitblit.models.IssueModel.Status;
+import com.gitblit.models.SearchResult;
+import com.gitblit.utils.FileUtils;
 import com.gitblit.utils.IssueUtils;
 import com.gitblit.utils.IssueUtils.IssueFilter;
 
@@ -44,9 +47,11 @@
 public class IssuesTest {
 
 	@Test
-	public void testCreation() throws Exception {
+	public void testLifecycle() throws Exception {
 		Repository repository = GitBlitSuite.getIssuesTestRepository();
-		// create and insert the issue
+		String name = FileUtils.getRelativePath(GitBlitSuite.REPOSITORIES, repository.getDirectory());
+		
+		// create and insert an issue
 		Change c1 = newChange("testCreation() " + Long.toHexString(System.currentTimeMillis()));
 		IssueModel issue = IssueUtils.createIssue(repository, c1);
 		assertNotNull(issue.id);
@@ -56,18 +61,15 @@
 		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");
@@ -107,45 +109,50 @@
 		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) {
 				return issue.status.isClosed();
 			}
 		});
-
-		repository.close();
+		
 		assertTrue(allIssues.size() > 0);
 		assertEquals(1, openIssues.size());
 		assertEquals(1, closedIssues.size());
-	}
-
-	@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"));
+		
+		// build a new Lucene index
+		LuceneExecutor lucene = new LuceneExecutor(null, GitBlitSuite.REPOSITORIES);
+		lucene.deleteIndex(name);
+		for (IssueModel anIssue : allIssues) {
+			lucene.index(name, anIssue);
 		}
+		List<SearchResult> hits = lucene.search("working", 1, 10, name);
+		assertTrue(hits.size() > 0);
+		
+		// reindex an issue
+		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);
+		lucene.index(name, issue);
+
+		// delete all issues
+		for (IssueModel anIssue : allIssues) {
+			assertTrue(IssueUtils.deleteIssue(repository, anIssue.id, "D"));
+		}
+				
+		lucene.close();
 		repository.close();
 	}
-
+	
 	@Test
 	public void testChangeComment() throws Exception {
 		Repository repository = GitBlitSuite.getIssuesTestRepository();

--
Gitblit v1.9.1