|
21 | 21 | import static org.junit.Assert.assertTrue;
|
22 | 22 | import static org.junit.Assert.fail;
|
23 | 23 |
|
| 24 | +import java.util.List; |
24 | 25 | import java.util.concurrent.atomic.AtomicReference;
|
25 | 26 |
|
26 | 27 | import org.junit.Test;
|
@@ -109,15 +110,16 @@ public void onErrorFailureSafe() {
|
109 | 110 |
|
110 | 111 | Throwable e2 = e.getCause();
|
111 | 112 | 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()); |
113 | 115 |
|
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()); |
117 | 119 |
|
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()); |
121 | 123 | }
|
122 | 124 | }
|
123 | 125 |
|
@@ -157,15 +159,16 @@ public void onNextOnErrorFailureSafe() {
|
157 | 159 |
|
158 | 160 | Throwable e2 = e.getCause();
|
159 | 161 | 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()); |
161 | 164 |
|
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()); |
165 | 168 |
|
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()); |
169 | 172 | }
|
170 | 173 | }
|
171 | 174 |
|
@@ -251,19 +254,20 @@ public void call() {
|
251 | 254 |
|
252 | 255 | Throwable e2 = e.getCause();
|
253 | 256 | 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()); |
255 | 259 |
|
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()); |
259 | 263 |
|
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()); |
263 | 267 |
|
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()); |
267 | 271 | }
|
268 | 272 | }
|
269 | 273 |
|
@@ -292,15 +296,16 @@ public void call() {
|
292 | 296 |
|
293 | 297 | Throwable e2 = e.getCause();
|
294 | 298 | 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()); |
296 | 301 |
|
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()); |
300 | 305 |
|
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()); |
304 | 309 | }
|
305 | 310 | }
|
306 | 311 |
|
|
0 commit comments