Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)

77154: Merged PLATFORM1 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud)
      74004: ACE-1802 "MT / Cloud Restrict namespace URI of dynamic models."
      ACE-955 "Custom Content Models in Cloud"
      fix tests


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@78012 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2014-07-23 16:03:56 +00:00
parent 1b4155add7
commit ece83f5410
4 changed files with 50 additions and 77 deletions

View File

@@ -23,9 +23,6 @@ public class AllUnitTestsSuite extends TestSuite
static void unitTests(TestSuite suite) 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.cmis.PropertyFilterTest.class);
suite.addTestSuite(org.alfresco.encryption.EncryptorTest.class); suite.addTestSuite(org.alfresco.encryption.EncryptorTest.class);
suite.addTestSuite(org.alfresco.encryption.KeyStoreKeyProviderTest.class); suite.addTestSuite(org.alfresco.encryption.KeyStoreKeyProviderTest.class);

View File

@@ -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<Void>()
{
@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<Void>()
{
@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");
}
}

View File

@@ -22,6 +22,7 @@ package org.alfresco.opencmis;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
@@ -40,14 +41,20 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import org.alfresco.model.ContentModel; 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;
import org.alfresco.opencmis.search.CMISQueryOptions.CMISQueryMode; import org.alfresco.opencmis.search.CMISQueryOptions.CMISQueryMode;
import org.alfresco.repo.action.evaluator.ComparePropertyValueEvaluator; import org.alfresco.repo.action.evaluator.ComparePropertyValueEvaluator;
import org.alfresco.repo.action.executer.AddFeaturesActionExecuter; import org.alfresco.repo.action.executer.AddFeaturesActionExecuter;
import org.alfresco.repo.content.MimetypeMap; 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.domain.node.NodeDAO;
import org.alfresco.repo.model.Repository; import org.alfresco.repo.model.Repository;
import org.alfresco.repo.security.authentication.AuthenticationUtil; 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.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.action.ActionCondition; import org.alfresco.service.cmr.action.ActionCondition;
import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.action.ActionService;
@@ -137,6 +144,8 @@ public class CMISTest
private NamespaceService namespaceService; private NamespaceService namespaceService;
private AuthorityService authorityService; private AuthorityService authorityService;
private PermissionService permissionService; private PermissionService permissionService;
private DictionaryDAO dictionaryDAO;
private CMISDictionaryService cmisDictionaryService;
private AlfrescoCmisServiceFactory factory; private AlfrescoCmisServiceFactory factory;
@@ -305,6 +314,8 @@ public class CMISTest
this.nodeDAO = (NodeDAO) ctx.getBean("nodeDAO"); this.nodeDAO = (NodeDAO) ctx.getBean("nodeDAO");
this.authorityService = (AuthorityService)ctx.getBean("AuthorityService"); this.authorityService = (AuthorityService)ctx.getBean("AuthorityService");
this.permissionService = (PermissionService) ctx.getBean("permissionService"); 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(); AccessControlEntryImpl ace = new AccessControlEntryImpl();
ace.setPrincipal(new AccessControlPrincipalDataImpl(testGroup)); ace.setPrincipal(new AccessControlPrincipalDataImpl(testGroup));
List<String> putPermissions = new ArrayList<String>(); List<String> putPermissions = new ArrayList<String>();
putPermissions.add(BasicPermissions.ALL); putPermissions.add(CMISAccessControlService.CMIS_ALL_PERMISSION);
putPermissions.add(BasicPermissions.READ); putPermissions.add(CMISAccessControlService.CMIS_READ_PERMISSION);
putPermissions.add(BasicPermissions.WRITE); putPermissions.add(CMISAccessControlService.CMIS_WRITE_PERMISSION);
ace.setPermissions(putPermissions); ace.setPermissions(putPermissions);
ace.setDirect(true); ace.setDirect(true);
acesList.add(ace); acesList.add(ace);
@@ -2314,4 +2325,37 @@ public class CMISTest
AuthenticationUtil.popAuthentication(); AuthenticationUtil.popAuthentication();
} }
} }
@Test
public void dictionaryTest()
{
TenantUtil.runAsUserTenant(new TenantRunAsWork<Void>()
{
@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<Void>()
{
@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");
}
} }

View File

@@ -24,7 +24,7 @@ import java.util.List;
import junit.framework.TestCase; 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.DictionaryBootstrap;
import org.alfresco.repo.dictionary.DictionaryComponent; import org.alfresco.repo.dictionary.DictionaryComponent;
import org.alfresco.repo.dictionary.DictionaryDAOImpl; import org.alfresco.repo.dictionary.DictionaryDAOImpl;
@@ -77,11 +77,11 @@ public class PolicyComponentTest extends TestCase
policyComponent = new PolicyComponentImpl(dictionary); policyComponent = new PolicyComponentImpl(dictionary);
} }
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "rawtypes" })
private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO) private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO)
{ {
// note: unit tested here with null cache // note: unit tested here with null cache
dictionaryDAO.setDictionaryRegistryCache(new NullCache()); dictionaryDAO.setDictionaryRegistryCache(new MemoryCache());
} }
public void testJavaBehaviour() public void testJavaBehaviour()