Program: 34402
Project: 34402
Buggy source:
public void testTemplateWizardCopiesItsPropertiesToMapForOverridenEntryOnMoreEntries() throws Exception {
  LocalFileSystem fs=new LocalFileSystem();
  fs.setRootDirectory(getWorkDir());
  FileObject root=fs.getRoot();
  FileObject fo=FileUtil.createData(root,"String_Node_Str");
  FileObject fo2=FileUtil.createData(root,"String_Node_Str");
  fo.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR,"String_Node_Str");
  fo2.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR,"String_Node_Str");
  Charset set=Charset.forName("String_Node_Str");
  OutputStream os=fo2.getOutputStream();
  OutputStreamWriter w=new OutputStreamWriter(os,set);
  String txt="String_Node_Str";
  w.write(txt);
  w.close();
  DataObject obj=DataObject.find(fo);
  assertEquals(TwoPartObject.class,obj.getClass());
  TwoPartObject tpo=(TwoPartObject)obj;
  tpo.encoding=set;
  FileObject root2=FileUtil.createMemoryFileSystem().getRoot();
  DataFolder folder=DataFolder.findFolder(FileUtil.createFolder(root2,"String_Node_Str"));
  Map<String,String> parameters=Collections.singletonMap("String_Node_Str","String_Node_Str");
  FEQI.fs=root2.getFileSystem();
  FEQI.result=Charset.forName("String_Node_Str");
  DataObject n=obj.createFromTemplate(folder,"String_Node_Str",parameters);
  Integer cnt=TwoPartLoader.queried.get(n.getPrimaryFile());
  assertEquals("String_Node_Str",null,cnt);
  assertEquals("String_Node_Str",folder,n.getFolder());
  assertEquals("String_Node_Str","String_Node_Str",n.getName());
  Iterator<FileObject> it=n.files().iterator();
  it.next();
  FileObject snd=it.next();
  long length=snd.getSize();
  if (length <= 0) {
    fail("String_Node_Str" + length + "String_Node_Str"+ snd);
  }
  InputStream is=snd.getInputStream();
  InputStreamReader r=new InputStreamReader(is,"String_Node_Str");
  char[] cbuf=new char[1024];
  int len=r.read(cbuf);
  if (len == -1) {
    fail("String_Node_Str" + snd);
  }
  String read=new String(cbuf,0,len);
  txt=txt.replaceAll("String_Node_Str","String_Node_Str").replaceAll("String_Node_Str","String_Node_Str") + '\n';
  assertEquals(txt,read);
}

Fixed version (ground truth):
public void testTemplateWizardCopiesItsPropertiesToMapForOverridenEntryOnMoreEntries() throws Exception {
  LocalFileSystem fs=new LocalFileSystem();
  fs.setRootDirectory(getWorkDir());
  FileObject root=fs.getRoot();
  FileObject fo=FileUtil.createData(root,"String_Node_Str");
  FileObject fo2=FileUtil.createData(root,"String_Node_Str");
  fo.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR,"String_Node_Str");
  fo2.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR,"String_Node_Str");
  Charset set=Charset.forName("String_Node_Str");
  OutputStream os=fo2.getOutputStream();
  OutputStreamWriter w=new OutputStreamWriter(os,set);
  String txt="String_Node_Str";
  w.write(txt);
  w.close();
  DataObject obj=DataObject.find(fo);
  assertEquals(TwoPartObject.class,obj.getClass());
  TwoPartObject tpo=(TwoPartObject)obj;
  tpo.encoding=set;
  FileObject root2=FileUtil.createMemoryFileSystem().getRoot();
  DataFolder folder=DataFolder.findFolder(FileUtil.createFolder(root2,"String_Node_Str"));
  Map<String,String> parameters=Collections.singletonMap("String_Node_Str","String_Node_Str");
  FEQI.fs=root2.getFileSystem();
  FEQI.result=Charset.forName("String_Node_Str");
  DataObject n=obj.createFromTemplate(folder,"String_Node_Str",parameters);
  Integer cnt=TwoPartLoader.queried.get(n.getPrimaryFile());
  assertEquals("String_Node_Str",null,cnt);
  assertEquals("String_Node_Str",folder,n.getFolder());
  assertEquals("String_Node_Str","String_Node_Str",n.getName());
  Iterator<FileObject> it=n.files().iterator();
  it.next();
  FileObject snd=it.next();
  long length=snd.getSize();
  if (length <= 0) {
    fail("String_Node_Str" + length + "String_Node_Str"+ snd);
  }
  InputStream is=snd.getInputStream();
  InputStreamReader r=new InputStreamReader(is,"String_Node_Str");
  char[] cbuf=new char[1024];
  int len=r.read(cbuf);
  if (len == -1) {
    fail("String_Node_Str" + snd);
  }
  String read=new String(cbuf,0,len);
  String normRead=read.replace(System.getProperty("String_Node_Str"),"String_Node_Str");
  txt=txt.replaceAll("String_Node_Str","String_Node_Str").replaceAll("String_Node_Str","String_Node_Str") + "String_Node_Str";
  assertEquals(txt,normRead);
}