コード例 #1
0
  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());
  }
コード例 #2
0
  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);
  }
コード例 #3
0
  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());
  }
コード例 #4
0
 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);
 }