Program: 51463
Project: 51463
Buggy source:
/** 
 * verifies that values containing illegal control chars are base64 encoded, and that the "encoded=true" attribute is set as expected. For example, <value encoded="true" label="Gg==" null="false" selected="false" type="java.lang.String" value="Gg==" /> http://jira.pentaho.com/browse/PRD-3882
 */
public void testEncodedParameterValues() throws Exception {
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  final ParameterContentGenerator contentGenerator=new ParameterContentGenerator();
  final ParameterXmlContentHandler handler=new ParameterXmlContentHandler(contentGenerator,false);
  handler.createParameterContent(baos,"String_Node_Str","String_Node_Str",false,null);
  Document doc=DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
  NodeList list=doc.getElementsByTagName("String_Node_Str");
  doc.getElementsByTagName("String_Node_Str").item(0).getAttributes().item(4);
  String[] expectedVal=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"};
  String[] expectedEncoded=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"};
  for (int i=0; i < 3; i++) {
    String value=((Element)doc.getElementsByTagName("String_Node_Str").item(i)).getAttribute("String_Node_Str");
    Node encoded=((Element)doc.getElementsByTagName("String_Node_Str").item(i)).getAttributeNode("String_Node_Str");
    String label=((Element)doc.getElementsByTagName("String_Node_Str").item(i)).getAttribute("String_Node_Str");
    assertEquals(expectedVal[i],value);
    assertEquals(expectedVal[i],label);
    if (i == 0) {
      assertEquals(null,encoded);
    }
 else {
      assertEquals(expectedEncoded[i],encoded.getTextContent());
    }
  }
}

Fixed version (ground truth):
/** 
 * verifies that values containing illegal control chars are base64 encoded, and that the "encoded=true" attribute is set as expected. For example, <value encoded="true" label="Gg==" null="false" selected="false" type="java.lang.String" value="Gg==" /> http://jira.pentaho.com/browse/PRD-3882
 */
public void testEncodedParameterValues() throws Exception {
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  final ParameterContentGenerator contentGenerator=new ParameterContentGenerator();
  final ParameterXmlContentHandler handler=new ParameterXmlContentHandler(contentGenerator,false);
  handler.createParameterContent(baos,"String_Node_Str","String_Node_Str",false,null);
  Document doc=DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
  NodeList list=doc.getElementsByTagName("String_Node_Str");
  doc.getElementsByTagName("String_Node_Str").item(0).getAttributes().item(4);
  String[] expectedVal=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"};
  String[] expectedLab=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"};
  String[] expectedEncoded=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"};
  for (int i=0; i < 3; i++) {
    String value=((Element)doc.getElementsByTagName("String_Node_Str").item(i)).getAttribute("String_Node_Str");
    Node encoded=((Element)doc.getElementsByTagName("String_Node_Str").item(i)).getAttributeNode("String_Node_Str");
    String label=((Element)doc.getElementsByTagName("String_Node_Str").item(i)).getAttribute("String_Node_Str");
    assertEquals(expectedVal[i],value);
    assertEquals(expectedLab[i],label);
    if (i == 0) {
      assertEquals(null,encoded);
    }
 else {
      assertEquals(expectedEncoded[i],encoded.getTextContent());
    }
  }
}