Skip to content

Commit af215c7

Browse files
committed
build: fix jooby/src/test/java/io/jooby/internal/handler/ChunkedSubscriberTest.java
1 parent 4ca2b4f commit af215c7

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

jooby/src/test/java/io/jooby/internal/handler/ChunkedSubscriberTest.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)