Exemplo n.º 1
0
        public virtual void RunReplication(Replication replication)
        {
            CountDownLatch replicationDoneSignal = new CountDownLatch(1);

            LiteTestCase.ReplicationFinishedObserver replicationFinishedObserver = new LiteTestCase.ReplicationFinishedObserver
                                                                                       (replicationDoneSignal);
            replication.AddChangeListener(replicationFinishedObserver);
            replication.Start();
            CountDownLatch replicationDoneSignalPolling = ReplicationWatcherThread(replication
                                                                                   );

            Log.D(Tag, "Waiting for replicator to finish");
            try
            {
                bool success = replicationDoneSignal.Await(300, TimeUnit.Seconds);
                NUnit.Framework.Assert.IsTrue(success);
                success = replicationDoneSignalPolling.Await(300, TimeUnit.Seconds);
                NUnit.Framework.Assert.IsTrue(success);
                Log.D(Tag, "replicator finished");
            }
            catch (Exception e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
            }
            replication.RemoveChangeListener(replicationFinishedObserver);
        }
Exemplo n.º 2
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestGetActiveReplications()
        {
            Uri         remote      = GetReplicationURL();
            Replication replication = (Replication)database.CreatePullReplication(remote);

            NUnit.Framework.Assert.AreEqual(0, database.GetAllReplications().Count);
            NUnit.Framework.Assert.AreEqual(0, database.GetActiveReplications().Count);
            replication.Start();
            NUnit.Framework.Assert.AreEqual(1, database.GetAllReplications().Count);
            NUnit.Framework.Assert.AreEqual(1, database.GetActiveReplications().Count);
            CountDownLatch replicationDoneSignal = new CountDownLatch(1);

            LiteTestCase.ReplicationFinishedObserver replicationFinishedObserver = new LiteTestCase.ReplicationFinishedObserver
                                                                                       (replicationDoneSignal);
            replication.AddChangeListener(replicationFinishedObserver);
            bool success = replicationDoneSignal.Await(60, TimeUnit.Seconds);

            NUnit.Framework.Assert.IsTrue(success);
            NUnit.Framework.Assert.AreEqual(1, database.GetAllReplications().Count);
            NUnit.Framework.Assert.AreEqual(0, database.GetActiveReplications().Count);
        }