private void RunReplication(Replication replication)
        {
            CountDownLatch replicationDoneSignal = new CountDownLatch(1);

            ReplicationTest.ReplicationObserver replicationObserver = new ReplicationTest.ReplicationObserver
                                                                          (this, replicationDoneSignal);
            replication.AddChangeListener(replicationObserver);
            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);
            }
        }
示例#2
0
        public virtual Replication[] CreateReplications()
        {
            Uri syncUrl;

            try
            {
                syncUrl = new Uri(SyncUrl);
            }
            catch (UriFormatException e)
            {
                Log.E(Tag, "Invalid Sync Url", e);
                throw new RuntimeException(e);
            }
            Replication pullRep = database.CreatePullReplication(syncUrl);

            pullRep.SetContinuous(true);
            pullRep.AddChangeListener(GetReplicationChangeListener());
            Replication pushRep = database.CreatePushReplication(syncUrl);

            pushRep.SetContinuous(true);
            pushRep.AddChangeListener(GetReplicationChangeListener());
            return(new Replication[] { pullRep, pushRep });
        }