diff --git a/source/test-java/org/alfresco/AllUnitTestsSuite.java b/source/test-java/org/alfresco/AllUnitTestsSuite.java index 7a3d8842a9..866f306838 100644 --- a/source/test-java/org/alfresco/AllUnitTestsSuite.java +++ b/source/test-java/org/alfresco/AllUnitTestsSuite.java @@ -23,9 +23,6 @@ public class AllUnitTestsSuite extends TestSuite static void unitTests(TestSuite suite) { - suite.addTest(new JUnit4TestAdapter(org.alfresco.opencmis.AlfrescoCmisExceptionInterceptorTest.class)); - suite.addTest(new JUnit4TestAdapter(org.alfresco.opencmis.CMISDictionaryTest.class)); - suite.addTest(new JUnit4TestAdapter(org.alfresco.opencmis.CMISTest.class)); suite.addTestSuite(org.alfresco.cmis.PropertyFilterTest.class); suite.addTestSuite(org.alfresco.encryption.EncryptorTest.class); suite.addTestSuite(org.alfresco.encryption.KeyStoreKeyProviderTest.class); diff --git a/source/test-java/org/alfresco/opencmis/CMISDictionaryTest.java b/source/test-java/org/alfresco/opencmis/CMISDictionaryTest.java deleted file mode 100644 index 71a6efc99e..0000000000 --- a/source/test-java/org/alfresco/opencmis/CMISDictionaryTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.alfresco.opencmis; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import org.alfresco.opencmis.dictionary.CMISDictionaryService; -import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper; -import org.alfresco.repo.dictionary.DictionaryDAO; -import org.alfresco.repo.dictionary.M2Model; -import org.alfresco.repo.tenant.TenantUtil; -import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations={"classpath:alfresco/application-context.xml"}) -public class CMISDictionaryTest -{ - private DictionaryDAO dictionaryDAO; - private CMISDictionaryService cmisDictionaryService; - - @Autowired - private ApplicationContext applicationContext; - - @Before - public void before() - { - this.dictionaryDAO = (DictionaryDAO)applicationContext.getBean("dictionaryDAO"); - this.cmisDictionaryService = (CMISDictionaryService)applicationContext.getBean("OpenCMISDictionaryService1.1"); - } - - @Test - public void test1() - { - TenantUtil.runAsUserTenant(new TenantRunAsWork() - { - @Override - public Void doWork() throws Exception - { - M2Model customModel = M2Model.createModel( - Thread.currentThread().getContextClassLoader(). - getResourceAsStream("dictionary/dictionarydaotest_model1.xml")); - dictionaryDAO.putModel(customModel); - assertNotNull(cmisDictionaryService.findType("P:cm:dublincore")); - TypeDefinitionWrapper td = cmisDictionaryService.findType("D:daotest1:type1"); - assertNotNull(td); - return null; - } - }, "user1", "tenant1"); - - TenantUtil.runAsUserTenant(new TenantRunAsWork() - { - @Override - public Void doWork() throws Exception - { - assertNotNull(cmisDictionaryService.findType("P:cm:dublincore")); - TypeDefinitionWrapper td = cmisDictionaryService.findType("D:daotest1:type1"); - assertNull(td); - return null; - } - }, "user2", "tenant2"); - } -} diff --git a/source/test-java/org/alfresco/opencmis/CMISTest.java b/source/test-java/org/alfresco/opencmis/CMISTest.java index 6a748dedd2..12ba8a2e62 100644 --- a/source/test-java/org/alfresco/opencmis/CMISTest.java +++ b/source/test-java/org/alfresco/opencmis/CMISTest.java @@ -22,6 +22,7 @@ package org.alfresco.opencmis; 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 static org.junit.Assert.assertNull; import static org.junit.Assert.fail; @@ -40,14 +41,20 @@ import java.util.Map; import java.util.Set; import org.alfresco.model.ContentModel; +import org.alfresco.opencmis.dictionary.CMISDictionaryService; +import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper; import org.alfresco.opencmis.search.CMISQueryOptions; import org.alfresco.opencmis.search.CMISQueryOptions.CMISQueryMode; import org.alfresco.repo.action.evaluator.ComparePropertyValueEvaluator; import org.alfresco.repo.action.executer.AddFeaturesActionExecuter; import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.repo.dictionary.DictionaryDAO; +import org.alfresco.repo.dictionary.M2Model; import org.alfresco.repo.domain.node.NodeDAO; import org.alfresco.repo.model.Repository; import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.tenant.TenantUtil; +import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.cmr.action.ActionCondition; import org.alfresco.service.cmr.action.ActionService; @@ -137,6 +144,8 @@ public class CMISTest private NamespaceService namespaceService; private AuthorityService authorityService; private PermissionService permissionService; + private DictionaryDAO dictionaryDAO; + private CMISDictionaryService cmisDictionaryService; private AlfrescoCmisServiceFactory factory; @@ -305,6 +314,8 @@ public class CMISTest this.nodeDAO = (NodeDAO) ctx.getBean("nodeDAO"); this.authorityService = (AuthorityService)ctx.getBean("AuthorityService"); this.permissionService = (PermissionService) ctx.getBean("permissionService"); + this.dictionaryDAO = (DictionaryDAO)ctx.getBean("dictionaryDAO"); + this.cmisDictionaryService = (CMISDictionaryService)ctx.getBean("OpenCMISDictionaryService1.1"); } /** @@ -2217,9 +2228,9 @@ public class CMISTest AccessControlEntryImpl ace = new AccessControlEntryImpl(); ace.setPrincipal(new AccessControlPrincipalDataImpl(testGroup)); List putPermissions = new ArrayList(); - putPermissions.add(BasicPermissions.ALL); - putPermissions.add(BasicPermissions.READ); - putPermissions.add(BasicPermissions.WRITE); + putPermissions.add(CMISAccessControlService.CMIS_ALL_PERMISSION); + putPermissions.add(CMISAccessControlService.CMIS_READ_PERMISSION); + putPermissions.add(CMISAccessControlService.CMIS_WRITE_PERMISSION); ace.setPermissions(putPermissions); ace.setDirect(true); acesList.add(ace); @@ -2314,4 +2325,37 @@ public class CMISTest AuthenticationUtil.popAuthentication(); } } + + @Test + public void dictionaryTest() + { + TenantUtil.runAsUserTenant(new TenantRunAsWork() + { + @Override + public Void doWork() throws Exception + { + M2Model customModel = M2Model.createModel( + Thread.currentThread().getContextClassLoader(). + getResourceAsStream("dictionary/dictionarydaotest_model1.xml")); + dictionaryDAO.putModel(customModel); + assertNotNull(cmisDictionaryService.findType("P:cm:dublincore")); + TypeDefinitionWrapper td = cmisDictionaryService.findType("D:daotest1:type1"); + assertNotNull(td); + return null; + } + }, "user1", "tenant1"); + + TenantUtil.runAsUserTenant(new TenantRunAsWork() + { + @Override + public Void doWork() throws Exception + { + assertNotNull(cmisDictionaryService.findType("P:cm:dublincore")); + TypeDefinitionWrapper td = cmisDictionaryService.findType("D:daotest1:type1"); + assertNull(td); + return null; + } + }, "user2", "tenant2"); + } + } diff --git a/source/test-java/org/alfresco/repo/policy/PolicyComponentTest.java b/source/test-java/org/alfresco/repo/policy/PolicyComponentTest.java index f09f103b81..45371e5b54 100644 --- a/source/test-java/org/alfresco/repo/policy/PolicyComponentTest.java +++ b/source/test-java/org/alfresco/repo/policy/PolicyComponentTest.java @@ -24,7 +24,7 @@ import java.util.List; import junit.framework.TestCase; -import org.alfresco.repo.cache.NullCache; +import org.alfresco.repo.cache.MemoryCache; import org.alfresco.repo.dictionary.DictionaryBootstrap; import org.alfresco.repo.dictionary.DictionaryComponent; import org.alfresco.repo.dictionary.DictionaryDAOImpl; @@ -77,11 +77,11 @@ public class PolicyComponentTest extends TestCase policyComponent = new PolicyComponentImpl(dictionary); } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO) { // note: unit tested here with null cache - dictionaryDAO.setDictionaryRegistryCache(new NullCache()); + dictionaryDAO.setDictionaryRegistryCache(new MemoryCache()); } public void testJavaBehaviour()