mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V4.1-BUG-FIX to HEAD
47745: ALF-18302: Merged V4.0.2 (4.0.2.29) to V4.1-BUG-FIX (4.1.5) 47498: MNT-317: CIFS: Image document version history lost intermittently after saving content in Preview on Mac Mountain Lion - Candidate fix by Dmitry Vaserin 47753: ALF-12264: Domain-filtering also done with new approach of fetching WorklfowTasks 47778: Merged DEV to V4.1-BUG-FIX ALF-18151: CMIS cannot delete folders that have rules applied - Will throw 'CMISConstraintException' exception only if 'ContentModel.ASSOC_CONTAINS' child association exist for the folder what is deleted. - Added and succesfully executed two unit test for openCMIS and CMIS. 47794: ALF-18302: Merged DEV to V4.1-BUG-FIX 47631: MNT-317: CIFS: Image document version history lost intermittently after saving content in Preview on Mac Mountain Lion Add class description describing the shuffle on ScenarioRenameDeleteMove. Add proper unit test. 47795: Merged back build fix from HEAD (thanks Neil) 47803: Merged PATCHES/V4.1.4 to V4.1-BUG-FIX 47680: Merged DEV to PATCHES/V4.1.4 47677: ALF-18270 Cannot open properties of model In FormUIGet.processFieldConstraints() was added check: (fieldConfig != null && fieldConfig.getConstraintDefinitionMap() != null). 47738: ALF-18301: Alfresco fails to start up because of NPE error, when debug logging for 'org.alfresco.repo.cache.AbstractAsynchronouslyRefreshedCache' is enabled - Fix by Dmitry Velichkevich 47754: Merged DEV to PATCHES/V4.1.4 47751: ALF-17644 : Document version was increased after canceling editing. Unnecessary calls for property deletion was removed. 47767: ALF-18088: Add Implementation-Edition + limit Specification-Version to 3 digits in war MANIFEST files 47786: Fixed ALF-18137 "It's impossible to create a new item in the data list." 47804: Merged PATCHES/V4.1.4 to V4.1-BUG-FIX (RECORD ONLY) 47755: Merged V4.1-BUG-FIX to PATCHES/V4.1.4 47753: ALF-12264: Domain-filtering also done with new approach of fetching WorklfowTasks git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@47807 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -6355,6 +6355,187 @@ public class ContentDiskDriverTest extends TestCase
|
||||
tran.doInTransaction(validateCB, false, true);
|
||||
|
||||
} // testScenarioMacMountainLionPreview_MNT_263
|
||||
|
||||
/**
|
||||
* This test tries to simulate the cifs shuffling that is done
|
||||
* from Save from Mac Mountain Lion by Preview when document is opened/saved few time a row
|
||||
*
|
||||
* a) Temp file created in temporary folder (temp\image.jpg)
|
||||
* b) Original file is renamed for deletion(test\image.jpg -> test\.smbdeleteAAA1b994.4)
|
||||
* c) Renamed file has got deleteOnClose flag
|
||||
* d) Renamed file is closed.
|
||||
* e) Temp file is moved into original file location(temp\image.jpg -> test\image.jgp)
|
||||
*/
|
||||
public void testScenarioMacMountainLionPreview_MNT_317() throws Exception
|
||||
{
|
||||
logger.debug("testScenarioMacMountainLionPreview_MNT_317");
|
||||
final String FILE_NAME = "image.jpg";
|
||||
final String TEMP_FILE_NAME = ".smbdeleteAAA1b994.4";
|
||||
|
||||
final String UPDATED_TEXT = "Mac Lion Preview Updated Content";
|
||||
|
||||
class TestContext
|
||||
{
|
||||
NetworkFile firstFileHandle;
|
||||
NetworkFile tempFileHandle;
|
||||
NodeRef testNodeRef; // node ref image.jpg
|
||||
}
|
||||
;
|
||||
|
||||
final TestContext testContext = new TestContext();
|
||||
|
||||
final String TEST_ROOT_DIR = "\\ContentDiskDriverTest";
|
||||
final String TEST_DIR = "\\ContentDiskDriverTest\\testScenarioMountainLionPreview";
|
||||
final String TEST_TEMP_DIR = "\\ContentDiskDriverTest\\testScenarioMountainLionPreview\\.Temporary Items";
|
||||
|
||||
ServerConfiguration scfg = new ServerConfiguration("testServer");
|
||||
TestServer testServer = new TestServer("testServer", scfg);
|
||||
final SrvSession testSession = new TestSrvSession(666, testServer, "test", "remoteName");
|
||||
DiskSharedDevice share = getDiskSharedDevice();
|
||||
final TreeConnection testConnection = testServer.getTreeConnection(share);
|
||||
final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper();
|
||||
|
||||
/**
|
||||
* Create a file in the test directory
|
||||
*/
|
||||
RetryingTransactionCallback<Void> createFileCB = new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
/**
|
||||
* Create the test directory we are going to use
|
||||
*/
|
||||
FileOpenParams createRootDirParams = new FileOpenParams(TEST_ROOT_DIR, 0, AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
|
||||
FileOpenParams createDirParams = new FileOpenParams(TEST_DIR, 0, AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
|
||||
FileOpenParams createTempDirParams = new FileOpenParams(TEST_TEMP_DIR, 0, AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
|
||||
driver.createDirectory(testSession, testConnection, createRootDirParams);
|
||||
driver.createDirectory(testSession, testConnection, createDirParams);
|
||||
driver.createDirectory(testSession, testConnection, createTempDirParams);
|
||||
|
||||
/**
|
||||
* Create the file we are going to use
|
||||
*/
|
||||
FileOpenParams createFileParams = new FileOpenParams(TEST_DIR + "\\" + FILE_NAME, 0, AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
|
||||
testContext.firstFileHandle = driver.createFile(testSession, testConnection, createFileParams);
|
||||
assertNotNull(testContext.firstFileHandle);
|
||||
|
||||
String testContent = "Mac Lion Preview Content";
|
||||
byte[] testContentBytes = testContent.getBytes();
|
||||
|
||||
driver.writeFile(testSession, testConnection, testContext.firstFileHandle, testContentBytes, 0, testContentBytes.length, 0);
|
||||
driver.closeFile(testSession, testConnection, testContext.firstFileHandle);
|
||||
|
||||
/**
|
||||
* Create the temp file we are going to use
|
||||
*/
|
||||
FileOpenParams createTempFileParams = new FileOpenParams(TEST_TEMP_DIR + "\\" + FILE_NAME, 0, AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
|
||||
testContext.tempFileHandle = driver.createFile(testSession, testConnection, createTempFileParams);
|
||||
assertNotNull(testContext.tempFileHandle);
|
||||
|
||||
testContent = UPDATED_TEXT;
|
||||
testContentBytes = testContent.getBytes();
|
||||
driver.writeFile(testSession, testConnection, testContext.tempFileHandle, testContentBytes, 0, testContentBytes.length, 0);
|
||||
driver.closeFile(testSession, testConnection, testContext.tempFileHandle);
|
||||
|
||||
/**
|
||||
* Also add versionable to target file
|
||||
*/
|
||||
testContext.testNodeRef = getNodeForPath(testConnection, TEST_DIR + "\\" + FILE_NAME);
|
||||
nodeService.addAspect(testContext.testNodeRef, ContentModel.ASPECT_VERSIONABLE, null);
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
tran.doInTransaction(createFileCB, false, true);
|
||||
|
||||
RetryingTransactionCallback<Void> renameFileCB = new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
FileOpenParams openFileParams = new FileOpenParams(TEST_DIR + "\\" + FILE_NAME, 0, AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
|
||||
testContext.tempFileHandle = driver.openFile(testSession, testConnection, openFileParams);
|
||||
driver.renameFile(testSession, testConnection, TEST_DIR + "\\" + FILE_NAME, TEST_DIR + "\\" + TEMP_FILE_NAME);
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
tran.doInTransaction(renameFileCB, false, true);
|
||||
|
||||
/**
|
||||
* Delete file via deleteOnClose flag.
|
||||
*/
|
||||
RetryingTransactionCallback<Void> deleteOnCloseCB = new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
FileInfo info = new FileInfo();
|
||||
info.setFileInformationFlags(FileInfo.SetDeleteOnClose);
|
||||
info.setDeleteOnClose(true);
|
||||
testContext.tempFileHandle.setDeleteOnClose(true);
|
||||
|
||||
driver.setFileInformation(testSession, testConnection, TEST_DIR + "\\" + TEMP_FILE_NAME, info);
|
||||
|
||||
assertNotNull(testContext.tempFileHandle);
|
||||
logger.debug("this close should result in a file being deleted");
|
||||
driver.closeFile(testSession, testConnection, testContext.tempFileHandle);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
tran.doInTransaction(deleteOnCloseCB, false, true);
|
||||
|
||||
// /**
|
||||
// * Delete file directly.
|
||||
// */
|
||||
// RetryingTransactionCallback<Void> deleteTargetFileCB = new RetryingTransactionCallback<Void>()
|
||||
// {
|
||||
//
|
||||
// @Override
|
||||
// public Void execute() throws Throwable
|
||||
// {
|
||||
//
|
||||
// driver.deleteFile(testSession, testConnection, TEST_DIR + "\\" + TEMP_FILE_NAME);
|
||||
// return null;
|
||||
// }
|
||||
// };
|
||||
// tran.doInTransaction(deleteTargetFileCB, false, true);
|
||||
|
||||
RetryingTransactionCallback<Void> moveRenamedTempFileCB = new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
driver.renameFile(testSession, testConnection, TEST_TEMP_DIR + "\\" + FILE_NAME, TEST_DIR + "\\" + FILE_NAME);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
tran.doInTransaction(moveRenamedTempFileCB, false, true);
|
||||
|
||||
RetryingTransactionCallback<Void> validateCB = new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
|
||||
NodeRef shuffledNodeRef = getNodeForPath(testConnection, TEST_DIR + "\\" + FILE_NAME);
|
||||
assertTrue("node is not versionable", nodeService.hasAspect(shuffledNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||
assertEquals("shuffledNode ref is different", shuffledNodeRef, testContext.testNodeRef);
|
||||
assertEquals("Unexpected content size", contentService.getReader(shuffledNodeRef, ContentModel.PROP_CONTENT).getSize(), UPDATED_TEXT.length());
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
tran.doInTransaction(validateCB, false, true);
|
||||
|
||||
} // testScenarioMacMountainLionPreview_MNT_317
|
||||
|
||||
/**
|
||||
* Gedit has the nasty behaviour of renaming an open file.
|
||||
|
Reference in New Issue
Block a user