Skip to content

Commit

Permalink
Merge pull request #5 from Nosto/chunk_handler_for_functional_tests
Browse files Browse the repository at this point in the history
Add primitive chunk handler for functional tests
  • Loading branch information
timowestnosto committed Nov 5, 2015
2 parents 1495126 + 70ba001 commit c50d3cb
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion framework/src/play/test/FunctionalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import play.Invoker.InvocationContext;

import play.classloading.enhancers.ControllersEnhancer.ControllerInstrumentation;
import play.libs.F;
import play.mvc.ActionInvoker;
import play.mvc.Http;
import play.mvc.Http.Request;
Expand Down Expand Up @@ -339,7 +340,23 @@ public InvocationContext getInvocationContext() {
}

public static Response makeRequest(final Request request) {
Response response = newResponse();
final Response response = newResponse();
response.onWriteChunk(new F.Action<Object>() {
public void invoke(Object chunk) {
byte[] bytes;
try {
if ( chunk instanceof byte[]) {
bytes = (byte[])chunk;
} else {
String message = chunk == null ? "" : chunk.toString();
bytes = message.getBytes(response.encoding);
}
response.out.write(bytes);
} catch (IOException e) {
e.printStackTrace();
}
}
});
makeRequest(request, response);

if (response.status == 302) { // redirect
Expand Down

0 comments on commit c50d3cb

Please sign in to comment.