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);
}
}
}