/// <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());
        }
Exemplo n.º 2
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());
		}