From b46331ab9c7a7ec37517d1a328c15eb81962348c Mon Sep 17 00:00:00 2001 From: Mark Rogers Date: Wed, 23 Jul 2014 15:53:37 +0000 Subject: [PATCH] Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud) 77140: Merged PLATFORM1 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 73711: Reverse Merge << Unit tests failed >> 73642: Merged DEV to PLATFORM1(4.3.0) ACE-1996: Cluster: Web client extensions not distributed: 72232: MNT-9882: Cluster: Web client extensions not distributed - Use asynchronously refreshed cache in diactionaryDAO 73275: MNT-9882: Cluster: Web client extensions not distributed - Add javadocs, remove excess classes. 73509: MNT-9882: Cluster: Web client extensions not distributed - Remove stale configs for "compiledModelsSharedCache", remove unreachable code from DictionaryDAOImpl, return value from NoOpCompiledModelsCache.get() method. 73591: ACE-1996: Cluster: Web client extensions not distributed - Remove NoOpCompiledModelsCache. - Modify unit tests that uses CompiledModelCache git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@77996 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/cache-context.xml | 4 +-- .../alfresco/repo/dictionary/TestModel.java | 23 ++++--------- .../dictionary/RepoDictionaryDAOTest.java | 33 +++++++------------ .../repo/policy/MTPolicyComponentTest.java | 21 +++--------- .../repo/policy/PolicyComponentTest.java | 20 +++-------- 5 files changed, 28 insertions(+), 73 deletions(-) diff --git a/config/alfresco/cache-context.xml b/config/alfresco/cache-context.xml index fadfc0856a..bda3775e73 100644 --- a/config/alfresco/cache-context.xml +++ b/config/alfresco/cache-context.xml @@ -378,8 +378,8 @@ - - + + diff --git a/source/java/org/alfresco/repo/dictionary/TestModel.java b/source/java/org/alfresco/repo/dictionary/TestModel.java index 40f4132697..f8c7211dc5 100644 --- a/source/java/org/alfresco/repo/dictionary/TestModel.java +++ b/source/java/org/alfresco/repo/dictionary/TestModel.java @@ -20,15 +20,13 @@ package org.alfresco.repo.dictionary; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.ThreadPoolExecutor; import org.alfresco.repo.cache.DefaultSimpleCache; import org.alfresco.repo.cache.SimpleCache; +import org.alfresco.repo.dictionary.DictionaryDAOImpl.DictionaryRegistry; import org.alfresco.repo.dictionary.NamespaceDAOImpl.NamespaceRegistry; import org.alfresco.repo.tenant.SingleTServiceImpl; import org.alfresco.repo.tenant.TenantService; -import org.alfresco.util.ThreadPoolExecutorFactoryBean; -import org.alfresco.util.cache.DefaultAsynchronouslyRefreshedCacheRegistry; /** @@ -46,9 +44,8 @@ public class TestModel * TestModel [-h] [model filename]* *

* Returns 0 for success. - * @throws Exception */ - public static void main(String[] args) throws Exception + public static void main(String[] args) { if (args != null && args.length > 0 && args[0].equals("-h")) { @@ -92,7 +89,7 @@ public class TestModel DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(namespaceDAO); dictionaryDAO.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO, tenantService); + initDictionaryCaches(dictionaryDAO); // bootstrap dao try @@ -119,23 +116,15 @@ public class TestModel } } - private static void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception + private static void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO) { - CompiledModelsCache compiledModelsCache = new CompiledModelsCache(); - compiledModelsCache.setDictionaryDAO(dictionaryDAO); - compiledModelsCache.setTenantService(tenantService); - compiledModelsCache.setRegistry(new DefaultAsynchronouslyRefreshedCacheRegistry()); - ThreadPoolExecutorFactoryBean threadPoolfactory = new ThreadPoolExecutorFactoryBean(); - threadPoolfactory.afterPropertiesSet(); - compiledModelsCache.setThreadPoolExecutor((ThreadPoolExecutor) threadPoolfactory.getObject()); - dictionaryDAO.setDictionaryRegistryCache(compiledModelsCache); - dictionaryDAO.init(); + SimpleCache dictionaryCache = new DefaultSimpleCache(); + dictionaryDAO.setDictionaryRegistryCache(dictionaryCache); } private static void initNamespaceCaches(NamespaceDAOImpl namespaceDAO) { SimpleCache namespaceCache = new DefaultSimpleCache(); namespaceDAO.setNamespaceRegistryCache(namespaceCache); - namespaceDAO.init(); } } \ No newline at end of file diff --git a/source/test-java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java b/source/test-java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java index 68c8583c78..9c52b32187 100644 --- a/source/test-java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java +++ b/source/test-java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java @@ -26,13 +26,14 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.concurrent.ThreadPoolExecutor; import junit.framework.TestCase; import org.alfresco.model.ContentModel; import org.alfresco.repo.cache.DefaultSimpleCache; +import org.alfresco.repo.cache.NullCache; import org.alfresco.repo.cache.SimpleCache; +import org.alfresco.repo.dictionary.DictionaryDAOImpl.DictionaryRegistry; import org.alfresco.repo.dictionary.NamespaceDAOImpl.NamespaceRegistry; import org.alfresco.repo.dictionary.constraint.AbstractConstraint; import org.alfresco.repo.dictionary.constraint.ConstraintRegistry; @@ -56,8 +57,6 @@ import org.alfresco.service.cmr.dictionary.PropertyDefinition; import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; -import org.alfresco.util.ThreadPoolExecutorFactoryBean; -import org.alfresco.util.cache.DefaultAsynchronouslyRefreshedCacheRegistry; import org.springframework.extensions.surf.util.I18NUtil; @@ -72,7 +71,7 @@ public class RepoDictionaryDAOTest extends TestCase @Override - public void setUp() throws Exception + public void setUp() { // Registered the required constraints ConstraintRegistry constraintRegistry = ConstraintRegistry.getInstance(); @@ -96,7 +95,7 @@ public class RepoDictionaryDAOTest extends TestCase DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(namespaceDAO); dictionaryDAO.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO, tenantService); + initDictionaryCaches(dictionaryDAO); // Populate with appropriate models DictionaryBootstrap bootstrap = new DictionaryBootstrap(); @@ -117,28 +116,20 @@ public class RepoDictionaryDAOTest extends TestCase service = component; } - private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception + private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO) { - CompiledModelsCache compiledModelsCache = new CompiledModelsCache(); - compiledModelsCache.setDictionaryDAO(dictionaryDAO); - compiledModelsCache.setTenantService(tenantService); - compiledModelsCache.setRegistry(new DefaultAsynchronouslyRefreshedCacheRegistry()); - ThreadPoolExecutorFactoryBean threadPoolfactory = new ThreadPoolExecutorFactoryBean(); - threadPoolfactory.afterPropertiesSet(); - compiledModelsCache.setThreadPoolExecutor((ThreadPoolExecutor) threadPoolfactory.getObject()); - dictionaryDAO.setDictionaryRegistryCache(compiledModelsCache); - dictionaryDAO.init(); + SimpleCache dictionaryCache = new DefaultSimpleCache(11, getClass().getName() + ".dictionary"); + dictionaryDAO.setDictionaryRegistryCache(dictionaryCache); } private void initNamespaceCaches(NamespaceDAOImpl namespaceDAO) { SimpleCache namespaceCache = new DefaultSimpleCache(11, getClass().getName() + ".namespace"); namespaceDAO.setNamespaceRegistryCache(namespaceCache); - namespaceDAO.init(); } - public void testBootstrap() throws Exception + public void testBootstrap() { TenantService tenantService = new SingleTServiceImpl(); NamespaceDAOImpl namespaceDAO = new NamespaceDAOImpl(); @@ -147,7 +138,7 @@ public class RepoDictionaryDAOTest extends TestCase DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(namespaceDAO); dictionaryDAO.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO, tenantService); + initDictionaryCaches(dictionaryDAO); DictionaryBootstrap bootstrap = new DictionaryBootstrap(); List bootstrapModels = new ArrayList(); @@ -424,7 +415,7 @@ public class RepoDictionaryDAOTest extends TestCase assertTrue("Expected 'true' for timestamp propagation", childAssocDef.getPropagateTimestamps()); } - public void testADB159() throws Exception + public void testADB159() throws UnsupportedEncodingException { // source dictionary TenantService tenantService = new SingleTServiceImpl(); @@ -433,7 +424,7 @@ public class RepoDictionaryDAOTest extends TestCase initNamespaceCaches(namespaceDAO); DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(namespaceDAO); dictionaryDAO.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO, tenantService); + initDictionaryCaches(dictionaryDAO); // destination dictionary NamespaceDAOImpl namespaceDAO2 = new NamespaceDAOImpl(); @@ -441,7 +432,7 @@ public class RepoDictionaryDAOTest extends TestCase initNamespaceCaches(namespaceDAO2); DictionaryDAOImpl dictionaryDAO2 = new DictionaryDAOImpl(namespaceDAO2); dictionaryDAO2.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO2, tenantService); + initDictionaryCaches(dictionaryDAO2); List models = new ArrayList(); models.add("alfresco/model/dictionaryModel.xml"); diff --git a/source/test-java/org/alfresco/repo/policy/MTPolicyComponentTest.java b/source/test-java/org/alfresco/repo/policy/MTPolicyComponentTest.java index 05e2bf91a1..467fa4ae93 100644 --- a/source/test-java/org/alfresco/repo/policy/MTPolicyComponentTest.java +++ b/source/test-java/org/alfresco/repo/policy/MTPolicyComponentTest.java @@ -23,12 +23,10 @@ import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Map; -import java.util.concurrent.ThreadPoolExecutor; import junit.framework.TestCase; import org.alfresco.repo.cache.NullCache; -import org.alfresco.repo.dictionary.CompiledModelsCache; import org.alfresco.repo.dictionary.CompiledModel; import org.alfresco.repo.dictionary.DictionaryBootstrap; import org.alfresco.repo.dictionary.DictionaryComponent; @@ -40,9 +38,6 @@ import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.namespace.QName; -import org.alfresco.util.ThreadPoolExecutorFactoryBean; -import org.alfresco.util.cache.DefaultAsynchronouslyRefreshedCacheRegistry; - import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; @@ -93,7 +88,7 @@ public class MTPolicyComponentTest extends TestCase initNamespaceCaches(namespaceDAO); DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(namespaceDAO); dictionaryDAO.setTenantService(mockTenantService); - initDictionaryCaches(dictionaryDAO, mockTenantService); + initDictionaryCaches(dictionaryDAO); DictionaryBootstrap bootstrap = new DictionaryBootstrap(); List bootstrapModels = new ArrayList(); @@ -115,17 +110,10 @@ public class MTPolicyComponentTest extends TestCase } @SuppressWarnings("unchecked") - private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception + private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO) { - CompiledModelsCache compiledModelsCache = new CompiledModelsCache(); - compiledModelsCache.setDictionaryDAO(dictionaryDAO); - compiledModelsCache.setTenantService(tenantService); - compiledModelsCache.setRegistry(new DefaultAsynchronouslyRefreshedCacheRegistry()); - ThreadPoolExecutorFactoryBean threadPoolfactory = new ThreadPoolExecutorFactoryBean(); - threadPoolfactory.afterPropertiesSet(); - compiledModelsCache.setThreadPoolExecutor((ThreadPoolExecutor) threadPoolfactory.getObject()); - dictionaryDAO.setDictionaryRegistryCache(compiledModelsCache); - dictionaryDAO.init(); + // note: unit tested here with null cache + dictionaryDAO.setDictionaryRegistryCache(new NullCache()); } @SuppressWarnings("unchecked") @@ -133,7 +121,6 @@ public class MTPolicyComponentTest extends TestCase { // note: unit tested here with null cache namespaceDAO.setNamespaceRegistryCache(new NullCache()); - namespaceDAO.init(); } public void testJavaBehaviour() diff --git a/source/test-java/org/alfresco/repo/policy/PolicyComponentTest.java b/source/test-java/org/alfresco/repo/policy/PolicyComponentTest.java index 6fd6c24e16..3ecaf01825 100644 --- a/source/test-java/org/alfresco/repo/policy/PolicyComponentTest.java +++ b/source/test-java/org/alfresco/repo/policy/PolicyComponentTest.java @@ -21,12 +21,10 @@ package org.alfresco.repo.policy; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.concurrent.ThreadPoolExecutor; import junit.framework.TestCase; import org.alfresco.repo.cache.NullCache; -import org.alfresco.repo.dictionary.CompiledModelsCache; import org.alfresco.repo.dictionary.DictionaryBootstrap; import org.alfresco.repo.dictionary.DictionaryComponent; import org.alfresco.repo.dictionary.DictionaryDAOImpl; @@ -34,8 +32,6 @@ import org.alfresco.repo.dictionary.NamespaceDAOImpl; import org.alfresco.repo.tenant.SingleTServiceImpl; import org.alfresco.repo.tenant.TenantService; import org.alfresco.service.namespace.QName; -import org.alfresco.util.ThreadPoolExecutorFactoryBean; -import org.alfresco.util.cache.DefaultAsynchronouslyRefreshedCacheRegistry; public class PolicyComponentTest extends TestCase @@ -66,7 +62,7 @@ public class PolicyComponentTest extends TestCase initNamespaceCaches(namespaceDAO); DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(namespaceDAO); dictionaryDAO.setTenantService(tenantService); - initDictionaryCaches(dictionaryDAO, tenantService); + initDictionaryCaches(dictionaryDAO); DictionaryBootstrap bootstrap = new DictionaryBootstrap(); List bootstrapModels = new ArrayList(); @@ -86,17 +82,10 @@ public class PolicyComponentTest extends TestCase } @SuppressWarnings("unchecked") - private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception + private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO) { - CompiledModelsCache compiledModelsCache = new CompiledModelsCache(); - compiledModelsCache.setDictionaryDAO(dictionaryDAO); - compiledModelsCache.setTenantService(tenantService); - compiledModelsCache.setRegistry(new DefaultAsynchronouslyRefreshedCacheRegistry()); - ThreadPoolExecutorFactoryBean threadPoolfactory = new ThreadPoolExecutorFactoryBean(); - threadPoolfactory.afterPropertiesSet(); - compiledModelsCache.setThreadPoolExecutor((ThreadPoolExecutor) threadPoolfactory.getObject()); - dictionaryDAO.setDictionaryRegistryCache(compiledModelsCache); - dictionaryDAO.init(); + // note: unit tested here with null cache + dictionaryDAO.setDictionaryRegistryCache(new NullCache()); } @SuppressWarnings("unchecked") @@ -104,7 +93,6 @@ public class PolicyComponentTest extends TestCase { // note: unit tested here with null cache namespaceDAO.setNamespaceRegistryCache(new NullCache()); - namespaceDAO.init(); } public void testJavaBehaviour()