From 4550f97fc9cb76f77d8ed5601a33ffbeeff7fd43 Mon Sep 17 00:00:00 2001 From: Dave Ward Date: Tue, 2 Oct 2012 03:35:09 +0000 Subject: [PATCH] Fix NPEs in unit tests - The next problem will be that WQS doesn't compile anymore! git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@42245 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/repo/cache/DefaultSimpleCache.java | 17 ++++++++++++++++- .../repo/content/RoutingContentStoreTest.java | 2 +- .../repo/dictionary/RepoDictionaryDAOTest.java | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/source/java/org/alfresco/repo/cache/DefaultSimpleCache.java b/source/java/org/alfresco/repo/cache/DefaultSimpleCache.java index 68434810ac..37349a238c 100644 --- a/source/java/org/alfresco/repo/cache/DefaultSimpleCache.java +++ b/source/java/org/alfresco/repo/cache/DefaultSimpleCache.java @@ -20,6 +20,7 @@ package org.alfresco.repo.cache; import java.io.Serializable; import java.util.AbstractMap; +import java.util.AbstractMap.SimpleImmutableEntry; import java.util.Collection; import java.util.LinkedHashMap; import java.util.Map; @@ -50,6 +51,20 @@ public final class DefaultSimpleCache { } + /** + * Constructor for programmatic use. + * @param maxItems + * @param cacheName + */ + public DefaultSimpleCache(int maxItems, String cacheName) + { + setMaxItems(maxItems); + setBeanName(cacheName); + afterPropertiesSet(); + } + + + @Override public boolean contains(K key) { @@ -128,7 +143,7 @@ public final class DefaultSimpleCache * @throws Exception */ @Override - public synchronized void afterPropertiesSet() throws Exception + public synchronized void afterPropertiesSet() { if (maxItems < 1) { diff --git a/source/java/org/alfresco/repo/content/RoutingContentStoreTest.java b/source/java/org/alfresco/repo/content/RoutingContentStoreTest.java index 4bf5444845..816141d2af 100644 --- a/source/java/org/alfresco/repo/content/RoutingContentStoreTest.java +++ b/source/java/org/alfresco/repo/content/RoutingContentStoreTest.java @@ -156,7 +156,7 @@ public class RoutingContentStoreTest extends AbstractWritableContentStoreTest { this.stores.add(store); } - SimpleCache, ContentStore> cache = new DefaultSimpleCache, ContentStore>(); + SimpleCache, ContentStore> cache = new DefaultSimpleCache, ContentStore>(11, getClass().getName()); super.setStoresCache(cache); } diff --git a/source/java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java b/source/java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java index c8590c58d8..ca85c81f54 100644 --- a/source/java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java +++ b/source/java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java @@ -116,7 +116,7 @@ public class RepoDictionaryDAOTest extends TestCase private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO) { - SimpleCache dictionaryCache = new DefaultSimpleCache(); + SimpleCache dictionaryCache = new DefaultSimpleCache(11, getClass().getName()); dictionaryDAO.setDictionaryRegistryCache(dictionaryCache); }