Skip to content

Commit 7fb3987

Browse files
authored
Merge pull request #4852 from akarnokd/SingleTakeUntilMessage
1.x: Single::takeUntil CancellationException message enh.
2 parents a3f3f94 + 8812756 commit 7fb3987

File tree

4 files changed

+64
-3
lines changed

4 files changed

+64
-3
lines changed

src/main/java/rx/internal/operators/SingleTakeUntilCompletable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void onError(Throwable error) {
8686

8787
@Override
8888
public void onCompleted() {
89-
onError(new CancellationException("Stream was canceled before emitting a terminal event."));
89+
onError(new CancellationException("Single::takeUntil(Completable) - Stream was canceled before emitting a terminal event."));
9090
}
9191
}
9292
}

src/main/java/rx/internal/operators/SingleTakeUntilObservable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void onError(Throwable error) {
9696

9797
@Override
9898
public void onCompleted() {
99-
onError(new CancellationException("Stream was canceled before emitting a terminal event."));
99+
onError(new CancellationException("Single::takeUntil(Observable) - Stream was canceled before emitting a terminal event."));
100100
}
101101
}
102102
}

src/main/java/rx/internal/operators/SingleTakeUntilSingle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void onError(Throwable error) {
8686
final class OtherSubscriber extends SingleSubscriber<U> {
8787
@Override
8888
public void onSuccess(U value) {
89-
onError(new CancellationException("Stream was canceled before emitting a terminal event."));
89+
onError(new CancellationException("Single::takeUntil(Single) - Stream was canceled before emitting a terminal event."));
9090
}
9191

9292
@Override
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* Copyright 2016 Netflix, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package rx.internal.operators;
18+
19+
import java.util.concurrent.CancellationException;
20+
21+
import static org.junit.Assert.*;
22+
import org.junit.Test;
23+
24+
import rx.*;
25+
import rx.observers.AssertableSubscriber;
26+
27+
public class SingleTakeUntilTest {
28+
29+
@Test
30+
public void withSingleMessage() {
31+
AssertableSubscriber<Integer> ts = Single.just(1).takeUntil(Single.just(2))
32+
.test()
33+
.assertFailure(CancellationException.class);
34+
35+
String message = ts.getOnErrorEvents().get(0).getMessage();
36+
37+
assertTrue(message, message.startsWith("Single::takeUntil(Single)"));
38+
}
39+
40+
@Test
41+
public void withCompletableMessage() {
42+
AssertableSubscriber<Integer> ts = Single.just(1).takeUntil(Completable.complete())
43+
.test()
44+
.assertFailure(CancellationException.class);
45+
46+
String message = ts.getOnErrorEvents().get(0).getMessage();
47+
48+
assertTrue(message, message.startsWith("Single::takeUntil(Completable)"));
49+
}
50+
51+
@Test
52+
public void withObservableMessage() {
53+
AssertableSubscriber<Integer> ts = Single.just(1).takeUntil(Observable.just(1))
54+
.test()
55+
.assertFailure(CancellationException.class);
56+
57+
String message = ts.getOnErrorEvents().get(0).getMessage();
58+
59+
assertTrue(message, message.startsWith("Single::takeUntil(Observable)"));
60+
}
61+
}

0 commit comments

Comments
 (0)