public void LocalFileDeletion(string ignoredCanonicalName, string ignoredLocalPath, string remoteFolderPath, string url, string user, string password, string repositoryId) { // Prepare remote folder and CmisSync process. ISession session = ClearRemoteCMISFolderAndGetSession(url, user, password, repositoryId, remoteFolderPath); sync = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); // Create the file LocalFile localFile = new LocalFile(url, user, password, repositoryId, remoteFolderPath, sync, this); // FIXME Check on server. Or even create the file on server. // Delete the file. File.Delete(Path.Combine(sync.Folder(), localFile.FullPath)); // Check that file is not present server-side. Thread.Sleep(15 * 1000); IDocument doc = null; try { doc = (IDocument)session.GetObjectByPath(remoteFolderPath + "/" + localFile.Filename, true); // Should have failed. Assert.Fail("Deleted document still exists on server: " + doc); } catch (CmisObjectNotFoundException e) { // That's the correct outcome } }
public void LocalFolderCreation(string ignoredCanonicalName, string ignoredLocalPath, string remoteFolderPath, string url, string user, string password, string repositoryId) { // Prepare remote folder and CmisSync process. ISession session = ClearRemoteCMISFolderAndGetSession(url, user, password, repositoryId, remoteFolderPath); sync = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); // Create local folder. string foldername = "folder 1"; Directory.CreateDirectory(Path.Combine(sync.Folder(), foldername)); // Check on server Thread.Sleep(10 * 1000); IFolder folder = null; try { folder = (IFolder)session.GetObjectByPath(remoteFolderPath + "/" + foldername, true); } catch (CmisObjectNotFoundException e) { Assert.Fail("Folder failed to get synced to the server.", e); } }
public void Issue772(string ignoredCanonicalName, string ignoredLocalPath, string remoteFolderPath, string url, string user, string password, string repositoryId) { // Clear the remote folder. ClearRemoteCMISFolder(url, user, password, repositoryId, remoteFolderPath); // Create syncs. sync = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); sync2 = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); // Wait so that sync gets a chance to sync things. Thread.Sleep(10 * 1000); // Disconnect 1. sync.Suspend(); // Create local folder on 2. string foldername = "Subfolder"; Directory.CreateDirectory(Path.Combine(sync2.Folder(), foldername)); // Wait so that sync gets a chance to sync things. Thread.Sleep(10 * 1000); // Reconnect 1. sync.Resume(); // Wait so that sync gets a chance to sync things. Thread.Sleep(10 * 1000); // Check that the folder is present on both. Assert.True(Directory.Exists(Path.Combine(sync.Folder(), foldername))); Assert.True(Directory.Exists(Path.Combine(sync2.Folder(), foldername))); }
public void RemoteDocumentCreation(string ignoredCanonicalName, string ignoredLocalPath, string remoteFolderPath, string url, string user, string password, string repositoryId) { // Prepare remote folder and CmisSync process. IFolder remoteBaseFolder = ClearRemoteCMISFolder(url, user, password, repositoryId, remoteFolderPath); sync = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); // Remote file creations string[] remoteFilenames = { "document.txt", "いろんなカタチが、見えてくる。", "مشاور", "コンサルティングपरामर्शदाता컨설턴트" }; foreach (string remoteFilename in remoteFilenames) { // Create remote file IDictionary <string, object> properties = new Dictionary <string, object>(); properties[PropertyIds.Name] = remoteFilename; properties[PropertyIds.ObjectTypeId] = "cmis:document"; byte[] creationContent = UTF8Encoding.UTF8.GetBytes("Hello World!"); ContentStream creationContentStream = new ContentStream(); creationContentStream.FileName = remoteFilename; creationContentStream.MimeType = "text/plain"; creationContentStream.Length = creationContent.Length; creationContentStream.Stream = new MemoryStream(creationContent); remoteBaseFolder.CreateDocument(properties, creationContentStream, null); // Wait for a few seconds so that sync gets a chance to sync things. Thread.Sleep(20 * 1000); // Check locally Assert.True(File.Exists(Path.Combine(sync.Folder(), (String)properties[PropertyIds.Name]))); } }
public void RemoteFolderDeletion(string ignoredCanonicalName, string ignoredLocalPath, string remoteFolderPath, string url, string user, string password, string repositoryId) { // Prepare remote folder and CmisSync process. IFolder remoteBaseFolder = ClearRemoteCMISFolder(url, user, password, repositoryId, remoteFolderPath); sync = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); // Create remote folder string foldername = "folder1"; IDictionary <string, object> properties = new Dictionary <string, object>(); properties[PropertyIds.Name] = foldername; properties[PropertyIds.ObjectTypeId] = "cmis:folder"; IFolder folder = remoteBaseFolder.CreateFolder(properties); // Wait for a few seconds so that sync gets a chance to sync things. Thread.Sleep(20 * 1000); // Check locally Assert.True(Directory.Exists(Path.Combine(sync.Folder(), (String)properties[PropertyIds.Name]))); // Delete the folder. folder.DeleteTree(true, null, true); // Wait for 10 seconds so that sync gets a chance to sync things. Thread.Sleep(10 * 1000); // Check locally Assert.False(Directory.Exists(Path.Combine(sync.Folder(), (String)properties[PropertyIds.Name]))); }
public void LocalFileCreation(string ignoredCanonicalName, string ignoredLocalPath, string remoteFolderPath, string url, string user, string password, string repositoryId) { // Clear the remote folder. ClearRemoteCMISFolder(url, user, password, repositoryId, remoteFolderPath); sync = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); new LocalFile(url, user, password, repositoryId, remoteFolderPath, sync, this); }
public void _CurrentlyFailing_RemoteDocumentModification(string ignoredCanonicalName, string ignoredLocalPath, string remoteFolderPath, string url, string user, string password, string repositoryId) { // Prepare remote folder and CmisSync process. IFolder remoteBaseFolder = ClearRemoteCMISFolder(url, user, password, repositoryId, remoteFolderPath); sync = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); // Create remote file string filename = "document.txt"; IDictionary <string, object> properties = new Dictionary <string, object>(); properties[PropertyIds.Name] = filename; properties[PropertyIds.ObjectTypeId] = "cmis:document"; byte[] creationContent = UTF8Encoding.UTF8.GetBytes("Hello World!"); ContentStream creationContentStream = new ContentStream(); creationContentStream.FileName = filename; creationContentStream.MimeType = "text/plain"; creationContentStream.Length = creationContent.Length; creationContentStream.Stream = new MemoryStream(creationContent); IDocument doc = remoteBaseFolder.CreateDocument(properties, creationContentStream, null); // Wait for a few seconds so that sync gets a chance to sync things. Thread.Sleep(20 * 1000); // Check locally Assert.True(File.Exists(Path.Combine(sync.Folder(), (String)properties[PropertyIds.Name]))); // Modify remote document. doc = (IDocument)CreateSession(url, user, password, repositoryId) .GetObjectByPath(remoteFolderPath + "/" + filename, true); string contentString = "Hello World, edited."; byte[] content = UTF8Encoding.UTF8.GetBytes(contentString); ContentStream contentStream = new ContentStream(); contentStream.FileName = filename; contentStream.MimeType = "text/plain"; contentStream.Length = content.Length; contentStream.Stream = new MemoryStream(content); doc.SetContentStream(contentStream, true); // Wait so that sync gets a chance to sync things. Thread.Sleep(30 * 1000); // Check local file string remoteContent = File.ReadAllText(Path.Combine(sync.Folder(), filename)); Assert.AreEqual(contentString, remoteContent); }
public void _CurrentlyFailing_LocalFolderMove(string ignoredCanonicalName, string ignoredLocalPath, string remoteFolderPath, string url, string user, string password, string repositoryId) { // Prepare remote folder and CmisSync process. ISession session = ClearRemoteCMISFolderAndGetSession(url, user, password, repositoryId, remoteFolderPath); sync = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); ////////////////////////////////////////////// Move local folder // Create second local folder. string foldername1 = "folder 1"; string foldername2 = "folder 2"; Directory.CreateDirectory(Path.Combine(sync.Folder(), foldername1)); Directory.CreateDirectory(Path.Combine(sync.Folder(), foldername2)); // Wait for 10 seconds so that sync gets a chance to sync things. Thread.Sleep(15 * 1000); string id = null; try { IFolder folder = (IFolder)session.GetObjectByPath(remoteFolderPath + "/" + foldername2, true); id = folder.Id; } catch (CmisObjectNotFoundException e) { Assert.Fail("Folder failed to get synced to the server.", e); } // Move folder 2 into folder 1 Directory.Move(Path.Combine(sync.Folder(), foldername2), Path.Combine(sync.Folder(), foldername1, foldername2)); // Check on server. Thread.Sleep(10 * 1000); string newId = null; try { IFolder folder = (IFolder)session.GetObjectByPath(remoteFolderPath + "/" + foldername1 + "/" + foldername2, true); newId = folder.Id; } catch (CmisObjectNotFoundException e) { Assert.Fail("Folder failed to get synced to the server.", e); } // Currently fails Assert.AreEqual(newId, id, "The remote folder's id has changed when the local folder was moved: " + id + " -> " + newId); }
public void _CurrentlyFailing_RemoteFolderRename(string ignoredCanonicalName, string ignoredLocalPath, string remoteFolderPath, string url, string user, string password, string repositoryId) { // Prepare remote folder and CmisSync process. IFolder remoteBaseFolder = ClearRemoteCMISFolder(url, user, password, repositoryId, remoteFolderPath); sync = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); // Create remote folder string foldername = "folder1"; IDictionary <string, object> folderProperties = new Dictionary <string, object>(); folderProperties[PropertyIds.Name] = foldername; folderProperties[PropertyIds.ObjectTypeId] = "cmis:folder"; IFolder folder = remoteBaseFolder.CreateFolder(folderProperties); // Create remote file inside that folder. string filename = "document.txt"; IDictionary <string, object> properties = new Dictionary <string, object>(); properties[PropertyIds.Name] = filename; properties[PropertyIds.ObjectTypeId] = "cmis:document"; string contentString = "Hello World!"; byte[] creationContent = UTF8Encoding.UTF8.GetBytes(contentString); ContentStream creationContentStream = new ContentStream(); creationContentStream.FileName = filename; creationContentStream.MimeType = "text/plain"; creationContentStream.Length = creationContent.Length; creationContentStream.Stream = new MemoryStream(creationContent); IDocument doc = folder.CreateDocument(properties, creationContentStream, null); // Check locally Thread.Sleep(20 * 1000); string syncedContent = File.ReadAllText(Path.Combine(sync.Folder(), foldername, filename)); Assert.AreEqual(contentString, syncedContent); Assert.True(Directory.Exists(Path.Combine(sync.Folder(), foldername))); // Rename folder string newFoldername = "renamed folder"; folder.Rename(newFoldername); // Check locally Thread.Sleep(20 * 1000); Assert.True(File.Exists(Path.Combine(sync.Folder(), newFoldername, filename)), "File not present where it should be"); syncedContent = File.ReadAllText(Path.Combine(sync.Folder(), foldername, filename)); Assert.AreEqual(contentString, syncedContent); Assert.False(File.Exists(Path.Combine(sync.Folder(), foldername, filename)), "File present where it should not be"); }
public void RemoteDocumentDeletionThenSameNameFolderCreation(string ignoredCanonicalName, string ignoredLocalPath, string remoteFolderPath, string url, string user, string password, string repositoryId) { // Prepare remote folder and CmisSync process. IFolder remoteBaseFolder = ClearRemoteCMISFolder(url, user, password, repositoryId, remoteFolderPath); sync = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); // Remote file creation string remoteObjectName = "document.or.folder"; // Create remote file IDictionary <string, object> properties = new Dictionary <string, object>(); properties[PropertyIds.Name] = remoteObjectName; properties[PropertyIds.ObjectTypeId] = "cmis:document"; byte[] creationContent = UTF8Encoding.UTF8.GetBytes("Hello World!"); ContentStream creationContentStream = new ContentStream(); creationContentStream.FileName = remoteObjectName; creationContentStream.MimeType = "text/plain"; creationContentStream.Length = creationContent.Length; creationContentStream.Stream = new MemoryStream(creationContent); IDocument document = remoteBaseFolder.CreateDocument(properties, creationContentStream, null); // Wait for 10 seconds so that sync gets a chance to sync things. Thread.Sleep(10 * 1000); // Check locally Assert.True(File.Exists(Path.Combine(sync.Folder(), remoteObjectName))); // Delete remote document document.DeleteAllVersions(); // Immediately create remote folder with exact same name IDictionary <string, object> folderProperties = new Dictionary <string, object>(); folderProperties[PropertyIds.Name] = remoteObjectName; folderProperties[PropertyIds.ObjectTypeId] = "cmis:folder"; IFolder folder = remoteBaseFolder.CreateFolder(folderProperties); // Wait for 10 seconds so that sync gets a chance to sync things. Thread.Sleep(10 * 1000); // Check locally Assert.True(Directory.Exists(Path.Combine(sync.Folder(), remoteObjectName))); }
public void TearDown() { // Exit the sync process to avoid any possible interference with subsequent tests. if (sync != null) { sync.Kill(); sync = null; } if (sync2 != null) { sync2.Kill(); sync2 = null; } // Run normal teardown too. base.TearDown(); }
public void RemoteDocumentMetadataModification(string ignoredCanonicalName, string ignoredLocalPath, string remoteFolderPath, string url, string user, string password, string repositoryId) { // Prepare remote folder and CmisSync process. IFolder remoteBaseFolder = ClearRemoteCMISFolder(url, user, password, repositoryId, remoteFolderPath); sync = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); // Create remote file string filename = "document.txt"; IDictionary <string, object> properties = new Dictionary <string, object>(); properties[PropertyIds.Name] = filename; properties[PropertyIds.ObjectTypeId] = "cmis:document"; byte[] creationContent = UTF8Encoding.UTF8.GetBytes("Hello World!"); ContentStream creationContentStream = new ContentStream(); creationContentStream.FileName = filename; creationContentStream.MimeType = "text/plain"; creationContentStream.Length = creationContent.Length; creationContentStream.Stream = new MemoryStream(creationContent); IDocument doc = remoteBaseFolder.CreateDocument(properties, creationContentStream, null); // Wait for 10 seconds so that sync gets a chance to sync things. Thread.Sleep(10 * 1000); // Check locally Assert.True(File.Exists(Path.Combine(sync.Folder(), (String)properties[PropertyIds.Name]))); // Modify remote document metadata. doc = (IDocument)CreateSession(url, user, password, repositoryId) .GetObjectByPath(remoteFolderPath + "/" + filename, true); // TODO create custom aspect on server //properties[PropertyIds.] = filename; // Wait so that sync gets a chance to sync things. Thread.Sleep(30 * 1000); // Check local file's metadata in database // TODO }
public void _CurrentlyFailing_RemoteDocumentRename(string ignoredCanonicalName, string ignoredLocalPath, string remoteFolderPath, string url, string user, string password, string repositoryId) { // Prepare remote folder and CmisSync process. IFolder remoteBaseFolder = ClearRemoteCMISFolder(url, user, password, repositoryId, remoteFolderPath); sync = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); // Remote file creation string filename = "document.txt"; // Create remote file IDictionary <string, object> properties = new Dictionary <string, object>(); properties[PropertyIds.Name] = filename; properties[PropertyIds.ObjectTypeId] = "cmis:document"; byte[] creationContent = UTF8Encoding.UTF8.GetBytes("Hello World!"); ContentStream creationContentStream = new ContentStream(); creationContentStream.FileName = filename; creationContentStream.MimeType = "text/plain"; creationContentStream.Length = creationContent.Length; creationContentStream.Stream = new MemoryStream(creationContent); IDocument document = remoteBaseFolder.CreateDocument(properties, creationContentStream, null); // Wait for a few seconds so that sync gets a chance to sync things. Thread.Sleep(20 * 1000); // Check locally Assert.True(File.Exists(Path.Combine(sync.Folder(), (String)properties[PropertyIds.Name]))); string newFilename = "renamed.txt"; //document.Move(remoteBaseFolder, folder); document.Rename(newFilename); // Wait for a few seconds so that sync gets a chance to sync things. Thread.Sleep(20 * 1000); // Check locally Assert.False(File.Exists(Path.Combine(sync.Folder(), filename))); // Currently fails, local document is not renamed, even though document is correctly renamed on server. Assert.True(File.Exists(Path.Combine(sync.Folder(), newFilename))); }
public void _CurrentlyFailing_TwoCmisSync(string ignoredCanonicalName, string ignoredLocalPath, string remoteFolderPath, string url, string user, string password, string repositoryId) { // Clear the remote folder. ClearRemoteCMISFolder(url, user, password, repositoryId, remoteFolderPath); // Create syncs. sync = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); sync2 = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); // Create local folder on 1. string foldername = "Subfolder0"; Directory.CreateDirectory(Path.Combine(sync.Folder(), foldername)); // Check on 2. Thread.Sleep(2 * 10 * 1000); Assert.True(Directory.Exists(Path.Combine(sync2.Folder(), foldername))); }
public void LocalFileCreationWithOnlyWatcher(string ignoredCanonicalName, string ignoredLocalPath, string remoteFolderPath, string url, string user, string password, string repositoryId) { // Prepare remote folder. ISession session = ClearRemoteCMISFolderAndGetSession(url, user, password, repositoryId, remoteFolderPath); // Month-long sync interval, meaning that in fact only the watcher can trigger syncs. sync = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId, CmisSyncProcess.MONTH_LONG_SYNC_INTERVAL); // Wait a few seconds so that sync gets a chance to sync things. Thread.Sleep(20 * 1000); ////////////////////////////////////////////// Local file creation // Create random small file. int sizeKb = 3; string filename = "file.doc"; LocalFilesystemActivityGenerator.CreateFile(Path.Combine(sync.Folder(), filename), sizeKb); // Check that file is present server-side. Thread.Sleep(20 * 1000); IDocument doc = null; try { doc = (IDocument)session.GetObjectByPath(remoteFolderPath + "/" + filename, true); } catch (CmisObjectNotFoundException e) { Assert.Fail("Document failed to get synced to the server.", e); } Assert.NotNull(doc); Assert.AreEqual(filename, doc.ContentStreamFileName); Assert.AreEqual(filename, doc.Name); Assert.AreEqual(sizeKb * 1024, doc.ContentStreamLength); Assert.AreEqual("application/msword", doc.ContentStreamMimeType); // TODO compare date Assert.AreEqual(, doc.); string docId = doc.Id; }
public void Conflict(string ignoredCanonicalName, string ignoredLocalPath, string remoteFolderPath, string url, string user, string password, string repositoryId) { // Prepare remote folder and CmisSync process. ISession session = ClearRemoteCMISFolderAndGetSession(url, user, password, repositoryId, remoteFolderPath); sync = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); ////////////////////////////////////////////// Initialization // Create random small file. int sizeKb = 3; string filename = "file.txt"; LocalFilesystemActivityGenerator.CreateTextFile(Path.Combine(sync.Folder(), filename), sizeKb); // Wait a few seconds so that sync gets a chance to sync things. Thread.Sleep(20 * 1000); sync.Suspend(); // Wait for 10 seconds to be sure suspension happened. Thread.Sleep(10 * 1000); ////////////////////////////////////////////// Modify on remote side byte[] content = UTF8Encoding.UTF8.GetBytes("Modified from remote side"); ContentStream contentStream = new ContentStream(); contentStream.FileName = "file.txt"; contentStream.MimeType = "text/plain"; contentStream.Length = content.Length; contentStream.Stream = new MemoryStream(content); IDocument doc = null; try { doc = (IDocument)session.GetObjectByPath(remoteFolderPath + "/" + filename, true); doc.SetContentStream(contentStream, true); } catch (CmisObjectNotFoundException e) { Assert.Fail("Document failed to get synced to the server.", e); } // Modify on local side, by appending to file. string dataToAppend = "Modified on local side"; byte[] bytes = Encoding.UTF8.GetBytes(dataToAppend); using (var fileStream = new FileStream(Path.Combine(sync.Folder(), filename), FileMode.Append, FileAccess.Write, FileShare.None)) using (var bw = new BinaryWriter(fileStream)) { bw.Write(bytes); } // Conflict sync.Resume(); Thread.Sleep(10 * 1000); // TODO check that conflicts happened correctly. }
public void LocalFileAppend(string ignoredCanonicalName, string ignoredLocalPath, string remoteFolderPath, string url, string user, string password, string repositoryId) { // Prepare remote folder and CmisSync process. ISession session = ClearRemoteCMISFolderAndGetSession(url, user, password, repositoryId, remoteFolderPath); sync = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); // Local file creation // Create random small file. int sizeKb = 3; string filename = "file.doc"; LocalFilesystemActivityGenerator.CreateFile(Path.Combine(sync.Folder(), filename), sizeKb); // Check that file is present server-side. Thread.Sleep(20 * 1000); IDocument doc = null; try { doc = (IDocument)session.GetObjectByPath(remoteFolderPath + "/" + filename, true); } catch (CmisObjectNotFoundException e) { Assert.Fail("Document failed to get synced to the server.", e); } Assert.NotNull(doc); Assert.AreEqual(filename, doc.ContentStreamFileName); Assert.AreEqual(filename, doc.Name); Assert.AreEqual(sizeKb * 1024, doc.ContentStreamLength); Assert.AreEqual("application/msword", doc.ContentStreamMimeType); // TODO compare date Assert.AreEqual(, doc.); string docId = doc.Id; // Local file append // Append to file string dataToAppend = "let's add a bit more data to that file"; byte[] bytes = Encoding.UTF8.GetBytes(dataToAppend); using (var fileStream = new FileStream(Path.Combine(sync.Folder(), filename), FileMode.Append, FileAccess.Write, FileShare.None)) using (var bw = new BinaryWriter(fileStream)) { bw.Write(bytes); } // Check on server Thread.Sleep(10 * 1000); try { doc = (IDocument)session.GetObjectByPath(remoteFolderPath + "/" + filename, true); } catch (CmisObjectNotFoundException e) { Assert.Fail("Document failed to get synced to the server.", e); } Assert.NotNull(doc); Assert.AreEqual(filename, doc.ContentStreamFileName); Assert.AreEqual(filename, doc.Name); Assert.True(1 - (1024 * sizeKb + dataToAppend.Length) / doc.ContentStreamLength < 0.1); // Text file size can vary a bit }
public void _CurrentlyFailing_LocalFileMove(string ignoredCanonicalName, string ignoredLocalPath, string remoteFolderPath, string url, string user, string password, string repositoryId) { // Prepare remote folder and CmisSync process. ISession session = ClearRemoteCMISFolderAndGetSession(url, user, password, repositoryId, remoteFolderPath); sync = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); ////////////////////////////////////////////// Local file creation // Create random small file. int sizeKb = 3; string filename = "file.doc"; LocalFilesystemActivityGenerator.CreateFile(Path.Combine(sync.Folder(), filename), sizeKb); // Wait a few seconds so that sync gets a chance to sync things. Thread.Sleep(20 * 1000); // Check that file is present server-side. IDocument doc = null; try { doc = (IDocument)session.GetObjectByPath(remoteFolderPath + "/" + filename, true); } catch (CmisObjectNotFoundException e) { Assert.Fail("Document failed to get synced to the server.", e); } Assert.NotNull(doc); Assert.AreEqual(filename, doc.ContentStreamFileName); Assert.AreEqual(filename, doc.Name); Assert.AreEqual(sizeKb * 1024, doc.ContentStreamLength); Assert.AreEqual("application/msword", doc.ContentStreamMimeType); // TODO compare date Assert.AreEqual(, doc.); string docId = doc.Id; ////////////////////////////////////////////// Local folder creation // Create local folder. string foldername = "folder 1"; Directory.CreateDirectory(Path.Combine(sync.Folder(), foldername)); // Wait for 10 seconds so that sync gets a chance to sync things. Thread.Sleep(20 * 1000); IFolder folder = null; try { folder = (IFolder)session.GetObjectByPath(remoteFolderPath + "/" + foldername, true); } catch (CmisObjectNotFoundException e) { Assert.Fail("Folder failed to get synced to the server.", e); } // Move local file to other folder string destinationFilename = foldername + Path.DirectorySeparatorChar + filename; File.Move(Path.Combine(sync.Folder(), filename), Path.Combine(sync.Folder(), destinationFilename)); // Check that the remote document has been renamed, and still has the same object id. Thread.Sleep(20 * 1000); doc = null; try { doc = (IDocument)session.GetObjectByPath(remoteFolderPath + "/" + foldername + "/" + filename, true); } catch (CmisObjectNotFoundException e) { Assert.Fail("Document failed to get moved on server.", e); } Assert.NotNull(doc); Assert.AreEqual(filename, doc.ContentStreamFileName); Assert.AreEqual(filename, doc.Name); string newDocId = doc.Id; // Current status: Fails. Assert.AreEqual(docId, newDocId, "The remote document's id has changed when the local file was moved: " + docId + " -> " + newDocId); }
public void LocalFileRename(string ignoredCanonicalName, string ignoredLocalPath, string remoteFolderPath, string url, string user, string password, string repositoryId) { // Prepare remote folder and CmisSync process. ISession session = ClearRemoteCMISFolderAndGetSession(url, user, password, repositoryId, remoteFolderPath); sync = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); ////////////////////////////////////////////// Local file creation // Create random small file. int sizeKb = 3; string filename = "file.doc"; LocalFilesystemActivityGenerator.CreateFile(Path.Combine(sync.Folder(), filename), sizeKb); // Wait a few seconds so that sync gets a chance to sync things. Thread.Sleep(20 * 1000); // Check that file is present server-side. IDocument doc = null; try { doc = (IDocument)session.GetObjectByPath(remoteFolderPath + "/" + filename, true); } catch (CmisObjectNotFoundException e) { Assert.Fail("Document failed to get synced to the server.", e); } Assert.NotNull(doc); Assert.AreEqual(filename, doc.ContentStreamFileName); Assert.AreEqual(filename, doc.Name); Assert.AreEqual(sizeKb * 1024, doc.ContentStreamLength); Assert.AreEqual("application/msword", doc.ContentStreamMimeType); // TODO compare date Assert.AreEqual(, doc.); string docId = doc.Id; ////////////////////////////////////////////// Local file rename // Rename the document string newFilename = "moved_" + filename; File.Move(Path.Combine(sync.Folder(), filename), Path.Combine(sync.Folder(), newFilename)); filename = newFilename; // Check that the remote document has been renamed, and still has the same object id. Thread.Sleep(10 * 1000); doc = null; try { doc = (IDocument)session.GetObjectByPath(remoteFolderPath + "/" + filename, true); } catch (CmisObjectNotFoundException e) { Assert.Fail("Document failed to get synced to the server.", e); } Assert.NotNull(doc); Assert.AreEqual(filename, doc.ContentStreamFileName); Assert.AreEqual(filename, doc.Name); string newDocId = doc.Id; // Current status: The following line sometimes fails, sometimes succeeds. Probably a race condition. Assert.AreEqual(docId, newDocId, "The remote document's id has changed when the local file was renamed: " + docId + " -> " + newDocId); }
public void LongScenario(string ignoredCanonicalName, string ignoredLocalPath, string remoteFolderPath, string url, string user, string password, string repositoryId) { // Prepare remote folder and CmisSync process. ClearRemoteCMISFolder(url, user, password, repositoryId, remoteFolderPath); sync = new CmisSyncProcess(remoteFolderPath, url, user, password, repositoryId); ////////////////////////////////////////////// Local file creation // Create random small file. int sizeKb = 3; string filename = "file.doc"; LocalFilesystemActivityGenerator.CreateFile(Path.Combine(sync.Folder(), filename), sizeKb); // Wait a few seconds so that sync gets a chance to sync things. Thread.Sleep(20 * 1000); // Check that file is present server-side. IDocument doc = null; try { doc = (IDocument)CreateSession(url, user, password, repositoryId) .GetObjectByPath(remoteFolderPath + "/" + filename, true); } catch (CmisObjectNotFoundException e) { Assert.Fail("Document failed to get synced to the server.", e); } Assert.NotNull(doc); Assert.AreEqual(filename, doc.ContentStreamFileName); Assert.AreEqual(filename, doc.Name); Assert.AreEqual(sizeKb * 1024, doc.ContentStreamLength); Assert.AreEqual("application/msword", doc.ContentStreamMimeType); // TODO compare date Assert.AreEqual(, doc.); string docId = doc.Id; ////////////////////////////////////////////// Local file append // Append to file string dataToAppend = "let's add a bit more data to that file"; byte[] bytes = Encoding.UTF8.GetBytes(dataToAppend); using (var fileStream = new FileStream(Path.Combine(sync.Folder(), filename), FileMode.Append, FileAccess.Write, FileShare.None)) using (var bw = new BinaryWriter(fileStream)) { bw.Write(bytes); } // Wait for 10 seconds so that sync gets a chance to sync things. Thread.Sleep(10 * 1000); try { doc = (IDocument)CreateSession(url, user, password, repositoryId) .GetObjectByPath(remoteFolderPath + "/" + filename, true); } catch (CmisObjectNotFoundException e) { Assert.Fail("Document failed to get synced to the server.", e); } Assert.NotNull(doc); Assert.AreEqual(filename, doc.ContentStreamFileName); Assert.AreEqual(filename, doc.Name); Assert.True(1 - (1024 * sizeKb + dataToAppend.Length) / doc.ContentStreamLength < 0.1); // Text file size can vary a bit ////////////////////////////////////////////// Local folder creation // Create local folder. string foldername = "folder 1"; Directory.CreateDirectory(Path.Combine(sync.Folder(), foldername)); // Wait for 10 seconds so that sync gets a chance to sync things. Thread.Sleep(10 * 1000); IFolder folder = null; try { folder = (IFolder)CreateSession(url, user, password, repositoryId) .GetObjectByPath(remoteFolderPath + "/" + foldername, true); } catch (CmisObjectNotFoundException e) { Assert.Fail("Folder failed to get synced to the server.", e); } ////////////////////////////////////////////// Local file delete // Delete the file. File.Delete(Path.Combine(sync.Folder(), filename)); // Wait so that sync gets a chance to sync things. Thread.Sleep(15 * 1000); // Check that file is not present server-side. doc = null; try { doc = (IDocument)CreateSession(url, user, password, repositoryId) .GetObjectByPath(remoteFolderPath + "/" + filename, true); // Should have failed. Assert.Fail("Deleted document still exists on server: " + doc); } catch (CmisObjectNotFoundException e) { // That's the correct outcome } ////////////////////////////////////////////// Remote file creation string[] remoteFilenames = { filename, "いろんなカタチが、見えてくる。", "مشاور", "コンサルティングपरामर्शदाता컨설턴트" }; foreach (string remoteFilename in remoteFilenames) { // Create remote file IFolder remoteBaseFolder = (IFolder)CreateSession(url, user, password, repositoryId).GetObjectByPath(remoteFolderPath, true); IDictionary <string, object> properties = new Dictionary <string, object>(); properties[PropertyIds.Name] = remoteFilename; properties[PropertyIds.ObjectTypeId] = "cmis:document"; byte[] creationContent = UTF8Encoding.UTF8.GetBytes("Hello World!"); ContentStream creationContentStream = new ContentStream(); creationContentStream.FileName = remoteFilename; creationContentStream.MimeType = "text/plain"; creationContentStream.Length = creationContent.Length; creationContentStream.Stream = new MemoryStream(creationContent); remoteBaseFolder.CreateDocument(properties, creationContentStream, null); // Wait for 10 seconds so that sync gets a chance to sync things. Thread.Sleep(10 * 1000); // Check locally Assert.True(File.Exists(Path.Combine(sync.Folder(), (String)properties[PropertyIds.Name]))); } ////////////////////////////////////////////// Remote file modification doc = (IDocument)CreateSession(url, user, password, repositoryId) .GetObjectByPath(remoteFolderPath + "/" + filename, true); string contentString = "Hello World, edited."; byte[] content = UTF8Encoding.UTF8.GetBytes(contentString); ContentStream contentStream = new ContentStream(); contentStream.FileName = filename; contentStream.MimeType = "text/plain"; contentStream.Length = content.Length; contentStream.Stream = new MemoryStream(content); doc.SetContentStream(contentStream, true); // Wait so that sync gets a chance to sync things. Thread.Sleep(30 * 1000); // Check local file string remoteContent = File.ReadAllText(Path.Combine(sync.Folder(), filename)); Assert.AreEqual(contentString, remoteContent); }