Beispiel #1
0
        public new void SetUp()
        {
            testServer = new RainyTestServer ();
            testServer.Start ();

            syncServer = new WebSyncServer (testServer.BaseUri, testServer.GetAccessToken ());
        }
        public void SetUp()
        {
            CreateSomeSampleNotes ();

            RainyTestServer.StartNewServer ();

            syncServer = new WebSyncServer (RainyTestServer.BaseUri, RainyTestServer.GetAccessToken ());
        }
Beispiel #3
0
        public void BenchmarkNoteStorage()
        {
            var local_storage = new DiskStorage ("../../tmpstorage");
            var sample_notes = TestBase.GetSampleNotes ();
            var manifest = new SyncManifest ();
            var engine = new Engine (local_storage);
            sample_notes.ForEach(n => engine.SaveNote (n));

            var sync_client = new FilesystemSyncClient (engine, manifest);
            var access_token = WebSyncServer.PerformFastTokenExchange (listenUrl, "testuser", "testpass");
            var sync_server = new WebSyncServer (listenUrl, access_token);

            Action benchmark = () => new SyncManager (sync_client, sync_server).DoSync ();
            DbBenchmarks.RunBenchmark ("initial sync with 100 times no change at all", benchmark, 100);
        }
Beispiel #4
0
        public override void SetUp()
        {
            base.SetUp ();
            DTOUser user;
            List<DTONote> sample_notes;
            JsonServiceClient client = GetAdminServiceClient ();

            user = new DTOUser() {
                Username = "******",
                Password = "******",
                AdditionalData = "Its just john"
            };
            var user_url = new Rainy.WebService.Management.UserRequest ().ToUrl("POST");
            client.Post<DTOUser> (user_url, user);
            sampleUser.Add (user);

            // add sample notes
            sample_notes = AbstractSyncServerTests.GetSomeSampleNotes ()
                .Select (n => n.ToDTONote ()).ToList ();

            var syncServer = new WebSyncServer (testServer.RainyListenUrl, testServer.GetAccessToken ());

            var storage = new DiskStorage ();
            var tmpPath = "/tmp/sync1";
            storage.SetPath (tmpPath);
            var engine = new Engine (storage);
            var syncClient = new FilesystemSyncClient (engine, new SyncManifest ());

            var syncManager = new Tomboy.Sync.SyncManager (syncClient, syncServer);
            syncManager.DoSync ();

            sampleNotes[user.Username] = sample_notes;

            user = new DTOUser() {
                Username = "******",
                Password = "******",
                AdditionalData = "Jane, Johns wife"
            };
            client.Post<DTOUser> (user_url, user);
            sampleUser.Add (user);
            sampleNotes[user.Username] = AbstractSyncServerTests.GetSomeSampleNotes ()
                .Select (n => n.ToDTONote ()).ToList ();

            // add sample user data
        }
		/// <summary>
		/// Syncs the notes.
		/// </summary>
		/// <param name="sender">Sender.</param>
		partial void SyncNotes(NSObject sender) {

			bool success = false;

			if (!String.IsNullOrEmpty (settings.syncURL) || !String.IsNullOrWhiteSpace (settings.syncURL)) {

				var dest_manifest_path = Path.Combine (settings.syncURL, "manifest.xml");
				SyncManifest dest_manifest;
				if (!File.Exists (dest_manifest_path)) {
					using (var output = new FileStream (dest_manifest_path, FileMode.Create)) {
						SyncManifest.Write (new SyncManifest (), output);
					}
				}
				using (var input = new FileStream (dest_manifest_path, FileMode.Open)) {
					dest_manifest = SyncManifest.Read (input);
				}
				var dest_storage = new DiskStorage (settings.syncURL);
				var dest_engine = new Engine (dest_storage);

				var client = new FilesystemSyncClient (NoteEngine, manifestTracker.Manifest);
				var server = new FilesystemSyncServer (dest_engine, dest_manifest);
				new SyncManager(client, server).DoSync ();

				// write back the dest manifest
		        	using (var output = new FileStream (dest_manifest_path, FileMode.Create)) {
					SyncManifest.Write (dest_manifest, output);
				}

				PopulateNotebookList (false);
				RefreshNotesWindowController ();

				success = true;
			}

			else if (!String.IsNullOrEmpty (settings.webSyncURL) ||!String.IsNullOrWhiteSpace (settings.webSyncURL)) {

				ServicePointManager.CertificatePolicy = new DummyCertificateManager();

				OAuthToken reused_token = new OAuthToken { Token = settings.token, Secret = settings.secret };


				ISyncClient client = new FilesystemSyncClient (NoteEngine, manifestTracker.Manifest);
				ISyncServer server = new WebSyncServer (settings.webSyncURL, reused_token);

				new SyncManager (client, server).DoSync ();

				PopulateNotebookList (false);
				RefreshNotesWindowController ();

				success = true;
			}

			if (success) {
				NSAlert alert = new NSAlert () {
					MessageText = "Sync Successful",
					InformativeText = "The sync was successful",
					AlertStyle = NSAlertStyle.Warning
				};
				alert.AddButton ("OK");
				alert.BeginSheet (null);
				alert.Window.Title = "Sync Successful";
			} else {
				NSAlert alert = new NSAlert () {
					MessageText = "Sync Failed",
					InformativeText = "The sync was not successful. Please check the Sync Settings.",
					AlertStyle = NSAlertStyle.Warning
				};
				alert.AddButton ("OK");
				alert.BeginSheet (null);
				alert.Window.Title = "Sync Failed";
			}
        	}
        public new void SetUp()
        {
            RainyTestServer.StartNewServer ();

            syncServer = new WebSyncServer (RainyTestServer.BaseUri, RainyTestServer.GetAccessToken ());
        }