@@ -4144,7 +4144,7 @@ public void testReplicationRestartPreservesValues() throws Exception {
41444144 * https://github.com/couchbase/couchbase-lite-java-core/issues/383
41454145 */
41464146 public void testContinuousPullReplicationGoesIdleTwice () throws Exception {
4147- Log .e (TAG , "TEST START" );
4147+ Log .d (TAG , "TEST START" );
41484148
41494149 // create mockwebserver and custom dispatcher
41504150 MockDispatcher dispatcher = new MockDispatcher ();
@@ -4197,8 +4197,6 @@ public void testContinuousPullReplicationGoesIdleTwice() throws Exception {
41974197 mockRevsDiff .setSticky (true );
41984198 dispatcher .enqueueResponse (MockHelper .PATH_REGEX_REVS_DIFF , mockRevsDiff );
41994199
4200- Log .e (TAG , "SERVER START" );
4201-
42024200 server .play ();
42034201
42044202 // create pull replication
@@ -4209,16 +4207,14 @@ public void testContinuousPullReplicationGoesIdleTwice() throws Exception {
42094207 pullReplication .addChangeListener (new Replication .ChangeListener () {
42104208 @ Override
42114209 public void changed (Replication .ChangeEvent event ) {
4212- if (event .getTransition ().getDestination () == ReplicationState .IDLE ) {
4213- Log .e (TAG , "Replication is IDLE 1" );
4210+ if (event .getTransition () != null &&
4211+ event .getTransition ().getDestination () == ReplicationState .IDLE ) {
4212+ Log .d (TAG , "Replication is IDLE 1" );
42144213 enteredIdleState1 .countDown ();
4215- pullReplication .removeChangeListener (this );
42164214 }
42174215 }
42184216 });
42194217
4220- Log .e (TAG , "REPLICATOR START" );
4221-
42224218 // 1. start pull replication
42234219 pullReplication .start ();
42244220
@@ -4237,46 +4233,48 @@ public void changed(Replication.ChangeEvent event) {
42374233 pullReplication .addChangeListener (new Replication .ChangeListener () {
42384234 @ Override
42394235 public void changed (Replication .ChangeEvent event ) {
4240- if (event .getTransition ().getDestination () == ReplicationState .RUNNING ) {
4236+ if (event .getTransition () != null &&
4237+ event .getTransition ().getDestination () == ReplicationState .RUNNING ) {
42414238 if (enteredRunningState .getCount () > 0 ) {
4242- Log .e (TAG , "Replication is RUNNING" );
4239+ Log .d (TAG , "Replication is RUNNING" );
42434240 enteredRunningState .countDown ();
42444241 }
42454242 }
42464243 // second IDLE change listener
42474244 // handling IDLE event here. It seems IDLE event was fired before set IDLE event handler
4248- else if (event .getTransition ().getDestination () == ReplicationState .IDLE ) {
4245+ else if (event .getTransition () != null &&
4246+ event .getTransition ().getDestination () == ReplicationState .IDLE ) {
42494247 if (enteredRunningState .getCount () <= 0 && enteredIdleState2 .getCount () > 0 ) {
4250- Log .e (TAG , "Replication is IDLE 2" );
4248+ Log .d (TAG , "Replication is IDLE 2" );
42514249 enteredIdleState2 .countDown ();
42524250 }
42534251 }
42544252 }
42554253 });
42564254
42574255 // 4. wait until its RUNNING
4258- Log .e (TAG , "WAIT for RUNNING" );
4256+ Log .d (TAG , "WAIT for RUNNING" );
42594257 success = enteredRunningState .await (30 , TimeUnit .SECONDS );
42604258 assertTrue (success );
42614259
42624260 // 5. wait until its IDLE again. before the fix, it would never go IDLE again, and so
42634261 // this would timeout and the test would fail.
4264- Log .e (TAG , "WAIT for IDLE" );
4262+ Log .d (TAG , "WAIT for IDLE" );
42654263 success = enteredIdleState2 .await (30 , TimeUnit .SECONDS );
42664264 assertTrue (success );
42674265
4268- Log .e (TAG , "STOP REPLICATOR" );
4266+ Log .d (TAG , "STOP REPLICATOR" );
42694267
42704268 // clean up
42714269 stopReplication (pullReplication );
42724270
4273- Log .e (TAG , "STOP MOCK SERVER" );
4271+ Log .d (TAG , "STOP MOCK SERVER" );
42744272 } finally {
42754273 server .shutdown ();
42764274 }
42774275
42784276
4279- Log .e (TAG , "TEST DONE" );
4277+ Log .d (TAG , "TEST DONE" );
42804278 }
42814279
42824280 /**
@@ -4317,7 +4315,7 @@ public void changed(Replication.ChangeEvent event) {
43174315 enteredIdleState .countDown ();
43184316 } else if (event .getTransition ().getDestination () == ReplicationState .STOPPED ) {
43194317 event .getTransition ().getDestination ();
4320- Log .e (TAG , "Replication is STOPPED" , new Exception ( "HELLO WORLD" ) );
4318+ Log .d (TAG , "Replication is STOPPED" );
43214319 enteredStoppedState .countDown ();
43224320 }
43234321 }
@@ -4450,7 +4448,8 @@ public void testPullReplicatonSendIdleStateAfterCheckPoint() throws Exception {
44504448 pullReplication .addChangeListener (new Replication .ChangeListener () {
44514449 @ Override
44524450 public void changed (Replication .ChangeEvent event ) {
4453- if (event .getTransition ().getDestination () == ReplicationState .IDLE ) {
4451+ if (event .getTransition () != null &&
4452+ event .getTransition ().getDestination () == ReplicationState .IDLE ) {
44544453 pullInitialIdleState .countDown ();
44554454 }
44564455 }
@@ -4475,13 +4474,15 @@ public void changed(Replication.ChangeEvent event) {
44754474 @ Override
44764475 public void changed (Replication .ChangeEvent event ) {
44774476 Log .e (TAG , "[changed] PULL -> " + event );
4478- if (event .getTransition ().getDestination () == ReplicationState .IDLE ) {
4477+ if (event .getTransition () != null &&
4478+ event .getTransition ().getDestination () == ReplicationState .IDLE ) {
44794479 // make sure pull replicator becomes IDLE after ACTIVE state.
44804480 // so ignore any IDLE state before ACTIVE.
44814481 if (runningSignal .getCount () == 0 ) {
44824482 idleSignal .countDown ();
44834483 }
4484- } else if (event .getTransition ().getDestination () == ReplicationState .RUNNING ) {
4484+ } else if (event .getTransition () != null &&
4485+ event .getTransition ().getDestination () == ReplicationState .RUNNING ) {
44854486 runningSignal .countDown ();
44864487 }
44874488 }
@@ -4554,9 +4555,6 @@ public void testPullReplicatonWithManyAttachmentRevisions() throws Exception {
45544555 SavedRevision saved = newRev .save (true );
45554556 String rev2ID = doc .getCurrentRevisionId ();
45564557
4557- Log .w (TAG , "saved => " + saved );
4558- Log .w (TAG , "revID => " + doc .getCurrentRevisionId ());
4559-
45604558 // Create 5 revisions with 50 conflicts each
45614559 int j = 3 ;
45624560 for (; j < 5 ; j ++) {
@@ -4567,7 +4565,6 @@ public void testPullReplicatonWithManyAttachmentRevisions() throws Exception {
45674565 props .put (key , value );
45684566 RevisionInternal leaf = new RevisionInternal (props );
45694567 database .forceInsert (leaf , new ArrayList <String >(), null );
4570- Log .w (TAG , "revID => " + doc .getCurrentRevisionId ());
45714568
45724569 for (int i = 0 ; i < 49 ; i ++) {
45734570 // Create a conflict, won by the new revision:
@@ -4595,7 +4592,6 @@ public void testPullReplicatonWithManyAttachmentRevisions() throws Exception {
45954592 revHistory .add (rev2ID );
45964593 revHistory .add (rev1ID );
45974594 database .forceInsert (leaf_conflict , revHistory , null );
4598- Log .w (TAG , "revID => " + doc .getCurrentRevisionId ());
45994595 }
46004596 }
46014597
@@ -4634,7 +4630,8 @@ public void changed(Replication.ChangeEvent event) {
46344630 if (event .getError () != null ) {
46354631 Assert .fail ("Should not have any error...." );
46364632 }
4637- if (event .getTransition ().getDestination () == ReplicationState .IDLE ) {
4633+ if (event .getTransition () != null &&
4634+ event .getTransition ().getDestination () == ReplicationState .IDLE ) {
46384635 idleSignal1 .countDown ();
46394636 idleSignal2 .countDown ();
46404637 }
0 commit comments