Program: 99288
Project: 99288
Buggy source:
/** 
 * test basic behavior with simple input. expectations: <ul> <li>reads <em>decoded (uncompressed)</em> contents from archive record.</li> <li>calls HttpServletResponse.setHeader() for Content-Type, Content-Length and   {@link TextReplayRenderer#getGuessedCharsetHeader()}.</li> <li>calls HttpServletResponse.setCharsetEncoding() with value "utf-8"</li> </ul>
 * @throws Exception
 */
public void testBasicBehavior() throws Exception {
  final String payload="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  final byte[] payloadBytes=payload.getBytes("String_Node_Str");
  Resource payloadResource=createTestHtmlResource(payloadBytes);
  response.setStatus(200);
  response.setCharacterEncoding("String_Node_Str");
  response.setHeader(EasyMock.eq("String_Node_Str"),EasyMock.<String>notNull());
  response.setHeader(cut.getGuessedCharsetHeader(),"String_Node_Str");
  response.setHeader("String_Node_Str","String_Node_Str");
  response.setHeader(EasyMock.matches("String_Node_Str"),EasyMock.<String>notNull());
  EasyMock.expectLastCall().anyTimes();
  final String ts=result.getCaptureTimestamp();
  final String url1=result.getOriginalUrl() + "String_Node_Str";
  EasyMock.expect(uriConverter.makeReplayURI(ts,url1)).andReturn("String_Node_Str" + ts + "String_Node_Str"+ url1);
  final String url2=result.getOriginalUrl() + "String_Node_Str";
  EasyMock.expect(uriConverter.makeReplayURI(ts,url2)).andReturn("String_Node_Str" + ts + "String_Node_Str"+ url2);
  final String url3=result.getOriginalUrl() + "String_Node_Str";
  EasyMock.expect(uriConverter.makeReplayURI(ts,url3)).andReturn("String_Node_Str" + ts + "String_Node_Str"+ url3);
  EasyMock.expect(uriConverter.makeReplayURI(ts,"String_Node_Str")).andReturn("String_Node_Str");
  EasyMock.replay(response,uriConverter);
  cut.renderResource(null,response,wbRequest,result,payloadResource,payloadResource,uriConverter,null);
  EasyMock.verify(response,uriConverter);
  final String expected="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  String out=servletOutput.getString();
  assertEquals("String_Node_Str",expected,out);
}

Fixed version (ground truth):
/** 
 * test basic behavior with simple input. expectations: <ul> <li>reads <em>decoded (uncompressed)</em> contents from archive record.</li> <li>calls HttpServletResponse.setHeader() for Content-Type, Content-Length and   {@link TextReplayRenderer#getGuessedCharsetHeader()}.</li> <li>calls HttpServletResponse.setCharsetEncoding() with value "utf-8"</li> </ul>
 * @throws Exception
 */
public void testBasicBehavior() throws Exception {
  final String payload="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  final byte[] payloadBytes=payload.getBytes("String_Node_Str");
  Resource payloadResource=createTestHtmlResource(payloadBytes);
  response.setStatus(200);
  response.setCharacterEncoding("String_Node_Str");
  response.setHeader(EasyMock.eq("String_Node_Str"),EasyMock.<String>notNull());
  response.setHeader(cut.getGuessedCharsetHeader(),"String_Node_Str");
  response.setHeader("String_Node_Str","String_Node_Str");
  response.setHeader(EasyMock.matches("String_Node_Str"),EasyMock.<String>notNull());
  EasyMock.expectLastCall().anyTimes();
  final String ts=result.getCaptureTimestamp();
  final String url1=result.getOriginalUrl() + "String_Node_Str";
  EasyMock.expect(uriConverter.makeReplayURI(ts,url1)).andReturn("String_Node_Str" + ts + "String_Node_Str"+ url1);
  final String url2=result.getOriginalUrl() + "String_Node_Str";
  EasyMock.expect(uriConverter.makeReplayURI(ts,url2)).andReturn("String_Node_Str" + ts + "String_Node_Str"+ url2);
  final String url3=result.getOriginalUrl() + "String_Node_Str";
  EasyMock.expect(uriConverter.makeReplayURI(ts,url3)).andReturn("String_Node_Str" + ts + "String_Node_Str"+ url3);
  EasyMock.expect(uriConverter.makeReplayURI(ts,"String_Node_Str")).andReturn("String_Node_Str");
  EasyMock.replay(response,uriConverter);
  cut.renderResource(null,response,wbRequest,result,payloadResource,payloadResource,uriConverter,null);
  EasyMock.verify(response,uriConverter);
  final String expected="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  String out=servletOutput.getString();
  Assert.assertTrue(out.startsWith(expected));
}