2828import java .util .ArrayList ;
2929import java .util .concurrent .CountDownLatch ;
3030import org .hamcrest .MatcherAssert ;
31- import org .junit .Ignore ;
31+ import org .junit .Assert ;
3232import org .junit .Rule ;
3333import org .junit .Test ;
3434import org .junit .rules .ExternalResource ;
@@ -54,7 +54,6 @@ public void testRequestReplyNoError() {
5454 }
5555
5656 @ Test (timeout = 2000 )
57- @ Ignore
5857 public void testHandlerEmitsError () {
5958 rule .setRequestAcceptor (
6059 new AbstractRSocket () {
@@ -66,7 +65,11 @@ public Mono<Payload> requestResponse(Payload payload) {
6665 Subscriber <Payload > subscriber = TestSubscriber .create ();
6766 rule .crs .requestResponse (PayloadImpl .EMPTY ).subscribe (subscriber );
6867 verify (subscriber ).onError (any (ApplicationException .class ));
69- rule .assertNoErrors ();
68+
69+ // Client sees error through normal API
70+ rule .assertNoClientErrors ();
71+
72+ rule .assertServerError ("java.lang.NullPointerException: Deliberate exception." );
7073 }
7174
7275 @ Test (timeout = 2000 )
@@ -149,10 +152,36 @@ public void setRequestAcceptor(RSocket requestAcceptor) {
149152 }
150153
151154 public void assertNoErrors () {
155+ assertNoClientErrors ();
156+ assertNoServerErrors ();
157+ }
158+
159+ public void assertNoClientErrors () {
152160 MatcherAssert .assertThat (
153161 "Unexpected error on the client connection." , clientErrors , is (empty ()));
162+ }
163+
164+ public void assertNoServerErrors () {
154165 MatcherAssert .assertThat (
155166 "Unexpected error on the server connection." , serverErrors , is (empty ()));
156167 }
168+
169+ public void assertClientError (String s ) {
170+ assertError (s , "client" , this .clientErrors );
171+ }
172+
173+ public void assertServerError (String s ) {
174+ assertError (s , "server" , this .serverErrors );
175+ }
176+ }
177+
178+ public static void assertError (String s , String mode , ArrayList <Throwable > errors ) {
179+ for (Throwable t : errors ) {
180+ if (t .toString ().equals (s )) {
181+ return ;
182+ }
183+ }
184+
185+ Assert .fail ("Expected " + mode + " connection error: " + s + " other errors " + errors .size ());
157186 }
158187}
0 commit comments