Synchronization with a particular CMIS folder.
        public void ClientSideDirectoryAndSmallFilesAddition(string canonical_name, string localPath, string remoteFolderPath,
            string url, string user, string password, string repositoryId)
        {
            // Prepare checkout directory.
            string localDirectory = Path.Combine(CMISSYNCDIR, canonical_name);
            CleanDirectory(localDirectory);
            Console.WriteLine("Synced to clean state.");

            IActivityListener activityListener = new Mock<IActivityListener>().Object;
            RepoInfo repoInfo = new RepoInfo(
                    canonical_name,
                    CMISSYNCDIR,
                    remoteFolderPath,
                    url,
                    user,
                    password,
                    repositoryId,
                    5000);

            using (CmisRepo cmis = new CmisRepo(repoInfo, activityListener))
            {
                using (CmisRepo.SynchronizedFolder synchronizedFolder = new CmisRepo.SynchronizedFolder(
                    repoInfo,
                    activityListener,
                    cmis))
                {
                    synchronizedFolder.Sync();
                    Console.WriteLine("Synced to clean state.");

                    // Create directory and small files.
                    LocalFilesystemActivityGenerator.CreateDirectoriesAndFiles(localDirectory);

                    // Sync again.
                    synchronizedFolder.Sync();
                    Console.WriteLine("Second sync done.");

                    // Clean.
                    Console.WriteLine("Clean all.");
                    Clean(localDirectory, synchronizedFolder);
                }
            }
        }
        public void SyncWhileModifyingFolders(string canonical_name, string localPath, string remoteFolderPath,
            string url, string user, string password, string repositoryId)
        {
            // Prepare checkout directory.
            string localDirectory = Path.Combine(CMISSYNCDIR, canonical_name);
            CleanDirectory(localDirectory);
            Console.WriteLine("Synced to clean state.");
            
            // Mock.
            IActivityListener activityListener = new Mock<IActivityListener>().Object;
            // Sync.
            RepoInfo repoInfo = new RepoInfo(
                    canonical_name,
                    CMISSYNCDIR,
                    remoteFolderPath,
                    url,
                    user,
                    password,
                    repositoryId,
                    5000);

            using (CmisRepo cmis = new CmisRepo(repoInfo, activityListener))
            {
                using (CmisRepo.SynchronizedFolder synchronizedFolder = new CmisRepo.SynchronizedFolder(
                    repoInfo,
                    activityListener,
                    cmis))
                {
                    synchronizedFolder.Sync();
                    Console.WriteLine("Synced to clean state.");

                    // Sync a few times in a different thread.
                    bool syncing = true;
                    BackgroundWorker bw = new BackgroundWorker();
                    bw.DoWork += new DoWorkEventHandler(
                        delegate(Object o, DoWorkEventArgs args)
                        {
                            for (int i = 0; i < 10; i++)
                            {
                                Console.WriteLine("Sync D" + i.ToString());
                                synchronizedFolder.Sync();
                            }
                        }
                    );
                    bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
                        delegate(object o, RunWorkerCompletedEventArgs args)
                        {
                            syncing = false;
                        }
                    );
                    bw.RunWorkerAsync();

                    // Keep creating/removing a file as long as sync is going on.
                    while (syncing)
                    {
                        //Console.WriteLine("Create/remove.");
                        LocalFilesystemActivityGenerator.CreateDirectoriesAndFiles(localDirectory);
                        CleanAll(localDirectory);
                    }

                    // Clean.
                    Console.WriteLine("Clean all.");
                    Clean(localDirectory, synchronizedFolder);
                }
            }
        }
        public void Sync(string canonical_name, string localPath, string remoteFolderPath,
            string url, string user, string password, string repositoryId)
        {
            // Prepare checkout directory.
            string localDirectory = Path.Combine(CMISSYNCDIR, canonical_name);
            CleanDirectory(localDirectory);
            Console.WriteLine("Synced to clean state.");

            IActivityListener activityListener = new Mock<IActivityListener>().Object;
            RepoInfo repoInfo = new RepoInfo(
                    canonical_name,
                    CMISSYNCDIR,
                    remoteFolderPath,
                    url,
                    user,
                    password,
                    repositoryId,
                    5000);

            using (CmisRepo cmis = new CmisRepo(repoInfo, activityListener))
            {
                using (CmisRepo.SynchronizedFolder synchronizedFolder = new CmisRepo.SynchronizedFolder(
                    repoInfo,
                    activityListener,
                    cmis))
                {
                    synchronizedFolder.Sync();
                    Console.WriteLine("Synced to clean state.");

                    // Clean.
                    Console.WriteLine("Clean all.");
                    Clean(localDirectory, synchronizedFolder);
                }
            }
        }
        public void ClientSideBigFileAddition(string canonical_name, string localPath, string remoteFolderPath,
            string url, string user, string password, string repositoryId)
        {
            // Prepare checkout directory.
            string localDirectory = Path.Combine(CMISSYNCDIR, canonical_name);
            CleanDirectory(localDirectory);
            Console.WriteLine("Synced to clean state.");

            IActivityListener activityListener = new Mock<IActivityListener>().Object;
            RepoInfo repoInfo = new RepoInfo(
                    canonical_name,
                    ".",
                    remoteFolderPath,
                    url,
                    user,
                    password,
                    repositoryId,
                    5000);

            using (CmisRepo cmis = new CmisRepo(repoInfo, activityListener))
            {
                using (CmisRepo.SynchronizedFolder synchronizedFolder = new CmisRepo.SynchronizedFolder(
                    repoInfo,
                    activityListener,
                    cmis))
                {
                    synchronizedFolder.Sync();
                    Console.WriteLine("Synced to clean state.");

                    // Create random big file.
                    LocalFilesystemActivityGenerator.CreateRandomFile(localDirectory, 1000); // 1 MB ... no that big to not load servers too much.

                    // Sync again.
                    synchronizedFolder.Sync();
                    Console.WriteLine("Second sync done.");

                    // Check that file is present server-side.
                    // TODO

                    // Clean.
                    Console.WriteLine("Clean all.");
                    Clean(localDirectory, synchronizedFolder);
                }
            }
        }
Exemple #5
0
        public void SyncRemote(string canonical_name, string localPath, string remoteFolderPath,
            string url, string user, string password, string repositoryId)
        {
            // Prepare checkout directory.
            string localDirectory = Path.Combine(CMISSYNCDIR, canonical_name);
            CleanDirectory(localDirectory);
            Console.WriteLine("Synced to clean state.");

            // Mock.
            IActivityListener activityListener = new Mock<IActivityListener>().Object;
            // Sync.
            RepoInfo repoInfo = new RepoInfo(
                    canonical_name,
                    CMISSYNCDIR,
                    remoteFolderPath,
                    url,
                    user,
                    password,
                    repositoryId,
                    5000,
                    false,
                    DateTime.MinValue,
                    true);

            using (CmisRepo cmis = new CmisRepo(repoInfo, activityListener))
            {
                using (CmisRepo.SynchronizedFolder synchronizedFolder =
                    new CmisRepo.SynchronizedFolder(repoInfo, cmis, activityListener))
                using (Watcher watcher = new Watcher(localDirectory))
                {
                    synchronizedFolder.Sync();
                    CleanAll(localDirectory);
                    WatcherTest.WaitWatcher();
                    synchronizedFolder.Sync();
                    Console.WriteLine("Synced to clean state.");

                    ISession session = CreateSession(repoInfo);
                    IFolder folder = (IFolder)session.GetObjectByPath(remoteFolderPath);

                    string name1 = "SyncChangeLog.1";
                    string path1 = Path.Combine(localDirectory, name1);

                    string name2 = "SyncChangeLog.2";
                    string path2 = Path.Combine(localDirectory, name2);

                    //  create document
                    Console.WriteLine(" Remote create file");
                    Assert.IsFalse(File.Exists(path1));
                    IDocument doc1 = CreateDocument(folder, name1, "SyncChangeLog");
                    Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder, delegate {
                        return File.Exists(path1);
                    }));
                    Assert.IsTrue(File.Exists(path1));

                    //TODO: AtomPub does not support copy
                    ////  copy document
                    //Console.WriteLine(" Remote copy file");
                    //Assert.IsFalse(File.Exists(path2));
                    //IDocument doc2 = CopyDocument(folder, doc1, name2);
                    //synchronizedFolder.Sync();
                    //Assert.IsTrue(File.Exists(path2));

                    //  rename document
                    Console.WriteLine(" Remote rename file");
                    Assert.IsTrue(File.Exists(path1));
                    Assert.IsFalse(File.Exists(path2));
                    IDocument doc2 = RenameDocument(doc1, name2);
                    Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder, delegate {
                        return !File.Exists(path1) && File.Exists(path2);
                    }));
                    Assert.IsFalse(File.Exists(path1));
                    Assert.IsTrue(File.Exists(path2));

                    //  create folder
                    Console.WriteLine(" Remote create folder");
                    Assert.IsFalse(Directory.Exists(path1));
                    IFolder folder1 = CreateFolder(folder, name1);
                    Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder, delegate {
                        return Directory.Exists(path1);
                    }));
                    Assert.IsTrue(Directory.Exists(path1));

                    //  move document
                    Console.WriteLine(" Remote move file");
                    string filename = Path.Combine(path1, name2);
                    Assert.IsFalse(File.Exists(filename));
                    doc2.Move(folder, folder1);
                    Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder, delegate {
                        return File.Exists(filename);
                    }));

                    //  delete document
                    Console.WriteLine(" Remote delete file");
                    Assert.IsTrue(File.Exists(filename));
                    doc2.DeleteAllVersions();
                    Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder, delegate {
                        return !File.Exists(filename);
                    }));
                    Assert.IsFalse(File.Exists(filename));

                    //  rename folder
                    Console.WriteLine(" Remote rename folder");
                    Assert.IsTrue(Directory.Exists(path1));
                    Assert.IsFalse(Directory.Exists(path2));
                    IFolder folder2 = RenameFolder(folder1, name2);
                    Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder, delegate {
                        return !Directory.Exists(path1) && Directory.Exists(path2);
                    }));
                    Assert.IsFalse(Directory.Exists(path1));
                    Assert.IsTrue(Directory.Exists(path2));

                    //  move folder
                    Console.WriteLine(" Remote move folder");
                    Assert.IsFalse(Directory.Exists(path1));
                    folder1 = CreateFolder(folder, name1);
                    Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder, delegate {
                        return Directory.Exists(path1) && !Directory.Exists(Path.Combine(path2, name1));
                    }));
                    Assert.IsTrue(Directory.Exists(path1));
                    Assert.IsFalse(Directory.Exists(Path.Combine(path2, name1)));
                    folder1.Move(folder, folder2);
                    Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder, delegate {
                        return !Directory.Exists(path1) && Directory.Exists(Path.Combine(path2, name1));
                    }));
                    Assert.IsFalse(Directory.Exists(path1));
                    Assert.IsTrue(Directory.Exists(Path.Combine(path2, name1)));

                    //  move folder with sub folder and sub file
                    Console.WriteLine(" Remote move folder with subfolder and subfile");
                    Assert.IsFalse(File.Exists(Path.Combine(path2, name1, name1)));
                    Assert.IsFalse(Directory.Exists(Path.Combine(path2, name1, name2)));
                    CreateDocument(folder1, name1, "SyncChangeLog");
                    CreateFolder(folder1, name2);
                    Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder, delegate {
                        return File.Exists(Path.Combine(path2, name1, name1)) && Directory.Exists(Path.Combine(path2, name1, name2));
                    }));
                    Assert.IsTrue(File.Exists(Path.Combine(path2, name1, name1)));
                    Assert.IsTrue(Directory.Exists(Path.Combine(path2, name1, name2)));
                    folder1.Move(folder2, folder);
                    Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder, delegate {
                        return File.Exists(Path.Combine(path1, name1)) && Directory.Exists(Path.Combine(path1, name2));
                    }));
                    Assert.IsTrue(File.Exists(Path.Combine(path1, name1)));
                    Assert.IsTrue(Directory.Exists(Path.Combine(path1, name2)));

                    //  delete folder tree
                    Console.WriteLine(" Remote delete folder tree");
                    Assert.IsTrue(Directory.Exists(path1));
                    folder1.DeleteTree(true, null, true);
                    Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder, delegate {
                        return !Directory.Exists(path1);
                    }, 20));
                    Assert.IsFalse(Directory.Exists(path1));
                    Assert.IsTrue(Directory.Exists(path2));
                    folder2.DeleteTree(true, null, true);
                    WaitUntilSyncIsDone(synchronizedFolder, delegate {
                        return !Directory.Exists(path2);
                    });
                    if(Directory.Exists(path2))
                        synchronizedFolder.ForceFullSync();
                    Assert.IsFalse(Directory.Exists(path2));

                    // Clean.
                    Console.WriteLine("Clean all.");
                    Clean(localDirectory, synchronizedFolder);
                }
            }
        }
Exemple #6
0
        public void SyncRemoteHeavyFolder(string canonical_name, string localPath, string remoteFolderPath,
            string url, string user, string password, string repositoryId)
        {
            // Prepare checkout directory.
            string localDirectory = Path.Combine(CMISSYNCDIR, canonical_name);
            CleanDirectory(localDirectory);
            Console.WriteLine("Synced to clean state.");

            // Mock.
            IActivityListener activityListener = new Mock<IActivityListener>().Object;
            // Sync.
            RepoInfo repoInfo = new RepoInfo(
                    canonical_name,
                    CMISSYNCDIR,
                    remoteFolderPath,
                    url,
                    user,
                    password,
                    repositoryId,
                    5000,
                    false,
                    DateTime.MinValue,
                    true);

            using (CmisRepo cmis = new CmisRepo(repoInfo, activityListener))
            {
                using (CmisRepo.SynchronizedFolder synchronizedFolder =
                    new CmisRepo.SynchronizedFolder(repoInfo, cmis, activityListener))
                using (Watcher watcher = new Watcher(localDirectory))
                {
                    synchronizedFolder.Sync();
                    CleanAll(localDirectory);
                    WatcherTest.WaitWatcher();
                    synchronizedFolder.Sync();
                    Console.WriteLine("Synced to clean state.");

                    ISession session = CreateSession(repoInfo);
                    IFolder folder = (IFolder)session.GetObjectByPath(remoteFolderPath);

                    string name1 = "SyncChangeLog.1";
                    string path1 = Path.Combine(localDirectory, name1);

                    string name2 = "SyncChangeLog.2";
                    string path2 = Path.Combine(localDirectory, name2);

                    //  create heavy folder
                    Console.WriteLine(" Remote create heavy folder");
                    Assert.IsFalse(Directory.Exists(path1));
                    IFolder folder1 = CreateFolder(folder, name1);
                    Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder, delegate
                    {
                        return Directory.Exists(path1);
                    }));
                    Assert.IsTrue(Directory.Exists(path1));
                    CreateHeavyFolderRemote(folder1);
                    Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder, delegate
                    {
                        return CheckHeavyFolder(path1);
                    }));
                    Assert.IsTrue(CheckHeavyFolder(path1));

                    //  rename heavy folder
                    Console.WriteLine(" Remote rename heavy folder");
                    IFolder folder2 = RenameFolder(folder1, name2);
                    Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder, delegate
                    {
                        return CheckHeavyFolder(path2);
                    }));
                    Assert.IsTrue(CheckHeavyFolder(path2));

                    //  move heavy folder
                    Console.WriteLine(" Remote move heavy folder");
                    folder1 = CreateFolder(folder, name1);
                    folder2.Move(folder, folder1);
                    Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder, delegate
                    {
                        return CheckHeavyFolder(Path.Combine(path1,name2));
                    }));
                    Assert.IsTrue(CheckHeavyFolder(Path.Combine(path1, name2)));

                    //  delete heavy folder
                    Console.WriteLine(" Remote delete heavy folder");
                    folder1.DeleteTree(true, null, true);
                    Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder, delegate
                    {
                        return !Directory.Exists(path1);
                    }));
                    Assert.IsFalse(Directory.Exists(path1));

                    // Clean.
                    Console.WriteLine("Clean all.");
                    Clean(localDirectory, synchronizedFolder);
                }
            }
        }
Exemple #7
0
        public void ResumeBigFile(string canonical_name, string localPath, string remoteFolderPath,
            string url, string user, string password, string repositoryId)
        {
            // Prepare checkout directory.
            string localDirectory = Path.Combine(CMISSYNCDIR, canonical_name);
            string canonical_name2 = canonical_name + ".BigFile";
            string localDirectory2 = Path.Combine(CMISSYNCDIR, canonical_name2);
            CleanDirectory(localDirectory);
            CleanDirectory(localDirectory2);
            Console.WriteLine("Synced to clean state.");

            string filename = "ResumeBigFile.File";
            int fileSizeInMB = 10;
            string file = Path.Combine(localDirectory, filename);
            string file2 = Path.Combine(localDirectory2, filename);

            // Mock.
            IActivityListener activityListener = new Mock<IActivityListener>().Object;
            // Sync.
            RepoInfo repoInfo = new RepoInfo(
                    canonical_name,
                    CMISSYNCDIR,
                    remoteFolderPath,
                    url,
                    user,
                    password,
                    repositoryId,
                    5000,
                    false,
                    DateTime.MinValue,
                    true);
            repoInfo.ChunkSize = 1024 * 1024;
            RepoInfo repoInfo2 = new RepoInfo(
                    canonical_name2,
                    CMISSYNCDIR,
                    remoteFolderPath,
                    url,
                    user,
                    password,
                    repositoryId,
                    5000,
                    false,
                    DateTime.MinValue,
                    true);
            repoInfo2.ChunkSize = 1024 * 1024;

            using (CmisRepo cmis = new CmisRepo(repoInfo, activityListener))
            using (CmisRepo.SynchronizedFolder synchronizedFolder =
                    new CmisRepo.SynchronizedFolder(repoInfo, cmis, activityListener))
            {
                synchronizedFolder.resetFailedOperationsCounter();
                synchronizedFolder.Sync();
                CleanAll(localDirectory);
                WatcherTest.WaitWatcher();
                synchronizedFolder.Sync();
                Console.WriteLine("Synced to clean state.");
            }

            //  create file
            byte[] data = new byte[1024 * 1024];
            new Random().NextBytes(data);
            using (FileStream stream = File.OpenWrite(file))
            {
                for (int i = 0; i < fileSizeInMB; i++)
                {
                    stream.Write(data, 0, data.Length);
                }
            }
            string remoteFilePath = (remoteFolderPath + "/" + filename).Replace("//", "/");

            Console.WriteLine(String.Format("Upload big file size: {0}MB", fileSizeInMB));
            for (int currentFileSizeInMB = 0, retry = 0; currentFileSizeInMB < fileSizeInMB && retry < 100; ++retry)
            {
                using (CmisRepo cmis = new CmisRepo(repoInfo, activityListener))
                using (CmisRepo.SynchronizedFolder synchronizedFolder =
                    new CmisRepo.SynchronizedFolder(repoInfo, cmis, activityListener))
                {
                    //  disable the chunk upload
                    //synchronizedFolder.SyncInBackground();
                    //System.Threading.Thread.Sleep(1000);
                    synchronizedFolder.Sync();
                }

                try
                {
                    IDocument doc = (IDocument)CreateSession(repoInfo).GetObjectByPath(remoteFilePath);
                    long fileSize = doc.ContentStreamLength ?? 0;
                    Assert.IsTrue(0 == fileSize % (1024 * 1024));
                    currentFileSizeInMB = (int)(fileSize / 1024 / 1024);
                }
                catch (Exception)
                {
                }
                Console.WriteLine("Upload big file, current size: {0}MB", currentFileSizeInMB);
            }

            Console.WriteLine(String.Format("Download big file size: {0}MB", fileSizeInMB));
            for (int currentFileSizeInMB = 0, retry = 0; currentFileSizeInMB < fileSizeInMB && retry < 100; ++retry)
            {
                using (CmisRepo cmis2 = new CmisRepo(repoInfo2, activityListener))
                using (CmisRepo.SynchronizedFolder synchronizedFolder2 =
                    new CmisRepo.SynchronizedFolder(repoInfo2, cmis2, activityListener))
                {
                    synchronizedFolder2.SyncInBackground(true);
                    System.Threading.Thread.Sleep(1000);
                }

                string file2Tmp = file2 + ".sync";
                FileInfo info = new FileInfo(file2);
                FileInfo infoTmp = new FileInfo(file2Tmp);
                if (infoTmp.Exists)
                {
                    currentFileSizeInMB = (int)(infoTmp.Length / 1024 / 1024);
                }
                else if (info.Exists)
                {
                    currentFileSizeInMB = (int)(info.Length / 1024 / 1024);
                }
                Console.WriteLine("Download big file, current size: {0}MB", currentFileSizeInMB);
            }

            string checksum1 = Database.Checksum(file);
            string checksum2 = Database.Checksum(file2);
            Assert.IsTrue(checksum1 == checksum2);

            using (CmisRepo cmis2 = new CmisRepo(repoInfo2, activityListener))
            using (CmisRepo.SynchronizedFolder synchronizedFolder2 =
                    new CmisRepo.SynchronizedFolder(repoInfo2, cmis2, activityListener))
            {
                // Clean.
                Console.WriteLine("Clean all.");
                Clean(localDirectory2, synchronizedFolder2);
            }
        }
Exemple #8
0
        public void SyncUploads(string canonical_name, string localPath, string remoteFolderPath,
            string url, string user, string password, string repositoryId)
        {
                        // Prepare checkout directory.
            string localDirectory = Path.Combine(CMISSYNCDIR, canonical_name);
            CleanDirectory(localDirectory);
            Console.WriteLine("Synced to clean state.");

            // Mock.
            IActivityListener activityListener = new Mock<IActivityListener>().Object;
            // Sync.
            RepoInfo repoInfo = new RepoInfo(
                    canonical_name,
                    CMISSYNCDIR,
                    remoteFolderPath,
                    url,
                    user,
                    password,
                    repositoryId,
                    5000,
                    false,
                    DateTime.MinValue,
                    true);

            using (CmisRepo cmis = new CmisRepo(repoInfo, activityListener))
            {
                using (CmisRepo.SynchronizedFolder synchronizedFolder =
                    new CmisRepo.SynchronizedFolder(repoInfo, cmis, activityListener))
                using (Watcher watcher = new Watcher(localDirectory))
                {
                    // Clear local and remote folder
                    synchronizedFolder.Sync();
                    CleanAll(localDirectory);
                    WatcherTest.WaitWatcher();
                    synchronizedFolder.Sync();
                    // Create a list of file names
                    List<string> files = new List<string>();
                    for(int i = 1 ; i <= 10; i++) {
                        string filename =  String.Format("file{0}.bin", i.ToString());
                        files.Add(filename);
                    }
                    // Sizes of the files
                    int[] sizes = {1024, 2048, 324, 3452, 0, 43256};
                    // Create and modify all files and start syncing to ensure that any local modification is uploaded correctly
                    foreach ( int length in sizes )
                    {
                        foreach(string filename in files)
                        {
                            createOrModifyBinaryFile(Path.Combine(localDirectory, filename), length);
                        }
                        // Ensure, all local files are available
                        Assert.AreEqual(files.Count, Directory.GetFiles(localDirectory).Length);
                        // Sync until all remote files do have got the same content length like the local one
                        Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder, delegate {
                            foreach(string filename in files)
                            {
                                try{
                                    string remoteFilePath = (remoteFolderPath + "/" + filename).Replace("//", "/");
                                    IDocument d = (IDocument)CreateSession(repoInfo).GetObjectByPath(remoteFilePath);
                                    if(d == null || d.ContentStreamLength != length)
                                        return false;
                                }catch(Exception)
                                {return false;}
                            }
                            return true;
                        }));
                        // Check, if all local files are available
                        Assert.AreEqual(files.Count, Directory.GetFiles(localDirectory).Length);
                    }
                }
            }
        }
Exemple #9
0
        public void ClientSideBigFileAddition(string canonical_name, string localPath, string remoteFolderPath,
            string url, string user, string password, string repositoryId)
        {
            // Prepare checkout directory.
            string localDirectory = Path.Combine(CMISSYNCDIR, canonical_name);
            CleanDirectory(localDirectory);
            Console.WriteLine("Synced to clean state.");

            IActivityListener activityListener = new Mock<IActivityListener>().Object;
            RepoInfo repoInfo = new RepoInfo(
                    canonical_name,
                    CMISSYNCDIR,
                    remoteFolderPath,
                    url,
                    user,
                    password,
                    repositoryId,
                    5000,
                    false,
                    new DateTime(1900, 01, 01),
                    true);

            using (CmisRepo cmis = new CmisRepo(repoInfo, activityListener))
            {
                using (CmisRepo.SynchronizedFolder synchronizedFolder =
                    new CmisRepo.SynchronizedFolder(repoInfo, cmis, activityListener))
                using (Watcher watcher = new Watcher(localDirectory))
                {
                    synchronizedFolder.resetFailedOperationsCounter();
                    synchronizedFolder.Sync();
                    Console.WriteLine("Synced to clean state.");

                    // Create random big file.
                    string filename = LocalFilesystemActivityGenerator.GetNextFileName();
                    string remoteFilePath = (remoteFolderPath + "/" + filename).Replace("//", "/");
                    watcher.EnableRaisingEvents = true;
                    LocalFilesystemActivityGenerator.CreateRandomFile(localDirectory, 1000); // 1 MB ... no that big to not load servers too much.
                    WatcherTest.WaitWatcher((int)repoInfo.PollInterval, watcher, 1);
                    // Sync again.
                    Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder,delegate {
                        try{
                            IDocument d = (IDocument)CreateSession(repoInfo).GetObjectByPath(remoteFilePath);
                            if(d!=null)
                                return true;
                        }catch(Exception)
                        {return false;}
                        return false;
                    }));
                    Console.WriteLine("Second sync done.");
                    // Check that file is present server-side.
                    IDocument doc = (IDocument)CreateSession(repoInfo).GetObjectByPath(remoteFilePath);
                    Assert.NotNull(doc);
                    Assert.AreEqual(filename, doc.ContentStreamFileName);
                    Assert.AreEqual(filename, doc.Name);

                    // Clean.
                    Console.WriteLine("Clean all.");
                    Clean(localDirectory, synchronizedFolder);
                }
            }
        }
Exemple #10
0
        public void SyncEqualityHeavyFolder(string canonical_name, string localPath, string remoteFolderPath,
            string url, string user, string password, string repositoryId)
        {
            // Prepare checkout directory.
            string localDirectory = Path.Combine(CMISSYNCDIR, canonical_name);
            string canonical_name2 = canonical_name + ".equality";
            string localDirectory2 = Path.Combine(CMISSYNCDIR, canonical_name2);
            CleanDirectory(localDirectory);
            CleanDirectory(localDirectory2);
            Console.WriteLine("Synced to clean state.");

            // Mock.
            IActivityListener activityListener = new Mock<IActivityListener>().Object;
            // Sync.
            RepoInfo repoInfo = new RepoInfo(
                    canonical_name,
                    CMISSYNCDIR,
                    remoteFolderPath,
                    url,
                    user,
                    password,
                    repositoryId,
                    5000,
                    false,
                    DateTime.MinValue,
                    true);
            RepoInfo repoInfo2 = new RepoInfo(
                    canonical_name2,
                    CMISSYNCDIR,
                    remoteFolderPath,
                    url,
                    user,
                    password,
                    repositoryId,
                    5000,
                    false,
                    DateTime.MinValue,
                    true);
            using (CmisRepo cmis = new CmisRepo(repoInfo, activityListener))
            using (CmisRepo.SynchronizedFolder synchronizedFolder =
                    new CmisRepo.SynchronizedFolder(repoInfo, cmis, activityListener))
            using (CmisRepo cmis2 = new CmisRepo(repoInfo2, activityListener))
            using (CmisRepo.SynchronizedFolder synchronizedFolder2 =
                    new CmisRepo.SynchronizedFolder(repoInfo2, cmis2, activityListener))
            using (Watcher watcher = new Watcher(localDirectory))
            using (Watcher watcher2 = new Watcher(localDirectory2))
            {
                synchronizedFolder.resetFailedOperationsCounter();
                synchronizedFolder2.resetFailedOperationsCounter();
                synchronizedFolder.Sync();
                synchronizedFolder2.Sync();
                CleanAll(localDirectory);
                CleanAll(localDirectory2);
                WatcherTest.WaitWatcher();
                synchronizedFolder.Sync();
                synchronizedFolder2.Sync();
                Console.WriteLine("Synced to clean state.");

                string oldname = "SyncEquality.Old";
                string newname = "SyncEquality.New";

                //  test heavy folder create
                Console.WriteLine(" Local create heavy folder");
                string oldfolder = Path.Combine(localDirectory, oldname);
                string oldfolder2 = Path.Combine(localDirectory2, oldname);
                Directory.CreateDirectory(oldfolder);
                CreateHeavyFolder(oldfolder);
                Assert.IsTrue(CheckHeavyFolder(oldfolder));
                Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder2, delegate
                {
                    synchronizedFolder.Sync();
                    return CheckHeavyFolder(oldfolder2);
                }, 10));
                Assert.IsTrue(CheckHeavyFolder(oldfolder2));

                //  test heavy folder rename
                Console.WriteLine(" Local rename heavy folder");
                string newfolder = Path.Combine(localDirectory, newname);
                string newfolder2 = Path.Combine(localDirectory2, newname);
                Directory.Move(oldfolder, newfolder);
                Assert.IsTrue(CheckHeavyFolder(newfolder));
                Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder2, delegate
                {
                    synchronizedFolder.Sync();
                    return CheckHeavyFolder(newfolder2);
                }, 10));
                Assert.IsTrue(CheckHeavyFolder(newfolder2));

                //  test heavy folder move
                Console.WriteLine(" Local move heavy folder");
                Directory.CreateDirectory(oldfolder);
                Directory.Move(newfolder,Path.Combine(oldfolder,newname));
                newfolder = Path.Combine(oldfolder, newname);
                newfolder2 = Path.Combine(oldfolder2, newname);
                Assert.IsTrue(CheckHeavyFolder(newfolder));
                Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder2, delegate
                {
                    synchronizedFolder.Sync();
                    return CheckHeavyFolder(newfolder2);
                }, 10));
                Assert.IsTrue(CheckHeavyFolder(newfolder2));

                //  test heavy folder delete
                Console.WriteLine(" Local delete heavy folder");
                Directory.Delete(newfolder, true);
                Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder2, delegate
                {
                    synchronizedFolder.Sync();
                    return !Directory.Exists(newfolder2);
                }, 10));
                Assert.IsTrue(!Directory.Exists(newfolder2));

                // Clean.
                Console.WriteLine("Clean all.");
                Clean(localDirectory, synchronizedFolder);
                Clean(localDirectory2, synchronizedFolder2);
            }
        }
Exemple #11
0
        public void SyncEmptyFileEquality(string canonical_name, string localPath, string remoteFolderPath,
            string url, string user, string password, string repositoryId)
        {
            // Prepare checkout directory.
            string localDirectory = Path.Combine(CMISSYNCDIR, canonical_name);
            string canonical_name2 = canonical_name + ".equality";
            string localDirectory2 = Path.Combine(CMISSYNCDIR, canonical_name2);
            CleanDirectory(localDirectory);
            CleanDirectory(localDirectory2);
            Console.WriteLine("Synced to clean state.");

            // Mock.
            IActivityListener activityListener = new Mock<IActivityListener>().Object;
            // Sync.
            RepoInfo repoInfo = new RepoInfo(
                    canonical_name,
                    CMISSYNCDIR,
                    remoteFolderPath,
                    url,
                    user,
                    password,
                    repositoryId,
                    5000,
                    false,
                    DateTime.MinValue,
                    true);
            RepoInfo repoInfo2 = new RepoInfo(
                    canonical_name2,
                    CMISSYNCDIR,
                    remoteFolderPath,
                    url,
                    user,
                    password,
                    repositoryId,
                    5000,
                    false,
                    DateTime.MinValue,
                    true);
            using (CmisRepo cmis = new CmisRepo(repoInfo, activityListener))
            using (CmisRepo.SynchronizedFolder synchronizedFolder =
                    new CmisRepo.SynchronizedFolder(repoInfo, cmis, activityListener))
            using (CmisRepo cmis2 = new CmisRepo(repoInfo2, activityListener))
            using (CmisRepo.SynchronizedFolder synchronizedFolder2 =
                    new CmisRepo.SynchronizedFolder(repoInfo2, cmis2, activityListener))
            using (Watcher watcher = new Watcher(localDirectory))
            using (Watcher watcher2 = new Watcher(localDirectory2))
            {
                synchronizedFolder.resetFailedOperationsCounter();
                synchronizedFolder2.resetFailedOperationsCounter();
                synchronizedFolder.Sync();
                synchronizedFolder2.Sync();
                CleanAll(localDirectory);
                CleanAll(localDirectory2);
                WatcherTest.WaitWatcher();
                synchronizedFolder.Sync();
                synchronizedFolder2.Sync();
                Console.WriteLine("Synced to clean state.");
                string filename = "empty-file.bin";
                string file = Path.Combine(localDirectory, filename);
                string file2 = Path.Combine(localDirectory2, filename);
                watcher.EnableRaisingEvents = true;
                // Writing an empty file to the first local folder
                using(FileStream stream = File.Create(Path.Combine(localDirectory, filename))){
                    stream.Close();
                };
                WatcherTest.WaitWatcher((int)repoInfo.PollInterval, watcher, 1);
                Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder, delegate {
                    return WaitUntilSyncIsDone(synchronizedFolder2, delegate{
                        int files = Directory.GetFiles(localDirectory).Length;
                        int files2 = Directory.GetFiles(localDirectory2).Length;
                        Assert.LessOrEqual(files, 1, String.Format("There are more files ({0}) as has been created in the source repo", files));
                        Assert.LessOrEqual(files2, 1, String.Format("There are more files ({0}) as has been created in the target repo", files));
                        return File.Exists(file) && File.Exists(file2);
                    }, 1);
                    }, 20));
            }
        }
Exemple #12
0
        public void SyncEquality(string canonical_name, string localPath, string remoteFolderPath,
            string url, string user, string password, string repositoryId)
        {
            // Prepare checkout directory.
            string localDirectory = Path.Combine(CMISSYNCDIR, canonical_name);
            string canonical_name2 = canonical_name + ".equality";
            string localDirectory2 = Path.Combine(CMISSYNCDIR, canonical_name2);
            CleanDirectory(localDirectory);
            CleanDirectory(localDirectory2);
            Console.WriteLine("Synced to clean state.");

            // Mock.
            IActivityListener activityListener = new Mock<IActivityListener>().Object;
            // Sync.
            RepoInfo repoInfo = new RepoInfo(
                    canonical_name,
                    CMISSYNCDIR,
                    remoteFolderPath,
                    url,
                    user,
                    password,
                    repositoryId,
                    5000,
                    false,
                    DateTime.MinValue,
                    true);
            RepoInfo repoInfo2 = new RepoInfo(
                    canonical_name2,
                    CMISSYNCDIR,
                    remoteFolderPath,
                    url,
                    user,
                    password,
                    repositoryId,
                    5000,
                    false,
                    DateTime.MinValue,
                    true);
            using (CmisRepo cmis = new CmisRepo(repoInfo, activityListener))
            using (CmisRepo.SynchronizedFolder synchronizedFolder =
                    new CmisRepo.SynchronizedFolder(repoInfo, cmis, activityListener))
            using (CmisRepo cmis2 = new CmisRepo(repoInfo2, activityListener))
            using (CmisRepo.SynchronizedFolder synchronizedFolder2 =
                    new CmisRepo.SynchronizedFolder(repoInfo2, cmis2, activityListener))
            using (Watcher watcher = new Watcher(localDirectory))
            using (Watcher watcher2 = new Watcher(localDirectory2))
            {
                synchronizedFolder.resetFailedOperationsCounter();
                synchronizedFolder2.resetFailedOperationsCounter();
                synchronizedFolder.Sync();
                synchronizedFolder2.Sync();
                CleanAll(localDirectory);
                CleanAll(localDirectory2);
                WatcherTest.WaitWatcher();
                synchronizedFolder.Sync();
                synchronizedFolder2.Sync();
                Console.WriteLine("Synced to clean state.");

                //  create file
                // remote filename = /SyncEquality.File
                Console.WriteLine("create file test.");
                string filename = "SyncEquality.File";
                string file = Path.Combine(localDirectory, filename);
                string file2 = Path.Combine(localDirectory2, filename);
                Assert.IsFalse(File.Exists(file));
                Assert.IsFalse(File.Exists(file2));
                watcher.EnableRaisingEvents = true;
                int length = 1024;
                using (Stream stream = File.OpenWrite(file))
                {
                    byte[] content = new byte[length];
                    stream.Write(content, 0, content.Length);
                }
                Assert.IsTrue(File.Exists(file));
                Assert.IsFalse(File.Exists(file2));
                WatcherTest.WaitWatcher((int)repoInfo2.PollInterval, watcher, 1);
                watcher.EnableRaisingEvents = false;
                watcher.RemoveAll();
                synchronizedFolder.Sync();
                Assert.IsTrue(File.Exists(file));
                Assert.IsFalse(File.Exists(file2));
                Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder2, delegate {
                        FileInfo info = new FileInfo(file2);
                        return info.Exists && info.Length == length;
                    }));
                Assert.IsTrue(File.Exists(file));
                Assert.IsTrue(File.Exists(file2));

                //  create folder
                // remote folder name = /SyncEquality.Folder
                Console.WriteLine("create folder test.");
                string foldername = "SyncEquality.Folder";
                string folder = Path.Combine(localDirectory, foldername);
                string folder2 = Path.Combine(localDirectory2, foldername);
                Assert.IsFalse(Directory.Exists(folder));
                Assert.IsFalse(Directory.Exists(folder2));
                watcher.EnableRaisingEvents = true;
                Directory.CreateDirectory(folder);
                Assert.IsTrue(Directory.Exists(folder));
                Assert.IsFalse(Directory.Exists(folder2));
                WatcherTest.WaitWatcher((int)repoInfo2.PollInterval, watcher, 1);
                watcher.EnableRaisingEvents = false;
                watcher.RemoveAll();
                synchronizedFolder.Sync();
                Assert.IsTrue(Directory.Exists(folder));
                Assert.IsFalse(Directory.Exists(folder2));
                Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder2, delegate {
                        return Directory.Exists(folder2);
                    }));
                Assert.IsTrue(Directory.Exists(folder));
                Assert.IsTrue(Directory.Exists(folder2));

                //  move file
                // /SyncEquality.File -> /SyncEquality.Folder/SyncEquality.File
                Console.WriteLine("move file test.");
                string source = file;
                file = Path.Combine(folder, filename);
                file2 = Path.Combine(folder2, filename);
                Assert.IsFalse(File.Exists(file));
                Assert.IsFalse(File.Exists(file2));
                watcher.EnableRaisingEvents = true;
                File.Move(source, file);
                Assert.IsTrue(File.Exists(file));
                Assert.IsFalse(File.Exists(file2));
                WatcherTest.WaitWatcher((int)repoInfo2.PollInterval, watcher, 1);
                watcher.EnableRaisingEvents = false;
                watcher.RemoveAll();
                synchronizedFolder.Sync();
                Assert.IsTrue(File.Exists(file));
                Assert.IsFalse(File.Exists(file2));
                Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder2, delegate {
                        return File.Exists(file2);
                    }));
                Assert.IsTrue(File.Exists(file));
                Assert.IsTrue(File.Exists(file2));

                //  move folder
                // create a folder as move target = /SyncEquality.Folder.2/
                Console.WriteLine("move folder test.");
                string foldername2 = "SyncEquality.Folder.2";
                folder = Path.Combine(localDirectory, foldername2);
                folder2 = Path.Combine(localDirectory2, foldername2);
                Assert.IsFalse(Directory.Exists(folder));
                Assert.IsFalse(Directory.Exists(folder2));
                watcher.EnableRaisingEvents = true;
                Directory.CreateDirectory(folder);
                Assert.IsTrue(Directory.Exists(folder));
                Assert.IsFalse(Directory.Exists(folder2));
                WatcherTest.WaitWatcher((int)repoInfo2.PollInterval, watcher, 1);
                watcher.EnableRaisingEvents = false;
                watcher.RemoveAll();
                synchronizedFolder.Sync();
                Assert.IsTrue(Directory.Exists(folder));
                Assert.IsFalse(Directory.Exists(folder2));
                Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder2, delegate {
                        return Directory.Exists(folder2);
                    }));
                Assert.IsTrue(Directory.Exists(folder));
                Assert.IsTrue(Directory.Exists(folder2));
                //move to the created folder
                // moved folder = /SyncEquality.Folder/
                // target folder = /SyncEquality.Folder.2/
                // result = /SyncEquality.Folder.2/SyncEquality.Folder/
                file = Path.Combine(folder, foldername, filename);
                file2 = Path.Combine(folder2, foldername, filename);
                Assert.IsFalse(File.Exists(file));
                Assert.IsFalse(File.Exists(file2));
                watcher.EnableRaisingEvents = true;
                Directory.Move(
                    Path.Combine(localDirectory, foldername),
                    Path.Combine(folder, foldername));
                Assert.IsTrue(File.Exists(file));
                Assert.IsFalse(File.Exists(file2));
                WatcherTest.WaitWatcher((int)repoInfo2.PollInterval, watcher, 1);
                watcher.EnableRaisingEvents = false;
                watcher.RemoveAll();
                synchronizedFolder.Sync();
                Assert.IsTrue(File.Exists(file));
                Assert.IsFalse(File.Exists(file2));
                Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder2, delegate {
                        return File.Exists(file2);
                    }));
                Assert.IsTrue(File.Exists(file));
                Assert.IsTrue(File.Exists(file2));

                //change filecontent
                // remote file path = /SyncEquality.Folder.2/SyncEquality.Folder/SyncEquality.File
                Console.WriteLine("update file test.");
                int filecount = Directory.GetFiles(Path.Combine(folder, foldername)).Count();
                int filecount2 = Directory.GetFiles(Path.Combine(folder2, foldername)).Count();
                length = 2048;
                Assert.IsTrue(filecount == filecount2);
                Assert.IsTrue(filecount == 1);
                Console.WriteLine(" filecontent size = "+ length.ToString());
                watcher.EnableRaisingEvents = true;
                using (Stream stream = File.OpenWrite(file))
                {
                    byte[] content = new byte[length];
                    stream.Write(content, 0, content.Length);
                }
                WatcherTest.WaitWatcher((int)repoInfo2.PollInterval, watcher, 1);
                watcher.EnableRaisingEvents = false;
                watcher.RemoveAll();
                synchronizedFolder.Sync();
                Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder2, delegate {
                    if(filecount2 == Directory.GetFiles(Path.Combine(folder2, foldername)).Count())
                    {
                        FileInfo info = new FileInfo(file2);
                        return info.Exists && info.Length == length;
                    } else {
                        return false;
                    }
                    }, 20));
                Assert.AreEqual(filecount, Directory.GetFiles(Path.Combine(folder, foldername)).Count());
                Assert.AreEqual(filecount2, Directory.GetFiles(Path.Combine(folder2, foldername)).Count());
                Console.WriteLine(" checking file content equality");
                using (Stream stream = File.OpenRead(file))
                using (Stream stream2 = File.OpenRead(file2))
                {
                    Assert.IsTrue(stream.Length == stream2.Length && stream2.Length == length);
                    byte[] content = new byte[length];
                    byte[] content2 = new byte[length];
                    stream.Read(content,0,length);
                    stream.Read(content2,0,length);
                    for(int i = 0; i < length; i++)
                        Assert.AreEqual(content[i], content2[i]);
                }

                //  delete file
                // remote file path = /SyncEquality.Folder.2/SyncEquality.Folder/SyncEquality.File
                Console.WriteLine("delete file test.");
                Assert.IsTrue(File.Exists(file));
                Assert.IsTrue(File.Exists(file2));
                watcher.EnableRaisingEvents = true;
                File.Delete(file);
                Assert.IsFalse(File.Exists(file));
                Assert.IsTrue(File.Exists(file2));
                WatcherTest.WaitWatcher((int)repoInfo2.PollInterval, watcher, 1);
                watcher.EnableRaisingEvents = false;
                watcher.RemoveAll();
                Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder, delegate {
                    return WaitUntilSyncIsDone(synchronizedFolder2, delegate{
                        return !File.Exists(file) && !File.Exists(file2);
                    }, 1);
                    }, 20));
                Assert.IsFalse(File.Exists(file));
                Assert.IsFalse(File.Exists(file2));

                //  delete folder tree
                // delete remote folder = /SyncEquality.Folder.2/
                Console.WriteLine("delete folder tree test.");
                Assert.IsTrue(Directory.Exists(folder));
                Assert.IsTrue(Directory.Exists(folder2));
                watcher.EnableRaisingEvents = true;
                Directory.Delete(folder, true);
                Assert.IsFalse(Directory.Exists(folder));
                Assert.IsTrue(Directory.Exists(folder2));
                WatcherTest.WaitWatcher((int)repoInfo2.PollInterval, watcher, 1);
                watcher.EnableRaisingEvents = false;
                watcher.RemoveAll();
                synchronizedFolder.Sync();
                Assert.IsFalse(Directory.Exists(folder));
                Assert.IsTrue(Directory.Exists(folder2));
                Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder2, delegate {
                        return !Directory.Exists(folder2);
                    }, 20));
                Assert.IsFalse(Directory.Exists(folder));
                Assert.IsFalse(Directory.Exists(folder2));

                // Clean.
                Console.WriteLine("Clean all.");
                Clean(localDirectory, synchronizedFolder);
                Clean(localDirectory2, synchronizedFolder2);
            }
        }
Exemple #13
0
        public void SyncRenamedFiles(string canonical_name, string localPath, string remoteFolderPath,
            string url, string user, string password, string repositoryId)
        {
            // Prepare checkout directory.
            string localDirectory = Path.Combine(CMISSYNCDIR, canonical_name);
            string canonical_name2 = canonical_name + ".equality";
            string localDirectory2 = Path.Combine(CMISSYNCDIR, canonical_name2);
            CleanDirectory(localDirectory);
            CleanDirectory(localDirectory2);
            Console.WriteLine("Synced to clean state.");

            // Mock.
            IActivityListener activityListener = new Mock<IActivityListener>().Object;
            // Sync.
            RepoInfo repoInfo = new RepoInfo(
                    canonical_name,
                    CMISSYNCDIR,
                    remoteFolderPath,
                    url,
                    user,
                    password,
                    repositoryId,
                    5000,
                    false,
                    DateTime.MinValue,
                    true);
            RepoInfo repoInfo2 = new RepoInfo(
                    canonical_name2,
                    CMISSYNCDIR,
                    remoteFolderPath,
                    url,
                    user,
                    password,
                    repositoryId,
                    5000,
                    false,
                    DateTime.MinValue,
                    true);
            using (CmisRepo cmis = new CmisRepo(repoInfo, activityListener))
            using (CmisRepo.SynchronizedFolder synchronizedFolder =
                    new CmisRepo.SynchronizedFolder(repoInfo, cmis, activityListener))
            using (CmisRepo cmis2 = new CmisRepo(repoInfo2, activityListener))
            using (CmisRepo.SynchronizedFolder synchronizedFolder2 =
                    new CmisRepo.SynchronizedFolder(repoInfo2, cmis2, activityListener))
            using (Watcher watcher = new Watcher(localDirectory))
            using (Watcher watcher2 = new Watcher(localDirectory2))
            {
                synchronizedFolder.resetFailedOperationsCounter();
                synchronizedFolder2.resetFailedOperationsCounter();
                synchronizedFolder.Sync();
                synchronizedFolder2.Sync();
                CleanAll(localDirectory);
                CleanAll(localDirectory2);
                WatcherTest.WaitWatcher();
                synchronizedFolder.Sync();
                synchronizedFolder2.Sync();
                Console.WriteLine("Synced to clean state.");

                //  create file
                // remote filename = /SyncEquality.File
                Console.WriteLine("create file test.");
                string filename = "SyncRename.File";
                string file = Path.Combine(localDirectory, filename);
                string file2 = Path.Combine(localDirectory2, filename);
                int localFilesCount = 0;
                int localFilesCount2 = 0;
                Assert.IsFalse(File.Exists(file));
                Assert.IsFalse(File.Exists(file2));
                watcher.EnableRaisingEvents = true;
                int length = 1024;
                using (Stream stream = File.OpenWrite(file))
                {
                    byte[] content = new byte[length];
                    stream.Write(content, 0, content.Length);
                }
                Assert.IsTrue(File.Exists(file));
                Assert.IsFalse(File.Exists(file2));
                WatcherTest.WaitWatcher((int)repoInfo2.PollInterval, watcher, 1);
                watcher.EnableRaisingEvents = false;
                watcher.RemoveAll();
                Assert.IsTrue(File.Exists(file));
                Assert.IsFalse(File.Exists(file2));
                Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder2, delegate {
                    synchronizedFolder.Sync();
                    FileInfo info = new FileInfo(file2);
                    return info.Exists && info.Length == length;
                }), String.Format("The new file \"{0}\"should exist and it should have got the length \"{1}\"", file2, length));
                Assert.IsTrue(File.Exists(file));
                Assert.IsTrue(File.Exists(file2));
                localFilesCount = Directory.GetFiles(localDirectory).Length;
                localFilesCount2 = Directory.GetFiles(localDirectory2).Length;
                Assert.AreEqual(localFilesCount, localFilesCount2, String.Format("Both local folder should contain one file before renaming a file, but there are {0} and {1} files", localFilesCount, localFilesCount2));
                // Only one file should exist
                Assert.AreEqual(1, localFilesCount2, String.Format("There should exist only one file in the local folder before renaming, but there are {0}", localFilesCount2));
                string renamedfilename = "SyncRenameTarget.File";
                string renamedfile = Path.Combine(localDirectory, renamedfilename);
                string renamedfile2 = Path.Combine(localDirectory2, renamedfilename);
                watcher.EnableRaisingEvents = true;
                File.Move(file, renamedfile);
                WatcherTest.WaitWatcher((int) repoInfo2.PollInterval, watcher, 1);
                watcher.EnableRaisingEvents = false;
                watcher.RemoveAll();
                Assert.IsTrue(File.Exists(renamedfile));
                Assert.IsTrue(!File.Exists(renamedfile2));
                Assert.IsTrue(WaitUntilSyncIsDone(synchronizedFolder2, delegate {
                    synchronizedFolder.Sync();
                    FileInfo info = new FileInfo(renamedfile2);
                    return info.Exists && info.Length == length;
                }));
                localFilesCount = Directory.GetFiles(localDirectory).Length;
                localFilesCount2 = Directory.GetFiles(localDirectory2).Length;
                Assert.AreEqual(localFilesCount, localFilesCount2, String.Format("Both local folder should contain one file, but there are {0} and {1} files", localFilesCount, localFilesCount2));
                // Only one file should exist
                Assert.AreEqual(1, localFilesCount2, String.Format("There should exist only one file in the local folder, but there are {0}", localFilesCount2));
            }
        }