Skip to content

Commit

Permalink
Fixed up SafeObserverTest w.r.t. CompositeException changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrjacobs committed Jun 25, 2014
1 parent 3b95e2f commit 8e27cdc
Showing 1 changed file with 36 additions and 31 deletions.
67 changes: 36 additions & 31 deletions rxjava-core/src/test/java/rx/observers/SafeObserverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

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

Throwable e2 = e.getCause();
assertTrue(e2 instanceof CompositeException);
assertEquals("Chain of Causes for CompositeException In Order Received =>", e2.getCause().getMessage());
List<Throwable> innerExceptions = ((CompositeException) e2).getExceptions();
assertEquals(2, innerExceptions.size());

Throwable e3 = e2.getCause();
assertTrue(e3.getCause() instanceof SafeObserverTestException);
assertEquals("error!", e3.getCause().getMessage());
Throwable e3 = innerExceptions.get(0);
assertTrue(e3 instanceof SafeObserverTestException);
assertEquals("error!", e3.getMessage());

Throwable e4 = e3.getCause();
assertTrue(e4.getCause() instanceof SafeObserverTestException);
assertEquals("onErrorFail", e4.getCause().getMessage());
Throwable e4 = innerExceptions.get(1);
assertTrue(e4 instanceof SafeObserverTestException);
assertEquals("onErrorFail", e4.getMessage());
}
}

Expand Down Expand Up @@ -157,15 +159,16 @@ public void onNextOnErrorFailureSafe() {

Throwable e2 = e.getCause();
assertTrue(e2 instanceof CompositeException);
assertEquals("Chain of Causes for CompositeException In Order Received =>", e2.getCause().getMessage());
List<Throwable> innerExceptions = ((CompositeException) e2).getExceptions();
assertEquals(2, innerExceptions.size());

Throwable e3 = e2.getCause();
assertTrue(e3.getCause() instanceof SafeObserverTestException);
assertEquals("onNextFail", e3.getCause().getMessage());
Throwable e3 = innerExceptions.get(0);
assertTrue(e3 instanceof SafeObserverTestException);
assertEquals("onNextFail", e3.getMessage());

Throwable e4 = e3.getCause();
assertTrue(e4.getCause() instanceof SafeObserverTestException);
assertEquals("onErrorFail", e4.getCause().getMessage());
Throwable e4 = innerExceptions.get(1);
assertTrue(e4 instanceof SafeObserverTestException);
assertEquals("onErrorFail", e4.getMessage());
}
}

Expand Down Expand Up @@ -251,19 +254,20 @@ public void call() {

Throwable e2 = e.getCause();
assertTrue(e2 instanceof CompositeException);
assertEquals("Chain of Causes for CompositeException In Order Received =>", e2.getCause().getMessage());
List<Throwable> innerExceptions = ((CompositeException) e2).getExceptions();
assertEquals(3, innerExceptions.size());

Throwable e3 = e2.getCause();
assertTrue(e3.getCause() instanceof SafeObserverTestException);
assertEquals("onError failure", e3.getCause().getMessage());
Throwable e3 = innerExceptions.get(0);
assertTrue(e3 instanceof SafeObserverTestException);
assertEquals("onError failure", e3.getMessage());

Throwable e4 = e3.getCause();
assertTrue(e4.getCause() instanceof SafeObserverTestException);
assertEquals("onErrorFail", e4.getCause().getMessage());
Throwable e4 = innerExceptions.get(1);
assertTrue(e4 instanceof SafeObserverTestException);
assertEquals("onErrorFail", e4.getMessage());

Throwable e5 = e4.getCause();
assertTrue(e5.getCause() instanceof SafeObserverTestException);
assertEquals("failure from unsubscribe", e5.getCause().getMessage());
Throwable e5 = innerExceptions.get(2);
assertTrue(e5 instanceof SafeObserverTestException);
assertEquals("failure from unsubscribe", e5.getMessage());
}
}

Expand Down Expand Up @@ -292,15 +296,16 @@ public void call() {

Throwable e2 = e.getCause();
assertTrue(e2 instanceof CompositeException);
assertEquals("Chain of Causes for CompositeException In Order Received =>", e2.getCause().getMessage());
List<Throwable> innerExceptions = ((CompositeException) e2).getExceptions();
assertEquals(2, innerExceptions.size());

Throwable e3 = e2.getCause();
assertTrue(e3.getCause() instanceof SafeObserverTestException);
assertEquals("error!", e3.getCause().getMessage());
Throwable e3 = innerExceptions.get(0);
assertTrue(e3 instanceof SafeObserverTestException);
assertEquals("error!", e3.getMessage());

Throwable e4 = e3.getCause();
assertTrue(e4.getCause() instanceof SafeObserverTestException);
assertEquals("failure from unsubscribe", e4.getCause().getMessage());
Throwable e4 = innerExceptions.get(1);
assertTrue(e4 instanceof SafeObserverTestException);
assertEquals("failure from unsubscribe", e4.getMessage());
}
}

Expand Down

0 comments on commit 8e27cdc

Please sign in to comment.