@@ -146,12 +146,15 @@ void testOnNextExceptionInEncode() throws Exception {
146146 RuntimeException ex = new RuntimeException ("encoder error" );
147147 when (encoder .encode (ctx , item )).thenThrow (ex );
148148
149+ when (ctx .getMethod ()).thenReturn ("GET" );
150+ when (ctx .getRequestPath ()).thenReturn ("/path" );
151+
149152 ChunkedSubscriber sub = new ChunkedSubscriber (ctx );
150153 sub .onSubscribe (subscription );
151154 sub .onNext (item );
152155
156+ verify (subscription ).cancel ();
153157 verify (ctx ).sendError (ex );
154- verify (subscription ).cancel (); // Automatically cancels on exception
155158 }
156159
157160 @ Test
@@ -161,6 +164,9 @@ void testOnNextCallbackError() throws Exception {
161164 when (encoder .encode (ctx , item )).thenReturn (data );
162165 when (mediaType .isJson ()).thenReturn (false );
163166
167+ when (ctx .getMethod ()).thenReturn ("GET" );
168+ when (ctx .getRequestPath ()).thenReturn ("/path" );
169+
164170 ChunkedSubscriber sub = new ChunkedSubscriber (ctx );
165171 sub .onSubscribe (subscription );
166172 sub .onNext (item );
@@ -170,11 +176,10 @@ void testOnNextCallbackError() throws Exception {
170176
171177 Exception ex = new Exception ("write error" );
172178
173- // Simulate write failure (x != null)
174179 captor .getValue ().onComplete (ctx , ex );
175180
176- verify (ctx ).sendError (ex );
177181 verify (subscription ).cancel ();
182+ verify (ctx ).sendError (ex );
178183 }
179184
180185 @ Test
@@ -265,6 +270,9 @@ void testOnCompleteJsonError() throws Exception {
265270 when (encoder .encode (ctx , item )).thenReturn (data );
266271 when (mediaType .isJson ()).thenReturn (true );
267272
273+ when (ctx .getMethod ()).thenReturn ("GET" );
274+ when (ctx .getRequestPath ()).thenReturn ("/path" );
275+
268276 ChunkedSubscriber sub = new ChunkedSubscriber (ctx );
269277 sub .onSubscribe (subscription );
270278 sub .onNext (item );
@@ -276,6 +284,7 @@ void testOnCompleteJsonError() throws Exception {
276284 verify (sender ).write (any (byte [].class ), captor .capture ());
277285
278286 Exception err = new Exception ("complete callback error" );
287+
279288 captor .getValue ().onComplete (ctx , err );
280289
281290 verify (ctx ).sendError (err );
0 commit comments