From 874be0d933eb52d548a07b67d112a0975e900b14 Mon Sep 17 00:00:00 2001 From: James Moger Date: Wed, 1 Aug 2012 09:47:30 -0400 Subject: [PATCH] Fixed Lucene unit tests --- tests/com/gitblit/tests/LdapUserServiceTest.java | 2 +- tests/com/gitblit/tests/LuceneExecutorTest.java | 9 +++++++-- tests/com/gitblit/tests/mock/MemorySettings.java | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/com/gitblit/tests/LdapUserServiceTest.java b/tests/com/gitblit/tests/LdapUserServiceTest.java index 390fa001..ffe82640 100644 --- a/tests/com/gitblit/tests/LdapUserServiceTest.java +++ b/tests/com/gitblit/tests/LdapUserServiceTest.java @@ -68,7 +68,7 @@ public class LdapUserServiceTest { } private MemorySettings getSettings() { - Map backingMap = new HashMap(); + Map backingMap = new HashMap(); backingMap.put("realm.ldap.server", "ldap://localhost:" + ldapPort); backingMap.put("realm.ldap.domain", ""); backingMap.put("realm.ldap.username", "cn=Directory Manager"); diff --git a/tests/com/gitblit/tests/LuceneExecutorTest.java b/tests/com/gitblit/tests/LuceneExecutorTest.java index 21454fe4..6b45b9fe 100644 --- a/tests/com/gitblit/tests/LuceneExecutorTest.java +++ b/tests/com/gitblit/tests/LuceneExecutorTest.java @@ -20,7 +20,9 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.eclipse.jgit.lib.Repository; import org.junit.Test; @@ -29,6 +31,7 @@ import com.gitblit.LuceneExecutor; import com.gitblit.models.RefModel; import com.gitblit.models.RepositoryModel; import com.gitblit.models.SearchResult; +import com.gitblit.tests.mock.MemorySettings; import com.gitblit.utils.FileUtils; import com.gitblit.utils.JGitUtils; @@ -41,7 +44,9 @@ import com.gitblit.utils.JGitUtils; public class LuceneExecutorTest { private LuceneExecutor newLuceneExecutor() { - return new LuceneExecutor(null, GitBlitSuite.REPOSITORIES); + Map map = new HashMap(); + MemorySettings settings = new MemorySettings(map); + return new LuceneExecutor(settings, GitBlitSuite.REPOSITORIES); } private RepositoryModel newRepositoryModel(Repository repository) { @@ -164,7 +169,7 @@ public class LuceneExecutorTest { @Test public void testDeleteBlobFromIndex() throws Exception { // start with a fresh reindex of entire repository - LuceneExecutor lucene = new LuceneExecutor(null, GitBlitSuite.REPOSITORIES); + LuceneExecutor lucene = newLuceneExecutor(); Repository repository = GitBlitSuite.getHelloworldRepository(); RepositoryModel model = newRepositoryModel(repository); lucene.reindex(model, repository); diff --git a/tests/com/gitblit/tests/mock/MemorySettings.java b/tests/com/gitblit/tests/mock/MemorySettings.java index 8b559354..1b3e2382 100644 --- a/tests/com/gitblit/tests/mock/MemorySettings.java +++ b/tests/com/gitblit/tests/mock/MemorySettings.java @@ -23,9 +23,9 @@ import com.gitblit.IStoredSettings; public class MemorySettings extends IStoredSettings { - private Map backingMap; + private Map backingMap; - public MemorySettings(Map backingMap) { + public MemorySettings(Map backingMap) { super(MemorySettings.class); this.backingMap = backingMap; } @@ -39,7 +39,7 @@ public class MemorySettings extends IStoredSettings { } public void put(Object key, Object value) { - backingMap.put(key, value); + backingMap.put(key.toString(), value); } @Override -- 2.39.5