Program: 11955
Project: 11955
Buggy source:
public void run(IAction action){
  store=getIPreferenceStore();
  Configuration config=getConfiguration(store,selection);
  PropertiesLoader props=getPropertiesLoader(config.language);
  String resourcePathForTestCaseFile=null;
  StructuredSelection structuredSelection=null;
  try {
    if (selection instanceof StructuredSelection) {
      structuredSelection=(StructuredSelection)selection;
    }
    if (isNotSelected(structuredSelection)) {
      openWarningForRequired(props);
      return;
    }
 else     if (isSelectedSeveral(structuredSelection)) {
      openWarningForSelectOneOnly(props);
      return;
    }
    String projectName=getProjectName(structuredSelection);
    String resourcePathForTargetClassFile=getResourcePathForTargetClassFile(structuredSelection);
    String targetClassName=getClassNameFromResourcePathForTargetClassFile(resourcePathForTargetClassFile);
    if (targetClassName == null) {
      openWarningForSelectJavaFile(props);
      return;
    }
    resourcePathForTestCaseFile=resourcePathForTargetClassFile.replace(config.directoryPathOfProductSourceCode,config.directoryPathOfTestSourceCode).replace(StringValue.FileExtension.JavaFile,StringValue.JUnit.TestClassNameSuffix + StringValue.FileExtension.JavaFile);
    String projectRootAbsolutePath=getWorkspaceRootAbsolutePath(getIWorkspaceRoot()) + StringValue.DirectorySeparator.General + projectName+ StringValue.DirectorySeparator.General;
    String testCaseFileAbsolutePath=projectRootAbsolutePath + resourcePathForTestCaseFile;
    File testCaseIOFile=new File(testCaseFileAbsolutePath);
    if (!testCaseIOFile.exists()) {
      String testCaseFilename=getTestClassNameFromClassName(targetClassName);
      String msg=props.get(Dialog.Common.notExist) + "String_Node_Str" + testCaseFilename+ "String_Node_Str"+ StringValue.LineFeed+ props.get(Dialog.Common.confirmToCreateNewFile);
      if (testCaseFilename != null && openConfirm(props,msg)) {
        new CreateNewTestCaseAction().run(action,selection);
      }
      return;
    }
    int retryCount=0;
    IEditorPart editorPart=null;
    while (true) {
      try {
        IProject project=getIProject(projectName);
        IWorkbenchPage page=getIWorkbenchPage();
        String absolutePath=projectRootAbsolutePath + StringValue.DirectorySeparator.General;
        config.directoryPathOfProductSourceCode=absolutePath + config.directoryPathOfProductSourceCode;
        config.directoryPathOfTestSourceCode=absolutePath + config.directoryPathOfTestSourceCode;
        IFile targetFile=getIFile(project,resourcePathForTargetClassFile);
        String targetFileEncoding=UniversalDetectorUtil.getDetectedEncoding(EclipseIFileUtil.getInputStreamFrom(targetFile));
        String targetSourceCodeString=IOUtil.readAsString(EclipseIFileUtil.getInputStreamFrom(targetFile),targetFileEncoding);
        ClassMeta targetClassMeta=new ClassMetaExtractor(config).extract(targetSourceCodeString);
        IFile testCaseFile=getIFile(project,resourcePathForTestCaseFile);
        String charset=null;
        if (config.outputFileEncoding != null) {
          charset=config.outputFileEncoding;
        }
 else {
          charset=getDetectedCharsetFrom(testCaseFile,config.outputFileEncoding);
        }
        InputStream testCaseFileStream=null;
        String currentTestCodeString=null;
        try {
          testCaseFileStream=new FileInputStream(new File(testCaseFileAbsolutePath));
          currentTestCodeString=IOUtils.toString(testCaseFileStream,charset);
        }
  finally {
          IOUtils.closeQuietly(testCaseFileStream);
        }
        CurrentLineBreak currentLineBreak=CurrentLineBreakDetector.detect(currentTestCodeString);
        LineBreakProvider lineBreakProvider=new LineBreakProvider(config,currentLineBreak);
        TestCaseGenerator generator=TestCaseGeneratorFactory.create(config,lineBreakProvider);
        String newTestCodeString=generator.initialize(targetClassMeta).getTestCaseSourceCodeWithLackingTestMethod(currentTestCodeString);
        OutputStreamWriter writer=null;
        FileOutputStream outputStream=null;
        try {
          outputStream=new FileOutputStream(testCaseIOFile);
          writer=new OutputStreamWriter(outputStream,charset);
          writer.write(newTestCodeString);
        }
  finally {
          IOUtils.closeQuietly(writer);
          IOUtils.closeQuietly(outputStream);
        }
        if (!ResourceRefreshUtil.refreshLocal(null,projectName + StringValue.DirectorySeparator.General + resourcePathForTestCaseFile+ "String_Node_Str")) {
          openWarningForResourceRefreshError(props);
          System.err.println("String_Node_Str");
          return;
        }
        retryCount=0;
        ThreadUtil.sleep(1500);
        while (true) {
          try {
            editorPart=getIEditorPart(page,testCaseFile);
            if (editorPart == null) {
              throw new NullPointerException();
            }
            break;
          }
 catch (          Exception e) {
            retryCount++;
            if (retryCount > 3) {
              break;
            }
            ThreadUtil.sleep(1500);
          }
        }
        editorPart.setFocus();
      }
 catch (      Exception e) {
        retryCount++;
        if (retryCount > 10) {
          break;
        }
        e.printStackTrace();
        ThreadUtil.sleep(1500);
      }
      break;
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public void run(IAction action){
  store=getIPreferenceStore();
  Configuration config=getConfiguration(store,selection);
  PropertiesLoader props=getPropertiesLoader(config.language);
  String resourcePathForTestCaseFile=null;
  StructuredSelection structuredSelection=null;
  try {
    if (selection instanceof StructuredSelection) {
      structuredSelection=(StructuredSelection)selection;
    }
    if (isNotSelected(structuredSelection)) {
      openWarningForRequired(props);
      return;
    }
 else     if (isSelectedSeveral(structuredSelection)) {
      openWarningForSelectOneOnly(props);
      return;
    }
    String projectName=getProjectName(structuredSelection);
    String resourcePathForTargetClassFile=getResourcePathForTargetClassFile(structuredSelection);
    String targetClassName=getClassNameFromResourcePathForTargetClassFile(resourcePathForTargetClassFile);
    if (targetClassName == null) {
      openWarningForSelectJavaFile(props);
      return;
    }
    resourcePathForTestCaseFile=resourcePathForTargetClassFile.replace(config.directoryPathOfProductSourceCode,config.directoryPathOfTestSourceCode).replace(StringValue.FileExtension.JavaFile,StringValue.JUnit.TestClassNameSuffix + StringValue.FileExtension.JavaFile);
    String projectRootAbsolutePath=getIWorkspaceRoot().findMember(projectName).getLocationURI().getPath() + StringValue.DirectorySeparator.General;
    String testCaseFileAbsolutePath=projectRootAbsolutePath + resourcePathForTestCaseFile;
    File testCaseIOFile=new File(testCaseFileAbsolutePath);
    if (!testCaseIOFile.exists()) {
      String testCaseFilename=getTestClassNameFromClassName(targetClassName);
      String msg=props.get(Dialog.Common.notExist) + "String_Node_Str" + testCaseFilename+ "String_Node_Str"+ StringValue.LineFeed+ props.get(Dialog.Common.confirmToCreateNewFile);
      if (testCaseFilename != null && openConfirm(props,msg)) {
        new CreateNewTestCaseAction().run(action,selection);
      }
      return;
    }
    int retryCount=0;
    IEditorPart editorPart=null;
    while (true) {
      try {
        IProject project=getIProject(projectName);
        IWorkbenchPage page=getIWorkbenchPage();
        String absolutePath=projectRootAbsolutePath + StringValue.DirectorySeparator.General;
        config.directoryPathOfProductSourceCode=absolutePath + config.directoryPathOfProductSourceCode;
        config.directoryPathOfTestSourceCode=absolutePath + config.directoryPathOfTestSourceCode;
        IFile targetFile=getIFile(project,resourcePathForTargetClassFile);
        String targetFileEncoding=UniversalDetectorUtil.getDetectedEncoding(EclipseIFileUtil.getInputStreamFrom(targetFile));
        String targetSourceCodeString=IOUtil.readAsString(EclipseIFileUtil.getInputStreamFrom(targetFile),targetFileEncoding);
        ClassMeta targetClassMeta=new ClassMetaExtractor(config).extract(targetSourceCodeString);
        IFile testCaseFile=getIFile(project,resourcePathForTestCaseFile);
        String charset=null;
        if (config.outputFileEncoding != null) {
          charset=config.outputFileEncoding;
        }
 else {
          charset=getDetectedCharsetFrom(testCaseFile,config.outputFileEncoding);
        }
        InputStream testCaseFileStream=null;
        String currentTestCodeString=null;
        try {
          testCaseFileStream=new FileInputStream(new File(testCaseFileAbsolutePath));
          currentTestCodeString=IOUtils.toString(testCaseFileStream,charset);
        }
  finally {
          IOUtils.closeQuietly(testCaseFileStream);
        }
        CurrentLineBreak currentLineBreak=CurrentLineBreakDetector.detect(currentTestCodeString);
        LineBreakProvider lineBreakProvider=new LineBreakProvider(config,currentLineBreak);
        TestCaseGenerator generator=TestCaseGeneratorFactory.create(config,lineBreakProvider);
        String newTestCodeString=generator.initialize(targetClassMeta).getTestCaseSourceCodeWithLackingTestMethod(currentTestCodeString);
        OutputStreamWriter writer=null;
        FileOutputStream outputStream=null;
        try {
          outputStream=new FileOutputStream(testCaseIOFile);
          writer=new OutputStreamWriter(outputStream,charset);
          writer.write(newTestCodeString);
        }
  finally {
          IOUtils.closeQuietly(writer);
          IOUtils.closeQuietly(outputStream);
        }
        if (!ResourceRefreshUtil.refreshLocal(null,projectName + StringValue.DirectorySeparator.General + resourcePathForTestCaseFile+ "String_Node_Str")) {
          openWarningForResourceRefreshError(props);
          System.err.println("String_Node_Str");
          return;
        }
        retryCount=0;
        ThreadUtil.sleep(1500);
        while (true) {
          try {
            editorPart=getIEditorPart(page,testCaseFile);
            if (editorPart == null) {
              throw new NullPointerException();
            }
            break;
          }
 catch (          Exception e) {
            retryCount++;
            if (retryCount > 3) {
              break;
            }
            ThreadUtil.sleep(1500);
          }
        }
        editorPart.setFocus();
      }
 catch (      Exception e) {
        retryCount++;
        if (retryCount > 10) {
          break;
        }
        e.printStackTrace();
        ThreadUtil.sleep(1500);
      }
      break;
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}