From 9f84dc7c728b51f89ce61ed7b1853177f8120094 Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Sat, 31 Jan 2015 11:22:28 +0000 Subject: [PATCH] Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud) 91358: Merged V4.2-BUG-FIX (4.2.5) to HEAD-BUG-FIX (5.0/Cloud) 91138: Merged DEV to V4.2-BUG-FIX (4.2.5) 91059 : MNT-12680: Alfresco 4.0/4.2 AtomPub cmis:createdDate value mapping for versions is different then Alfresco 3.4 AtomPub binding results - Extracting "creationDate" property via filter, like in v3.4 91139: MNT-12680: Alfresco 4.0/4.2 AtomPub cmis:createdDate value mapping for versions is different then Alfresco 3.4 AtomPub binding results - Reverted "merge" to incorrect branch 91260: Merged V4.2.4 (4.2.4) to V4.2-BUG-FIX (4.2.5) (RECORD ONLY) 91156: Merged DEV to V4.2-BUG-FIX (4.2.4) 91059 : MNT-12680: Alfresco 4.0/4.2 AtomPub cmis:createdDate value mapping for versions is different then Alfresco 3.4 AtomPub binding results - Extracting "creationDate" property via filter, like in v3.4 91264: Merged V4.2.4 (4.2.4) to V4.2-BUG-FIX (4.2.5) (RECORD ONLY) 91181: Reverse Merged V4.2-BUG-FIX (4.2.5) to V4.2.4 (4.2.4) 91156: Merged DEV to V4.2-BUG-FIX (4.2.4) 91059 : MNT-12680: Alfresco 4.0/4.2 AtomPub cmis:createdDate value mapping for versions is different then Alfresco 3.4 AtomPub binding results - Extracting "creationDate" property via filter, like in v3.4 91161: Merged DEV to PATCHES/4.2.4 91109 : MNT-12496: CMIS: Unable to navigate to a folder if it has image with special character on the metadata - Escaping of control characters was added 90723 : MNT-12496: CMIS: Unable to navigate to a folder if it has image with special character on the metadata - Added tests to check incorrect char in description property of node. 91342: Merged V4.2.4 (4.2.4) to V4.2-BUG-FIX (4.2.5) 91254: Merged DEV to PATCHES/4.2.4 91232 : MNT-12680: Alfresco 4.0/4.2 AtomPub cmis:createdDate value mapping for versions is different then Alfresco 3.4 AtomPub binding results - Extracting "creationDate" property via filter, like in v3.4 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@94785 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../org/alfresco/rest/api/tests/TestCMIS.java | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/source/test-java/org/alfresco/rest/api/tests/TestCMIS.java b/source/test-java/org/alfresco/rest/api/tests/TestCMIS.java index c9c4167fa7..aa73c40802 100644 --- a/source/test-java/org/alfresco/rest/api/tests/TestCMIS.java +++ b/source/test-java/org/alfresco/rest/api/tests/TestCMIS.java @@ -32,6 +32,7 @@ import java.util.AbstractList; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.GregorianCalendar; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -1322,6 +1323,86 @@ public class TestCMIS extends EnterpriseTestApi } } + /** + * MNT-12680 + * The creation date of version should be the same as creation date of the original node + * @throws Exception + */ + @Test + public void testCreationDate() throws Exception + { + // create a site + final TestNetwork network1 = getTestFixture().getRandomNetwork(); + String username = "user" + System.currentTimeMillis(); + PersonInfo personInfo = new PersonInfo(username, username, username, "password", null, null, null, null, null, null, null); + TestPerson person1 = network1.createUser(personInfo); + String person1Id = person1.getId(); + + final String siteName = "site" + System.currentTimeMillis(); + + TenantUtil.runAsUserTenant(new TenantRunAsWork() + { + + @Override + public NodeRef doWork() throws Exception + { + SiteInformation siteInfo = new SiteInformation(siteName, siteName, siteName, SiteVisibility.PUBLIC); + final TestSite site = network1.createSite(siteInfo); + final NodeRef resNode = repoService.createDocument(site.getContainerNodeRef("documentLibrary"), "testdoc.txt", "Test Doc1 Title", "Test Doc1 Description", + "Test Content"); + return resNode; + } + }, person1Id, network1.getId()); + + // create a document + publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id)); + CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, CMIS_VERSION_10, AlfrescoObjectFactoryImpl.class.getName()); + AlfrescoFolder docLibrary = (AlfrescoFolder) cmisSession.getObjectByPath("/Sites/" + siteName + "/documentLibrary"); + Map properties = new HashMap(); + { + properties.put(PropertyIds.OBJECT_TYPE_ID, TYPE_CMIS_DOCUMENT); + properties.put(PropertyIds.NAME, "mydoc-" + GUID.generate() + ".txt"); + } + ContentStreamImpl fileContent = new ContentStreamImpl(); + { + ContentWriter writer = new FileContentWriter(TempFileProvider.createTempFile(GUID.generate(), ".txt")); + writer.putContent("some content"); + ContentReader reader = writer.getReader(); + fileContent.setMimeType(MimetypeMap.MIMETYPE_TEXT_PLAIN); + fileContent.setStream(reader.getContentInputStream()); + } + + Document autoVersionedDoc = docLibrary.createDocument(properties, fileContent, VersioningState.MAJOR); + String objectId = autoVersionedDoc.getId(); + String bareObjectId = getBareObjectId(objectId); + // create versions + for (int i = 0; i < 3; i++) + { + Document doc1 = (Document) cmisSession.getObject(bareObjectId); + + ObjectId pwcId = doc1.checkOut(); + Document pwc = (Document) cmisSession.getObject(pwcId.getId()); + + ContentStreamImpl contentStream = new ContentStreamImpl(); + { + ContentWriter writer = new FileContentWriter(TempFileProvider.createTempFile(GUID.generate(), ".txt")); + writer.putContent(GUID.generate()); + ContentReader reader = writer.getReader(); + contentStream.setMimeType(MimetypeMap.MIMETYPE_TEXT_PLAIN); + contentStream.setStream(reader.getContentInputStream()); + } + pwc.checkIn(true, Collections.EMPTY_MAP, contentStream, "checkin " + i); + } + + GregorianCalendar cDateFirst = cmisSession.getAllVersions(bareObjectId).get(0).getCreationDate(); + GregorianCalendar cDateSecond = cmisSession.getAllVersions(bareObjectId).get(2).getCreationDate(); + + if (cDateFirst.before(cDateSecond) || cDateFirst.after(cDateSecond)) + { + fail("The creation date of version should be the same as creation date of the original node"); + } + } + /** * Test that updating properties does not automatically create a new version. * Test that updating content creates a new version automatically.