Skip to content

Commit 8e27cdc

Browse files
committed
Fixed up SafeObserverTest w.r.t. CompositeException changes
1 parent 3b95e2f commit 8e27cdc

File tree

1 file changed

+36
-31
lines changed

1 file changed

+36
-31
lines changed

rxjava-core/src/test/java/rx/observers/SafeObserverTest.java

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import static org.junit.Assert.assertTrue;
2222
import static org.junit.Assert.fail;
2323

24+
import java.util.List;
2425
import java.util.concurrent.atomic.AtomicReference;
2526

2627
import org.junit.Test;
@@ -109,15 +110,16 @@ public void onErrorFailureSafe() {
109110

110111
Throwable e2 = e.getCause();
111112
assertTrue(e2 instanceof CompositeException);
112-
assertEquals("Chain of Causes for CompositeException In Order Received =>", e2.getCause().getMessage());
113+
List<Throwable> innerExceptions = ((CompositeException) e2).getExceptions();
114+
assertEquals(2, innerExceptions.size());
113115

114-
Throwable e3 = e2.getCause();
115-
assertTrue(e3.getCause() instanceof SafeObserverTestException);
116-
assertEquals("error!", e3.getCause().getMessage());
116+
Throwable e3 = innerExceptions.get(0);
117+
assertTrue(e3 instanceof SafeObserverTestException);
118+
assertEquals("error!", e3.getMessage());
117119

118-
Throwable e4 = e3.getCause();
119-
assertTrue(e4.getCause() instanceof SafeObserverTestException);
120-
assertEquals("onErrorFail", e4.getCause().getMessage());
120+
Throwable e4 = innerExceptions.get(1);
121+
assertTrue(e4 instanceof SafeObserverTestException);
122+
assertEquals("onErrorFail", e4.getMessage());
121123
}
122124
}
123125

@@ -157,15 +159,16 @@ public void onNextOnErrorFailureSafe() {
157159

158160
Throwable e2 = e.getCause();
159161
assertTrue(e2 instanceof CompositeException);
160-
assertEquals("Chain of Causes for CompositeException In Order Received =>", e2.getCause().getMessage());
162+
List<Throwable> innerExceptions = ((CompositeException) e2).getExceptions();
163+
assertEquals(2, innerExceptions.size());
161164

162-
Throwable e3 = e2.getCause();
163-
assertTrue(e3.getCause() instanceof SafeObserverTestException);
164-
assertEquals("onNextFail", e3.getCause().getMessage());
165+
Throwable e3 = innerExceptions.get(0);
166+
assertTrue(e3 instanceof SafeObserverTestException);
167+
assertEquals("onNextFail", e3.getMessage());
165168

166-
Throwable e4 = e3.getCause();
167-
assertTrue(e4.getCause() instanceof SafeObserverTestException);
168-
assertEquals("onErrorFail", e4.getCause().getMessage());
169+
Throwable e4 = innerExceptions.get(1);
170+
assertTrue(e4 instanceof SafeObserverTestException);
171+
assertEquals("onErrorFail", e4.getMessage());
169172
}
170173
}
171174

@@ -251,19 +254,20 @@ public void call() {
251254

252255
Throwable e2 = e.getCause();
253256
assertTrue(e2 instanceof CompositeException);
254-
assertEquals("Chain of Causes for CompositeException In Order Received =>", e2.getCause().getMessage());
257+
List<Throwable> innerExceptions = ((CompositeException) e2).getExceptions();
258+
assertEquals(3, innerExceptions.size());
255259

256-
Throwable e3 = e2.getCause();
257-
assertTrue(e3.getCause() instanceof SafeObserverTestException);
258-
assertEquals("onError failure", e3.getCause().getMessage());
260+
Throwable e3 = innerExceptions.get(0);
261+
assertTrue(e3 instanceof SafeObserverTestException);
262+
assertEquals("onError failure", e3.getMessage());
259263

260-
Throwable e4 = e3.getCause();
261-
assertTrue(e4.getCause() instanceof SafeObserverTestException);
262-
assertEquals("onErrorFail", e4.getCause().getMessage());
264+
Throwable e4 = innerExceptions.get(1);
265+
assertTrue(e4 instanceof SafeObserverTestException);
266+
assertEquals("onErrorFail", e4.getMessage());
263267

264-
Throwable e5 = e4.getCause();
265-
assertTrue(e5.getCause() instanceof SafeObserverTestException);
266-
assertEquals("failure from unsubscribe", e5.getCause().getMessage());
268+
Throwable e5 = innerExceptions.get(2);
269+
assertTrue(e5 instanceof SafeObserverTestException);
270+
assertEquals("failure from unsubscribe", e5.getMessage());
267271
}
268272
}
269273

@@ -292,15 +296,16 @@ public void call() {
292296

293297
Throwable e2 = e.getCause();
294298
assertTrue(e2 instanceof CompositeException);
295-
assertEquals("Chain of Causes for CompositeException In Order Received =>", e2.getCause().getMessage());
299+
List<Throwable> innerExceptions = ((CompositeException) e2).getExceptions();
300+
assertEquals(2, innerExceptions.size());
296301

297-
Throwable e3 = e2.getCause();
298-
assertTrue(e3.getCause() instanceof SafeObserverTestException);
299-
assertEquals("error!", e3.getCause().getMessage());
302+
Throwable e3 = innerExceptions.get(0);
303+
assertTrue(e3 instanceof SafeObserverTestException);
304+
assertEquals("error!", e3.getMessage());
300305

301-
Throwable e4 = e3.getCause();
302-
assertTrue(e4.getCause() instanceof SafeObserverTestException);
303-
assertEquals("failure from unsubscribe", e4.getCause().getMessage());
306+
Throwable e4 = innerExceptions.get(1);
307+
assertTrue(e4 instanceof SafeObserverTestException);
308+
assertEquals("failure from unsubscribe", e4.getMessage());
304309
}
305310
}
306311

0 commit comments

Comments
 (0)