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

105374: Merged 5.0.N (5.0.3) to HEAD-BUG-FIX (5.1/Cloud)
      105132: Merged V4.2-BUG-FIX (4.2.5) to 5.0.N (5.0.3)
         104888: Merged DEV to V4.2-BUG-FIX (4.2.5)
            104492: MNT-10962: Versioning for cmis:document not working initially
               - Use default values in the content model for autoVersion.
               - Test to ensure that version properties for node created via CMIS are set wrt contentModel.
               - TCK is now run with autoVersion=false.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@105408 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-06-03 09:00:06 +00:00
parent e20f71ed3e
commit b98c2dc6b0
6 changed files with 37 additions and 6 deletions

View File

@@ -19,6 +19,12 @@
package org.alfresco.rest.api.tests;
import org.alfresco.opencmis.OpenCMISClientContext;
import org.alfresco.repo.dictionary.DictionaryDAO;
import org.alfresco.repo.dictionary.M2Aspect;
import org.alfresco.repo.dictionary.M2Model;
import org.alfresco.repo.dictionary.M2Property;
import org.alfresco.service.namespace.QName;
import org.springframework.context.ApplicationContext;
/**
* Base class for Chemistry OpenCMIS TCK tests.
@@ -35,4 +41,21 @@ public abstract class AbstractEnterpriseOpenCMISTCKTest extends EnterpriseTestAp
{
return TCKEnterpriseTestFixture.getInstance();
}
protected void overrideVersionableAspectProperties(ApplicationContext ctx)
{
final DictionaryDAO dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO");
dictionaryDAO.removeModel(QName.createQName("cm:contentmodel"));
M2Model contentModel = M2Model.createModel(getClass().getClassLoader().getResourceAsStream("alfresco/model/contentModel.xml"));
M2Aspect versionableAspect = contentModel.getAspect("cm:versionable");
M2Property prop = versionableAspect.getProperty("cm:initialVersion");
prop.setDefaultValue(Boolean.FALSE.toString());
prop = versionableAspect.getProperty("cm:autoVersion");
prop.setDefaultValue(Boolean.FALSE.toString());
prop = versionableAspect.getProperty("cm:autoVersionOnUpdateProps");
prop.setDefaultValue(Boolean.FALSE.toString());
dictionaryDAO.putModel(contentModel);
}
}

View File

@@ -570,7 +570,7 @@ public class TestCMIS extends EnterpriseTestApi
return autoVersion;
}
}, personId, network1.getId());
assertEquals(Boolean.FALSE, autoVersion);
assertEquals(Boolean.TRUE, autoVersion);
}
// https://issues.alfresco.com/jira/browse/PUBLICAPI-92
@@ -1462,9 +1462,10 @@ public class TestCMIS extends EnterpriseTestApi
properties.put(PropertyIds.DESCRIPTION, GUID.generate());
}
AlfrescoDocument doc1 = (AlfrescoDocument)doc.updateProperties(properties);
doc1 = (AlfrescoDocument)doc1.getObjectOfLatestVersion(false);
String versionLabel1 = doc1.getVersionLabel();
assertEquals(versionLabel, versionLabel1);
assertTrue(Float.parseFloat(versionLabel) < Float.parseFloat(versionLabel1));
// ...and check that updating its content creates a new version
fileContent = new ContentStreamImpl();
@@ -1481,7 +1482,7 @@ public class TestCMIS extends EnterpriseTestApi
@SuppressWarnings("unused")
String versionLabel2 = doc2.getVersionLabel();
assertEquals("Set content stream shouldn't create a new version automatically", versionLabel1, versionLabel2);
assertTrue("Set content stream should create a new version automatically", Float.parseFloat(versionLabel1) < Float.parseFloat(versionLabel2));
}
/**

View File

@@ -26,6 +26,10 @@ import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.opencmis.OpenCMISClientContext;
import org.alfresco.repo.dictionary.DictionaryDAO;
import org.alfresco.repo.dictionary.M2Aspect;
import org.alfresco.repo.dictionary.M2Model;
import org.alfresco.repo.dictionary.M2Property;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.web.util.JettyComponent;
@@ -35,6 +39,7 @@ import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.apache.chemistry.opencmis.commons.enums.BindingType;
import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTestGroup;
@@ -120,6 +125,8 @@ public class TestEnterpriseAtomPubTCK extends AbstractEnterpriseOpenCMIS10TCKTes
cmisParameters.put(TestParameters.DEFAULT_TEST_FOLDER_PARENT, "/" + name);
clientContext = new OpenCMISClientContext(BindingType.ATOMPUB,
MessageFormat.format(CMIS_URL, "localhost", String.valueOf(port), "alfresco"), "admin", "admin", cmisParameters);
overrideVersionableAspectProperties(jetty.getApplicationContext());
}
// Commented out: See https://issues.alfresco.com/jira/browse/MNT-11123?focusedCommentId=339130&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-339130

View File

@@ -48,7 +48,7 @@ public class TestPublicApiAtomPub10TCK extends AbstractEnterpriseOpenCMIS10TCKTe
clientContext = new OpenCMISClientContext(BindingType.ATOMPUB,
MessageFormat.format(CMIS_URL, "localhost", String.valueOf(port), "alfresco", network.getId(), "public"),
"admin@" + network.getId(), "admin", cmisParameters);
overrideVersionableAspectProperties(getTestFixture().getJettyComponent().getApplicationContext());
}
@AfterClass

View File

@@ -36,7 +36,7 @@ public class TestPublicApiAtomPub11TCK extends AbstractEnterpriseOpenCMIS11TCKTe
clientContext = new OpenCMISClientContext(BindingType.ATOMPUB,
MessageFormat.format(CMIS_URL, "localhost", String.valueOf(port), "alfresco", network.getId(), "public"),
"admin@" + network.getId(), "admin", cmisParameters);
overrideVersionableAspectProperties(getTestFixture().getJettyComponent().getApplicationContext());
}
@AfterClass

View File

@@ -35,6 +35,6 @@ public class TestPublicApiBrowser11TCK extends AbstractEnterpriseOpenCMIS11TCKTe
clientContext = new OpenCMISClientContext(BindingType.BROWSER,
MessageFormat.format(CMIS_URL, "localhost", String.valueOf(port), "alfresco", network.getId(), "public"),
"admin@" + network.getId(), "admin", cmisParameters);
overrideVersionableAspectProperties(getTestFixture().getJettyComponent().getApplicationContext());
}
}