Program: 11998
Project: 11998
Buggy source:
public void run(IAction action){
  store=getIPreferenceStore();
  Configuration config=getConfiguration(store);
  PropertiesLoader props=getPropertiesLoader(config.language);
  StructuredSelection structuredSelection=null;
  InputStream inputStream=null;
  FileOutputStream outputStream=null;
  OutputStreamWriter writer=null;
  String projectName=null;
  String testCaseFileName=null;
  String testCaseCreateFilePath=null;
  String resourcePathForTargetClassFile=null;
  String resourcePathForTestClassFile=null;
  try {
    if (selection instanceof StructuredSelection) {
      structuredSelection=(StructuredSelection)selection;
    }
    if (isNotSelected(structuredSelection)) {
      openWarningForRequired(props);
      return;
    }
 else     if (isSelectedSeveral(structuredSelection)) {
      openWarningForSelectOneOnly(props);
      return;
    }
    projectName=getProjectName(structuredSelection);
    resourcePathForTargetClassFile=getResourcePathForTargetClassFile(structuredSelection);
    String projectRootAbsolutePath=getWorkspaceRootAbsolutePath(getIWorkspaceRoot()) + StringValue.DirectorySeparator.General + projectName+ StringValue.DirectorySeparator.General;
    resourcePathForTestClassFile=resourcePathForTargetClassFile.replaceFirst(config.directoryPathOfProductSourceCode,config.directoryPathOfTestSourceCode).replace(StringValue.FileExtension.JavaFile,StringValue.JUnit.TestClassNameSuffix + StringValue.FileExtension.JavaFile);
    testCaseCreateFilePath=projectRootAbsolutePath + getResourcePathForTargetClassFile(structuredSelection).replace(config.directoryPathOfProductSourceCode,config.directoryPathOfTestSourceCode).replace(StringValue.FileExtension.JavaFile,StringValue.JUnit.TestClassNameSuffix + StringValue.FileExtension.JavaFile);
    testCaseFileName=(getClassNameFromResourcePathForTargetClassFile(resourcePathForTargetClassFile) + StringValue.FileExtension.JavaFile).replace(StringValue.FileExtension.JavaFile,StringValue.JUnit.TestClassNameSuffix + StringValue.FileExtension.JavaFile);
    String testCaseCreateDirPath=testCaseCreateFilePath.replaceFirst("String_Node_Str","String_Node_Str");
    File testDir=new File(testCaseCreateDirPath);
    String[] dirArr=testCaseCreateDirPath.split(StringValue.DirectorySeparator.General);
    String tmpDirPath=StringValue.Empty;
    String tmpResourceDirPath=StringValue.Empty;
    for (    String each : dirArr) {
      tmpDirPath+=StringValue.DirectorySeparator.General + each;
      File tmpDir=new File(tmpDirPath);
      if (tmpDir.getPath().length() <= projectRootAbsolutePath.length()) {
        continue;
      }
      tmpResourceDirPath+=StringValue.DirectorySeparator.General + each;
      if (!tmpDir.exists()) {
        if (!tmpDir.mkdir()) {
          System.err.println("String_Node_Str" + tmpDir.getPath());
        }
        String parentPathOfCreatedDir=projectName + StringValue.DirectorySeparator.General + tmpResourceDirPath+ "String_Node_Str";
        if (!ResourceRefreshUtil.refreshLocal(null,parentPathOfCreatedDir)) {
          System.err.println("String_Node_Str" + parentPathOfCreatedDir);
        }
      }
    }
    if (!testDir.mkdirs()) {
      System.err.println("String_Node_Str");
    }
    String pathOfTestCaseDir=projectName + StringValue.DirectorySeparator.General + resourcePathForTestClassFile+ "String_Node_Str";
    if (!ResourceRefreshUtil.refreshLocal(null,pathOfTestCaseDir)) {
      openWarningForResourceRefreshError(props);
      return;
    }
    try {
      File outputIOFile=new File(testCaseCreateDirPath + StringValue.DirectorySeparator.General + testCaseFileName);
      String msg=props.get(Dialog.Common.alreadyExist) + "String_Node_Str" + testCaseFileName+ "String_Node_Str"+ StringValue.LineFeed+ props.get(Dialog.Common.confirmToProceed);
      if (outputIOFile.exists() && !openConfirm(props,msg)) {
        return;
      }
      IResource targetClassResource=getIWorkspaceRoot().findMember("String_Node_Str" + projectName + "String_Node_Str"+ resourcePathForTargetClassFile);
      IFile targetClassFile=(IFile)targetClassResource;
      TestCaseGenerator generator=new DefaultTestCaseGenerator(config);
      String encoding=UniversalDetectorUtil.getDetectedEncoding(EclipseIFileUtil.getInputStreamFrom(targetClassFile));
      String sourceCodeString=IOUtil.readAsString(EclipseIFileUtil.getInputStreamFrom(targetClassFile),encoding);
      generator.initialize(new ClassMetaExtractor(config).extract(sourceCodeString));
      outputStream=new FileOutputStream(testCaseCreateDirPath + StringValue.DirectorySeparator.General + testCaseFileName);
      writer=new OutputStreamWriter(outputStream,getDetectedEncodingFrom(targetClassFile,config.outputFileEncoding));
      writer.write(generator.getNewTestCaseSourceCode());
    }
 catch (    InvalidPreferenceException ipe) {
      ipe.printStackTrace();
      openWarning(props,props.get(Dialog.Common.invalidPreference));
      return;
    }
catch (    FileNotFoundException fnfe) {
      fnfe.printStackTrace();
    }
 finally {
      IOUtil.close(writer);
      IOUtil.close(outputStream);
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
 finally {
    IOUtil.close(inputStream);
    IOUtil.close(outputStream);
    IOUtil.close(writer);
  }
  if (!ResourceRefreshUtil.refreshLocal(null,projectName + StringValue.DirectorySeparator.General + resourcePathForTestClassFile+ "String_Node_Str")) {
    openWarningForResourceRefreshError(props);
    System.err.println("String_Node_Str");
    return;
  }
  int retryCount=0;
  IEditorPart editorPart=null;
  ThreadUtil.sleep(1500);
  while (true) {
    try {
      IProject project=getIProject(projectName);
      IFile testCaseFile=getIFile(project,resourcePathForTestClassFile);
      IWorkbenchPage page=getIWorkbenchPage();
      editorPart=getIEditorPart(page,testCaseFile);
      if (editorPart == null) {
        throw new NullPointerException();
      }
      break;
    }
 catch (    Exception e) {
      retryCount++;
      if (retryCount > 3) {
        break;
      }
      ThreadUtil.sleep(1500);
    }
  }
  editorPart.setFocus();
}

Fixed version (ground truth):
public void run(IAction action){
  store=getIPreferenceStore();
  Configuration config=getConfiguration(store,selection);
  PropertiesLoader props=getPropertiesLoader(config.language);
  StructuredSelection structuredSelection=null;
  InputStream inputStream=null;
  FileOutputStream outputStream=null;
  OutputStreamWriter writer=null;
  String projectName=null;
  String testCaseFileName=null;
  String testCaseCreateFilePath=null;
  String resourcePathForTargetClassFile=null;
  String resourcePathForTestClassFile=null;
  try {
    if (selection instanceof StructuredSelection) {
      structuredSelection=(StructuredSelection)selection;
    }
    if (isNotSelected(structuredSelection)) {
      openWarningForRequired(props);
      return;
    }
 else     if (isSelectedSeveral(structuredSelection)) {
      openWarningForSelectOneOnly(props);
      return;
    }
    projectName=getProjectName(structuredSelection);
    resourcePathForTargetClassFile=getResourcePathForTargetClassFile(structuredSelection);
    String projectRootAbsolutePath=getWorkspaceRootAbsolutePath(getIWorkspaceRoot()) + StringValue.DirectorySeparator.General + projectName+ StringValue.DirectorySeparator.General;
    resourcePathForTestClassFile=resourcePathForTargetClassFile.replaceFirst(config.directoryPathOfProductSourceCode,config.directoryPathOfTestSourceCode).replace(StringValue.FileExtension.JavaFile,StringValue.JUnit.TestClassNameSuffix + StringValue.FileExtension.JavaFile);
    testCaseCreateFilePath=projectRootAbsolutePath + getResourcePathForTargetClassFile(structuredSelection).replace(config.directoryPathOfProductSourceCode,config.directoryPathOfTestSourceCode).replace(StringValue.FileExtension.JavaFile,StringValue.JUnit.TestClassNameSuffix + StringValue.FileExtension.JavaFile);
    testCaseFileName=(getClassNameFromResourcePathForTargetClassFile(resourcePathForTargetClassFile) + StringValue.FileExtension.JavaFile).replace(StringValue.FileExtension.JavaFile,StringValue.JUnit.TestClassNameSuffix + StringValue.FileExtension.JavaFile);
    String testCaseCreateDirPath=testCaseCreateFilePath.replaceFirst("String_Node_Str","String_Node_Str");
    File testDir=new File(testCaseCreateDirPath);
    String[] dirArr=testCaseCreateDirPath.split(StringValue.DirectorySeparator.General);
    String tmpDirPath=StringValue.Empty;
    String tmpResourceDirPath=StringValue.Empty;
    for (    String each : dirArr) {
      tmpDirPath+=StringValue.DirectorySeparator.General + each;
      File tmpDir=new File(tmpDirPath);
      if (tmpDir.getPath().length() <= projectRootAbsolutePath.length()) {
        continue;
      }
      tmpResourceDirPath+=StringValue.DirectorySeparator.General + each;
      if (!tmpDir.exists()) {
        if (!tmpDir.mkdir()) {
          System.err.println("String_Node_Str" + tmpDir.getPath());
        }
        String parentPathOfCreatedDir=projectName + StringValue.DirectorySeparator.General + tmpResourceDirPath+ "String_Node_Str";
        if (!ResourceRefreshUtil.refreshLocal(null,parentPathOfCreatedDir)) {
          System.err.println("String_Node_Str" + parentPathOfCreatedDir);
        }
      }
    }
    if (!testDir.mkdirs()) {
      System.err.println("String_Node_Str");
    }
    String pathOfTestCaseDir=projectName + StringValue.DirectorySeparator.General + resourcePathForTestClassFile+ "String_Node_Str";
    if (!ResourceRefreshUtil.refreshLocal(null,pathOfTestCaseDir)) {
      openWarningForResourceRefreshError(props);
      return;
    }
    try {
      File outputIOFile=new File(testCaseCreateDirPath + StringValue.DirectorySeparator.General + testCaseFileName);
      String msg=props.get(Dialog.Common.alreadyExist) + "String_Node_Str" + testCaseFileName+ "String_Node_Str"+ StringValue.LineFeed+ props.get(Dialog.Common.confirmToProceed);
      if (outputIOFile.exists() && !openConfirm(props,msg)) {
        return;
      }
      IResource targetClassResource=getIWorkspaceRoot().findMember("String_Node_Str" + projectName + "String_Node_Str"+ resourcePathForTargetClassFile);
      IFile targetClassFile=(IFile)targetClassResource;
      TestCaseGenerator generator=new DefaultTestCaseGenerator(config);
      String encoding=UniversalDetectorUtil.getDetectedEncoding(EclipseIFileUtil.getInputStreamFrom(targetClassFile));
      String sourceCodeString=IOUtil.readAsString(EclipseIFileUtil.getInputStreamFrom(targetClassFile),encoding);
      generator.initialize(new ClassMetaExtractor(config).extract(sourceCodeString));
      outputStream=new FileOutputStream(testCaseCreateDirPath + StringValue.DirectorySeparator.General + testCaseFileName);
      writer=new OutputStreamWriter(outputStream,getDetectedEncodingFrom(targetClassFile,config.outputFileEncoding));
      writer.write(generator.getNewTestCaseSourceCode());
    }
 catch (    InvalidPreferenceException ipe) {
      ipe.printStackTrace();
      openWarning(props,props.get(Dialog.Common.invalidPreference));
      return;
    }
catch (    FileNotFoundException fnfe) {
      fnfe.printStackTrace();
    }
 finally {
      IOUtil.close(writer);
      IOUtil.close(outputStream);
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
 finally {
    IOUtil.close(inputStream);
    IOUtil.close(outputStream);
    IOUtil.close(writer);
  }
  if (!ResourceRefreshUtil.refreshLocal(null,projectName + StringValue.DirectorySeparator.General + resourcePathForTestClassFile+ "String_Node_Str")) {
    openWarningForResourceRefreshError(props);
    System.err.println("String_Node_Str");
    return;
  }
  int retryCount=0;
  IEditorPart editorPart=null;
  ThreadUtil.sleep(1500);
  while (true) {
    try {
      IProject project=getIProject(projectName);
      IFile testCaseFile=getIFile(project,resourcePathForTestClassFile);
      IWorkbenchPage page=getIWorkbenchPage();
      editorPart=getIEditorPart(page,testCaseFile);
      if (editorPart == null) {
        throw new NullPointerException();
      }
      break;
    }
 catch (    Exception e) {
      retryCount++;
      if (retryCount > 3) {
        break;
      }
      ThreadUtil.sleep(1500);
    }
  }
  editorPart.setFocus();
}