public Response makeResponse(FitNesseContext context, Request request) throws Exception { init(context, request); String results = (String) request.getInput("results"); byte[] bytes = results.getBytes("UTF-8"); processResults(new ByteArrayInputStream(bytes)); InputStreamResponse response = new InputStreamResponse(); response.setBody(formatter.getResultStream(), formatter.getByteCount()); return response; }
public void processResults(InputStream input) throws Exception { StreamReader reader = new StreamReader(input); boolean readingResults = true; while (readingResults) { int bytesToRead = FitProtocol.readSize(reader); if (bytesToRead != 0) { String resultString = reader.read(bytesToRead); PageResult result = PageResult.parse(resultString); formatter.acceptResult(result); } else readingResults = false; } Counts counts = FitProtocol.readCounts(reader); TestSummary testSummary = new TestSummary(counts.right, counts.wrong, counts.ignores, counts.exceptions); formatter.acceptFinalCount(testSummary); }