Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
rchodava committed Apr 11, 2016
1 parent a5ebed3 commit 915c069
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ public class ClientToServerChannelHandlerTest {
@Mock
private ChannelHandlerContext context;

@Captor
private ArgumentCaptor<LastHttpContent> lastContentCaptor;

@Mock
private Route route;

Expand All @@ -49,6 +46,9 @@ public class ClientToServerChannelHandlerTest {
@Captor
private ArgumentCaptor<HttpObject> responseFragmentsCaptor;

@Captor
private ArgumentCaptor<HttpObject> responseStartCaptor;

private void waitForExecutorToFinishAllTasks(ExecutorService executor) throws Exception {
for (int i = 0; i < 5; i++) {
// We submit an empty task and wait for it so that other tasks submitted ahead of this get executed first
Expand Down Expand Up @@ -154,12 +154,12 @@ public void multipeResponseChunksSent() throws Exception {

waitForExecutorToFinishAllTasks(service);

verify(context, times(2)).write(responseFragmentsCaptor.capture());
verify(context).writeAndFlush(lastContentCaptor.capture());
verify(context).write(responseStartCaptor.capture());
verify(context, times(2)).writeAndFlush(responseFragmentsCaptor.capture());

assertEquals(HttpResponseStatus.OK, ((HttpResponse) responseFragmentsCaptor.getAllValues().get(0)).status());
byte[] bytes = new byte[((HttpContent) responseFragmentsCaptor.getAllValues().get(1)).content().readableBytes()];
((HttpContent) responseFragmentsCaptor.getAllValues().get(1)).content().readBytes(bytes);
assertEquals(HttpResponseStatus.OK, ((HttpResponse) responseStartCaptor.getValue()).status());
byte[] bytes = new byte[((HttpContent) responseFragmentsCaptor.getAllValues().get(0)).content().readableBytes()];
((HttpContent) responseFragmentsCaptor.getAllValues().get(0)).content().readBytes(bytes);
assertArrayEquals("Test Content".getBytes(), bytes);
}
}

0 comments on commit 915c069

Please sign in to comment.