/// <exception cref="System.Exception"></exception>
        public virtual void TestFetchRemoteCheckpointDoc()
        {
            HttpClientFactory mockHttpClientFactory = new _HttpClientFactory_583();

            Log.D("TEST", "testFetchRemoteCheckpointDoc() called");
            string dbUrlString = "http://fake.test-url.com:4984/fake/";
            Uri    remote      = new Uri(dbUrlString);

            database.SetLastSequence("1", remote, true);
            // otherwise fetchRemoteCheckpoint won't contact remote
            Replication replicator = new Pusher(database, remote, false, mockHttpClientFactory
                                                , manager.GetWorkExecutor());
            CountDownLatch doneSignal = new CountDownLatch(1);

            ReplicationTest.ReplicationObserver replicationObserver = new ReplicationTest.ReplicationObserver
                                                                          (this, doneSignal);
            replicator.AddChangeListener(replicationObserver);
            replicator.FetchRemoteCheckpointDoc();
            Log.D(Tag, "testFetchRemoteCheckpointDoc() Waiting for replicator to finish");
            try
            {
                bool succeeded = doneSignal.Await(300, TimeUnit.Seconds);
                NUnit.Framework.Assert.IsTrue(succeeded);
                Log.D(Tag, "testFetchRemoteCheckpointDoc() replicator finished");
            }
            catch (Exception e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
            }
            string errorMessage = "Since we are passing in a mock http client that always throws "
                                  + "errors, we expect the replicator to be in an error state";

            NUnit.Framework.Assert.IsNotNull(errorMessage, replicator.GetLastError());
        }
예제 #2
0
 public _RemoteRequestCompletionBlock_414(Pusher _enclosing, RevisionList changes,
                                          int numDocsToSend)
 {
     this._enclosing    = _enclosing;
     this.changes       = changes;
     this.numDocsToSend = numDocsToSend;
 }
        public virtual void TestBuildRelativeURLStringWithLeadingSlash()
        {
            string      dbUrlString       = "http://10.0.0.3:4984/todos/";
            Replication replicator        = new Pusher(null, new Uri(dbUrlString), false, null);
            string      relativeUrlString = replicator.BuildRelativeURLString("/foo");
            string      expected          = "http://10.0.0.3:4984/todos/foo";

            NUnit.Framework.Assert.AreEqual(expected, relativeUrlString);
        }
예제 #4
0
 internal Replication ReplicationWithDatabase(Database db, Uri remote, bool push, 
     bool create, bool start)
 {
     foreach (Replication replicator in replications)
     {
         if (replicator.GetLocalDatabase() == db && replicator.GetRemoteUrl().Equals(remote
             ) && replicator.IsPull() == !push)
         {
             return replicator;
         }
     }
     if (!create)
     {
         return null;
     }
     Replication replicator_1 = null;
     bool continuous = false;
     if (push)
     {
         replicator_1 = new Pusher(db, remote, continuous, GetWorkExecutor());
     }
     else
     {
         replicator_1 = new Puller(db, remote, continuous, GetWorkExecutor());
     }
     replications.AddItem(replicator_1);
     if (start)
     {
         replicator_1.Start();
     }
     return replicator_1;
 }
 public virtual void TestBuildRelativeURLStringWithLeadingSlash()
 {
     string dbUrlString = "http://10.0.0.3:4984/todos/";
     Replication replicator = new Pusher(null, new Uri(dbUrlString), false, null);
     string relativeUrlString = replicator.BuildRelativeURLString("/foo");
     string expected = "http://10.0.0.3:4984/todos/foo";
     Assert.AreEqual(expected, relativeUrlString);
 }
예제 #6
0
		/// <exception cref="System.Exception"></exception>
		public virtual void TestFetchRemoteCheckpointDoc()
		{
			HttpClientFactory mockHttpClientFactory = new _HttpClientFactory_583();
			Log.D("TEST", "testFetchRemoteCheckpointDoc() called");
			string dbUrlString = "http://fake.test-url.com:4984/fake/";
			Uri remote = new Uri(dbUrlString);
			database.SetLastSequence("1", remote, true);
			// otherwise fetchRemoteCheckpoint won't contact remote
			Replication replicator = new Pusher(database, remote, false, mockHttpClientFactory
				, manager.GetWorkExecutor());
			CountDownLatch doneSignal = new CountDownLatch(1);
			ReplicationTest.ReplicationObserver replicationObserver = new ReplicationTest.ReplicationObserver
				(this, doneSignal);
			replicator.AddChangeListener(replicationObserver);
			replicator.FetchRemoteCheckpointDoc();
			Log.D(Tag, "testFetchRemoteCheckpointDoc() Waiting for replicator to finish");
			try
			{
				bool succeeded = doneSignal.Await(300, TimeUnit.Seconds);
				NUnit.Framework.Assert.IsTrue(succeeded);
				Log.D(Tag, "testFetchRemoteCheckpointDoc() replicator finished");
			}
			catch (Exception e)
			{
				Sharpen.Runtime.PrintStackTrace(e);
			}
			string errorMessage = "Since we are passing in a mock http client that always throws "
				 + "errors, we expect the replicator to be in an error state";
			NUnit.Framework.Assert.IsNotNull(errorMessage, replicator.GetLastError());
		}
예제 #7
0
 public _RemoteRequestCompletionBlock_411(Pusher _enclosing)
 {
     this._enclosing = _enclosing;
 }
예제 #8
0
			public _RemoteRequestCompletionBlock_226(Pusher _enclosing, RevisionList inbox, long
				 lastInboxSequence)
			{
				this._enclosing = _enclosing;
				this.inbox = inbox;
				this.lastInboxSequence = lastInboxSequence;
			}
 public _RemoteRequestCompletionBlock_414(Pusher _enclosing, RevisionList changes, 
     int numDocsToSend)
 {
     this._enclosing = _enclosing;
     this.changes = changes;
     this.numDocsToSend = numDocsToSend;
 }
 public _RemoteRequestCompletionBlock_594(Pusher _enclosing, RevisionInternal rev)
 {
     this._enclosing = _enclosing;
     this.rev = rev;
 }
 public _RemoteRequestCompletionBlock_280(Pusher _enclosing, RevisionList changes)
 {
     this._enclosing = _enclosing;
     this.changes = changes;
 }
 /// <exception cref="System.Exception"></exception>
 public virtual void TestBuildRelativeURLString()
 {
     string dbUrlString = "http://10.0.0.3:4984/todos/";
     Replication replicator = new Pusher(database, new Uri(dbUrlString), false, null);
     string relativeUrlString = replicator.BuildRelativeURLString("foo");
     string expected = "http://10.0.0.3:4984/todos/foo";
     NUnit.Framework.Assert.AreEqual(expected, relativeUrlString);
 }
예제 #13
0
 public _RemoteRequestCompletionBlock_594(Pusher _enclosing, RevisionInternal rev)
 {
     this._enclosing = _enclosing;
     this.rev        = rev;
 }
 public virtual void TestBuildRelativeURLStringWithLeadingSlash()
 {
     if (!Boolean.Parse((string)Runtime.Properties["replicationTestsEnabled"]))
     {
         Assert.Inconclusive("Replication tests disabled.");
         return;
     }
     var dbUrlString = "http://10.0.0.3:4984/todos/";
     var replicator = new Pusher(database, new Uri(dbUrlString), false, null);
     string relativeUrlString = replicator.BuildRelativeURLString("/foo");
     string expected = "http://10.0.0.3:4984/todos/foo";
     Assert.AreEqual(expected, relativeUrlString);
 }
예제 #15
0
			public _RemoteRequestCompletionBlock_411(Pusher _enclosing)
			{
				this._enclosing = _enclosing;
			}
        public void TestRunReplicationWithError()
        {
            if (!Boolean.Parse((string)GetProperty("replicationTestsEnabled")))
            {
                Assert.Inconclusive("Replication tests disabled.");
                return;
            }

            var mockHttpClientFactory = new MockHttpClientFactory();
            manager.DefaultHttpClientFactory = mockHttpClientFactory;

            var mockHttpHandler = mockHttpClientFactory.HttpHandler;
            mockHttpHandler.AddResponderFailAllRequests(HttpStatusCode.InternalServerError);

            var dbUrlString = "http://fake.test-url.com:4984/fake/";
            var remote = new Uri(dbUrlString);
            var continuous = false;
            var r1 = new Pusher(database, remote, continuous, mockHttpClientFactory, new TaskFactory(new SingleTaskThreadpoolScheduler()));
            Assert.IsFalse(r1.Continuous);
            RunReplication(r1);

            Assert.AreEqual(ReplicationStatus.Stopped, r1.Status);
            Assert.AreEqual(0, r1.CompletedChangesCount);
            Assert.AreEqual(0, r1.ChangesCount);
            Assert.IsNotNull(r1.LastError);
        }
예제 #17
0
 public _RemoteRequestCompletionBlock_280(Pusher _enclosing, RevisionList changes)
 {
     this._enclosing = _enclosing;
     this.changes    = changes;
 }