Program: 133710
Project: 133710
Buggy source:
/** 
 * Tests the IPSWriter
 * @throws IOException 
 * @throws MalformedURLException 
 */
@Test public void checkIPSWriter() throws MalformedURLException, IOException {
  IPSWriter writer=null;
  IPSReader reader=null;
  FileReader fileReader=null;
  String separator=System.getProperty("String_Node_Str");
  String userDir=System.getProperty("String_Node_Str") + separator + "String_Node_Str"+ separator+ "String_Node_Str"+ separator+ "String_Node_Str";
  String outputFilePath=userDir + separator + "String_Node_Str";
  String exampleFilePath=userDir + separator + "String_Node_Str";
  IPath fileIPath=new Path(outputFilePath);
  IPath inputIPath=new Path(exampleFilePath);
  IFile outIFile=ResourcesPlugin.getWorkspace().getRoot().getFile(fileIPath);
  IFile inIFile=ResourcesPlugin.getWorkspace().getRoot().getFile(inputIPath);
  File exampleFile=new File(exampleFilePath);
  File outFile=new File(outputFilePath);
  if (!outFile.exists()) {
    outFile.createNewFile();
  }
  BufferedReader exampleReader=new BufferedReader(new FileReader(exampleFile));
  BufferedReader buffer=new BufferedReader(new FileReader(outFile));
  assertNotNull(buffer);
  try {
    assertTrue(buffer.read() == -1);
  }
 catch (  IOException e) {
    e.printStackTrace();
    fail("String_Node_Str");
  }
  writer=new IPSWriter();
  assertNotNull(writer);
  Form fakeForm=null;
  IFile fakeFile=null;
  writer.write(fakeForm,fakeFile);
  try {
    assertTrue(buffer.read() == -1);
  }
 catch (  IOException e) {
    e.printStackTrace();
    fail("String_Node_Str");
  }
  Form inputForm=null;
  reader=new IPSReader();
  inputForm=reader.read(inIFile);
  assertNotNull(inputForm);
  writer.write(inputForm,outIFile);
  try {
    buffer=new BufferedReader(new FileReader(outFile));
  }
 catch (  IOException e1) {
    e1.printStackTrace();
  }
  int numLines=0;
  try {
    while (buffer.readLine() != null) {
      numLines++;
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
    fail("String_Node_Str");
  }
  assertEquals(113,numLines);
  Form outputForm=reader.read(outIFile);
  ArrayList<Component> components=outputForm.getComponents();
  ArrayList<Component> testComponents=inputForm.getComponents();
  assertEquals(components.size(),testComponents.size());
  for (int i=0; i < components.size(); i++) {
    assertTrue(components.get(i).getName().equals(testComponents.get(i).getName()));
  }
  try {
    buffer.close();
    exampleReader.close();
  }
 catch (  IOException e) {
    e.printStackTrace();
    fail("String_Node_Str");
  }
  if (outFile.exists()) {
    outFile.delete();
  }
  File tempFile=new File(inIFile.getFullPath().toOSString().split("String_Node_Str")[0] + "String_Node_Str");
  if (tempFile.exists())   tempFile.delete();
  Files.copy(exampleFile.toPath(),tempFile.toPath());
  assertTrue(tempFile.exists());
  String replace="String_Node_Str";
  System.out.println("String_Node_Str" + inIFile.getFullPath().toOSString());
  writer.replace(inIFile,"String_Node_Str",replace);
  boolean foundReplacement=false;
  try {
    Scanner scanner=new Scanner(exampleFile);
    while (scanner.hasNextLine()) {
      String line=scanner.nextLine();
      if (line.contains(replace)) {
        foundReplacement=true;
      }
    }
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
  assertTrue(foundReplacement);
  if (exampleFile.exists())   exampleFile.delete();
  Files.copy(tempFile.toPath(),exampleFile.toPath());
  tempFile.delete();
  return;
}

Fixed version (ground truth):
/** 
 * Tests the IPSWriter
 * @throws IOException 
 * @throws MalformedURLException 
 */
@Test public void checkIPSWriter() throws MalformedURLException, IOException {
  IPSWriter writer=null;
  IPSReader reader=null;
  FileReader fileReader=null;
  String separator=System.getProperty("String_Node_Str");
  String userDir=System.getProperty("String_Node_Str") + separator + "String_Node_Str"+ separator+ "String_Node_Str"+ separator+ "String_Node_Str";
  String outputFilePath=userDir + separator + "String_Node_Str";
  String exampleFilePath=userDir + separator + "String_Node_Str";
  IPath fileIPath=new Path(outputFilePath);
  IPath inputIPath=new Path(exampleFilePath);
  IFile outIFile=ResourcesPlugin.getWorkspace().getRoot().getFile(fileIPath);
  IFile inIFile=ResourcesPlugin.getWorkspace().getRoot().getFile(inputIPath);
  File exampleFile=new File(exampleFilePath);
  File outFile=new File(outputFilePath);
  if (!outFile.exists()) {
    outFile.createNewFile();
  }
  BufferedReader exampleReader=new BufferedReader(new FileReader(exampleFile));
  BufferedReader buffer=new BufferedReader(new FileReader(outFile));
  assertNotNull(buffer);
  try {
    assertTrue(buffer.read() == -1);
  }
 catch (  IOException e) {
    e.printStackTrace();
    fail("String_Node_Str");
  }
  writer=new IPSWriter();
  assertNotNull(writer);
  Form fakeForm=null;
  IFile fakeFile=null;
  writer.write(fakeForm,fakeFile);
  try {
    assertTrue(buffer.read() == -1);
  }
 catch (  IOException e) {
    e.printStackTrace();
    fail("String_Node_Str");
  }
  Form inputForm=null;
  reader=new IPSReader();
  inputForm=reader.read(inIFile);
  assertNotNull(inputForm);
  writer.write(inputForm,outIFile);
  try {
    buffer=new BufferedReader(new FileReader(outFile));
  }
 catch (  IOException e1) {
    e1.printStackTrace();
  }
  int numLines=0;
  try {
    while (buffer.readLine() != null) {
      numLines++;
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
    fail("String_Node_Str");
  }
  assertEquals(113,numLines);
  Form outputForm=reader.read(outIFile);
  ArrayList<Component> components=outputForm.getComponents();
  ArrayList<Component> testComponents=inputForm.getComponents();
  assertEquals(components.size(),testComponents.size());
  for (int i=0; i < components.size(); i++) {
    assertTrue(components.get(i).getName().equals(testComponents.get(i).getName()));
  }
  try {
    buffer.close();
    exampleReader.close();
  }
 catch (  IOException e) {
    e.printStackTrace();
    fail("String_Node_Str");
  }
  if (outFile.exists()) {
    outFile.delete();
  }
  File tempFile=new File(inIFile.getFullPath().toOSString().split("String_Node_Str")[0] + "String_Node_Str");
  if (tempFile.exists())   tempFile.delete();
  Files.copy(exampleFile.toPath(),tempFile.toPath());
  assertTrue(tempFile.exists());
  String replace="String_Node_Str";
  System.out.println("String_Node_Str" + inIFile.getFullPath().toOSString());
  writer.replace(inIFile,"String_Node_Str",replace);
  boolean foundReplacement=false;
  try {
    Scanner scanner=new Scanner(exampleFile);
    while (scanner.hasNextLine()) {
      String line=scanner.nextLine();
      if (line.contains(replace)) {
        foundReplacement=true;
      }
    }
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
  assertTrue(foundReplacement);
  if (exampleFile.getAbsoluteFile().exists()) {
    exampleFile.delete();
  }
  Files.copy(tempFile.toPath(),exampleFile.toPath(),StandardCopyOption.REPLACE_EXISTING);
  tempFile.delete();
  return;
}