@@ -206,6 +206,8 @@ public void call() {
206206 public static class UnitTest {
207207 @ Mock
208208 Observer <? super String > w ;
209+ @ Mock
210+ Observer <? super String > w2 ;
209211
210212 // nulls lead to exceptions
211213 final Func1 <String , String > TO_UPPER_WITH_EXCEPTION = new Func1 <String , String >() {
@@ -310,6 +312,31 @@ public void testDistinctOfNormalSourceWithKeySelectorAndComparator() {
310312 verify (w , never ()).onError (any (Throwable .class ));
311313 }
312314
315+ @ Test
316+ public void testDistinctOfNormalSourceWithKeySelectorAndComparatorAndTwoSubscriptions () {
317+ Observable <String > src = from ("a" , "x" , "ab" , "abc" , "cba" , "de" , "x" , "a" , "abcd" );
318+ create (distinct (src , TO_UPPER_WITH_EXCEPTION , COMPARE_LENGTH )).subscribe (w );
319+
320+ InOrder inOrder = inOrder (w );
321+ inOrder .verify (w , times (1 )).onNext ("a" );
322+ inOrder .verify (w , times (1 )).onNext ("x" );
323+ create (distinct (src , TO_UPPER_WITH_EXCEPTION , COMPARE_LENGTH )).subscribe (w2 );
324+ inOrder .verify (w , times (1 )).onNext ("abc" );
325+ inOrder .verify (w , times (1 )).onNext ("abcd" );
326+ inOrder .verify (w , times (1 )).onCompleted ();
327+ inOrder .verify (w , never ()).onNext (anyString ());
328+ verify (w , never ()).onError (any (Throwable .class ));
329+
330+ InOrder inOrder2 = inOrder (w2 );
331+ inOrder2 .verify (w2 , times (1 )).onNext ("a" );
332+ inOrder2 .verify (w2 , times (1 )).onNext ("x" );
333+ inOrder2 .verify (w2 , times (1 )).onNext ("abc" );
334+ inOrder2 .verify (w2 , times (1 )).onNext ("abcd" );
335+ inOrder2 .verify (w2 , times (1 )).onCompleted ();
336+ inOrder2 .verify (w2 , never ()).onNext (anyString ());
337+ verify (w2 , never ()).onError (any (Throwable .class ));
338+ }
339+
313340 @ Test
314341 public void testDistinctOfSourceWithNulls () {
315342 Observable <String > src = from (null , "a" , "a" , null , null , "b" , null );
0 commit comments