public void testOneResult() throws Exception { FitProtocol.writeData(result1.toString(), output); FitProtocol.writeCounts(new Counts(0, 0, 0, 0), output); responder.processResults(input); assertEquals(1, formatter.results.size()); assertEquals(result1.toString(), formatter.results.get(0).toString()); }
public void testMakeResponse() throws Exception { MockRequest request = new MockRequest(); ByteArrayOutputStream output = new ByteArrayOutputStream(); FitProtocol.writeData(result1.toString(), output); FitProtocol.writeData(result2.toString(), output); FitProtocol.writeCounts(new Counts(5, 5, 5, 5), output); request.addInput("results", output.toString()); Response response = responder.makeResponse(context, request); MockResponseSender sender = new MockResponseSender(); sender.doSending(response); String content = sender.sentData(); assertSubString("Mock Results", content); }
public void testFinalCounts() throws Exception { FitProtocol.writeData(result1.toString(), output); Counts counts = new Counts(1, 2, 3, 4); FitProtocol.writeCounts(counts, output); responder.processResults(input); TestSummary summary = formatter.finalSummary; assertEquals(counts.right, summary.getRight()); assertEquals(counts.wrong, summary.getWrong()); assertEquals(counts.ignores, summary.getIgnores()); assertEquals(counts.exceptions, summary.getExceptions()); }
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); }