Program: 12043
Project: 12043
Buggy source:
/** 
 * Get the information on the test methods corresponded the developing public methods.
 * @param javaFile
 * @return the information on the test methods
 * @throws Exception
 */
public static ClassInfo getTestClassInfoFromTargetClass(IFile javaFile) throws InvalidPreferenceException, IOException {
  PreferenceLoader pref=new PreferenceLoader();
  ClassInfo classInfo=new ClassInfo();
  List<MethodInfo> testMethods=new ArrayList<MethodInfo>();
  InputStream is=null;
  InputStreamReader isr=null;
  BufferedReader br=null;
  try {
    String encoding=FileResourceUtil.detectEncoding(javaFile);
    is=FileResourceUtil.readFile(javaFile);
    isr=new InputStreamReader(is,encoding);
    br=new BufferedReader(isr);
    StringBuilder tmpsb=new StringBuilder();
    String line=null;
    while ((line=br.readLine()) != null) {
      line+=StrConst.lineFeed;
      tmpsb.append(SourceCodeParseUtil.trimLineComments(line));
      tmpsb.append(StrConst.space);
    }
    String targetClassSourceStrWithoutComments=SourceCodeParseUtil.trimAllComments(tmpsb.toString());
    String targetClassSourceStr=SourceCodeParseUtil.trimInsideOfBraces(targetClassSourceStrWithoutComments);
    if (pref.isTestMethodGenNotBlankEnabled) {
      if (testMethods.size() <= 0 || testMethods.get(0) == null)       testMethods.add(new MethodInfo());
      String[] importLines=targetClassSourceStr.split("String_Node_Str");
      for (      String importLine : importLines) {
        importLine=importLine.replaceAll(StrConst.lineFeed,StrConst.empty);
        if (!importLine.matches("String_Node_Str") && !importLine.matches("String_Node_Str")) {
          String importedPackage=importLine.split("String_Node_Str")[0];
          classInfo.importList.add(importedPackage);
        }
      }
      if (pref.isJUnitVersion3) {
      }
 else       if (pref.isJUnitVersion4) {
        classInfo.importList.add("String_Node_Str");
        classInfo.importList.add("String_Node_Str");
      }
      if (pref.isTestMethodGenEnabledSupportJMock2) {
        classInfo.importList.add("String_Node_Str");
        classInfo.importList.add("String_Node_Str");
        classInfo.importList.add("String_Node_Str");
        if (pref.isUsingJUnitHelperRuntime) {
          classInfo.importList.add("String_Node_Str");
        }
      }
      if (pref.isTestMethodGenEnabledSupportEasyMock) {
        classInfo.importList.add("String_Node_Str");
        classInfo.importList.add("String_Node_Str");
      }
    }
    List<String> targets=SourceCodeParseUtil.getTargetMethods(targetClassSourceStr,pref.isTestMethodGenIncludePublic,pref.isTestMethodGenIncludeProtected,pref.isTestMethodGenIncludePackageLocal);
    for (    String target : targets) {
      Matcher matcher=RegExp.groupMethodPattern.matcher(target);
      if (matcher.find()) {
        MethodInfo each=new MethodInfo();
        if (pref.isTestMethodGenNotBlankEnabled || pref.isTestMethodGenReturnEnabled) {
          String returnTypeFull=getType(matcher.group(1));
          Matcher toGenericsMatcher=Pattern.compile(RegExp.genericsGroup).matcher(returnTypeFull);
          while (toGenericsMatcher.find()) {
            String[] generics=toGenericsMatcher.group().replaceAll("String_Node_Str",StrConst.empty).replaceAll("String_Node_Str",StrConst.empty).split(StrConst.comma);
            for (            String generic : generics) {
              generic=getClassInSourceCode(generic,StrConst.empty,new ArrayList<String>());
              each.returnType.generics.add(generic);
            }
          }
          each.returnType.name=returnTypeFull.replace(RegExp.generics,StrConst.empty);
          each.returnType.nameInMethodName=getTypeAvailableInMethodName(each.returnType.name);
        }
        each.methodName=matcher.group(2);
        String args=matcher.group(3);
        String[] tmpArr=args.split(StrConst.comma);
        int tmpArrLen=tmpArr.length;
        List<String> tmpArrList=new ArrayList<String>();
        String buf=StrConst.empty;
        for (int i=0; i < tmpArrLen; i++) {
          String element=tmpArr[i].trim();
          if (element.matches("String_Node_Str")) {
            tmpArrList.add(element);
            continue;
          }
          if (element.matches("String_Node_Str")) {
            buf+=element;
            continue;
          }
          if (element.matches("String_Node_Str")) {
            String result=buf + StrConst.comma + element;
            tmpArrList.add(result);
            buf=StrConst.empty;
            continue;
          }
          if (!buf.equals(StrConst.empty)) {
            buf+=StrConst.comma + element;
            continue;
          }
          tmpArrList.add(element);
        }
        String[] argArr=tmpArrList.toArray(new String[0]);
        if (pref.isTestMethodGenNotBlankEnabled || pref.isTestMethodGenArgsEnabled) {
          int argArrLen=argArr.length;
          for (int i=0; i < argArrLen; i++) {
            ArgType argType=new ArgType();
            String argTypeFull=argArr[i];
            Matcher toGenericsMatcher=Pattern.compile(RegExp.genericsGroup).matcher(argTypeFull);
            while (toGenericsMatcher.find()) {
              String[] generics=toGenericsMatcher.group().replaceAll("String_Node_Str",StrConst.empty).replaceAll("String_Node_Str",StrConst.empty).split(StrConst.comma);
              for (              String generic : generics) {
                generic=getClassInSourceCode(generic,StrConst.empty,new ArrayList<String>());
                argType.generics.add(generic);
              }
            }
            String argTypeStr=argTypeFull.replaceAll(RegExp.generics,StrConst.empty);
            argType.name=getType(argTypeStr);
            argType.nameInMethodName=getTypeAvailableInMethodName(argTypeStr);
            each.argTypes.add(argType);
          }
        }
        if (pref.isTestMethodGenExecludeAccessors) {
          String fieldName=null;
          String fieldType=null;
          if (each.methodName.matches("String_Node_Str")) {
            fieldName=each.methodName.substring(3);
            if (each.argTypes.size() > 0) {
              fieldType=each.argTypes.get(0).name;
            }
          }
 else           if (each.methodName.matches("String_Node_Str")) {
            fieldName=each.methodName.substring(3);
            fieldType=each.returnType.name;
          }
 else           if (each.methodName.matches("String_Node_Str")) {
            fieldName=each.methodName.substring(2);
            fieldType=each.returnType.name;
          }
          if (fieldName != null) {
            fieldName=fieldName.substring(0,1).toLowerCase() + fieldName.substring(1);
            fieldType=fieldType.replaceAll("String_Node_Str","String_Node_Str").replaceAll("String_Node_Str","String_Node_Str");
            String searchRegexp="String_Node_Str" + fieldType + RegExp.wsReq+ fieldName+ "String_Node_Str";
            if (targetClassSourceStr.matches(searchRegexp)) {
              continue;
            }
          }
        }
        String prefix=pref.isJUnitVersion3 ? StrConst.testMethodPrefix4Version3 + pref.testMethodDelimiter : StrConst.empty;
        each.testMethodName=prefix + each.methodName;
        if (pref.isTestMethodGenArgsEnabled) {
          each.testMethodName+=pref.testMethodDelimiter + pref.testMethodArgsPrefix;
          if (each.argTypes.size() == 0) {
            each.testMethodName+=pref.testMethodArgsDelimiter;
          }
          for (          ArgType argType : each.argTypes) {
            each.testMethodName+=pref.testMethodArgsDelimiter + argType.nameInMethodName;
          }
        }
        if (pref.isTestMethodGenReturnEnabled) {
          each.testMethodName+=pref.testMethodDelimiter + pref.testMethodReturnPrefix + pref.testMethodReturnDelimiter+ each.returnType.nameInMethodName;
        }
        if (target.matches(RegExp.matchesStaticMethod)) {
          each.isStatic=true;
        }
        testMethods.add(each);
        if (pref.isTestMethodGenExceptions) {
          String throwsExceptions=matcher.group(4);
          if (throwsExceptions != null) {
            String[] exceptions=throwsExceptions.replaceAll("String_Node_Str" + RegExp.wsReq,StrConst.empty).split(StrConst.comma);
            for (            String exp : exceptions) {
              exp=exp.trim();
              MethodInfo expTest=ObjectUtil.deepCopy(each);
              expTest.testingTargetException=new ExceptionInfo();
              expTest.testingTargetException.name=exp;
              expTest.testingTargetException.nameInMethodName=TestCaseGenerateUtil.getTypeAvailableInMethodName(exp);
              expTest.testMethodName=expTest.testMethodName + pref.testMethodDelimiter + pref.testMethodExceptionPrefix+ pref.testMethodExceptionDelimiter+ expTest.testingTargetException.nameInMethodName;
              testMethods.add(expTest);
            }
          }
        }
      }
    }
  }
  finally {
    FileResourceUtil.close(br);
    FileResourceUtil.close(isr);
    FileResourceUtil.close(is);
  }
  classInfo.methods=testMethods;
  return classInfo;
}

Fixed version (ground truth):
/** 
 * Get the information on the test methods corresponded the developing public methods.
 * @param javaFile
 * @return the information on the test methods
 * @throws Exception
 */
public static ClassInfo getTestClassInfoFromTargetClass(IFile javaFile) throws InvalidPreferenceException, IOException {
  PreferenceLoader pref=new PreferenceLoader();
  ClassInfo classInfo=new ClassInfo();
  List<MethodInfo> testMethods=new ArrayList<MethodInfo>();
  InputStream is=null;
  InputStreamReader isr=null;
  BufferedReader br=null;
  try {
    String encoding=FileResourceUtil.detectEncoding(javaFile);
    is=FileResourceUtil.readFile(javaFile);
    isr=new InputStreamReader(is,encoding);
    br=new BufferedReader(isr);
    StringBuilder tmpsb=new StringBuilder();
    String line=null;
    while ((line=br.readLine()) != null) {
      line+=StrConst.lineFeed;
      tmpsb.append(SourceCodeParseUtil.trimLineComments(line));
      tmpsb.append(StrConst.space);
    }
    System.out.println(tmpsb.toString());
    String targetClassSourceStrWithoutComments=SourceCodeParseUtil.trimAllComments(tmpsb.toString());
    String targetClassSourceStr=SourceCodeParseUtil.trimInsideOfBraces(targetClassSourceStrWithoutComments);
    if (pref.isTestMethodGenNotBlankEnabled) {
      if (testMethods.size() <= 0 || testMethods.get(0) == null)       testMethods.add(new MethodInfo());
      String[] importLines=targetClassSourceStr.split("String_Node_Str");
      for (      String importLine : importLines) {
        importLine=importLine.replaceAll(StrConst.lineFeed,StrConst.empty);
        if (!importLine.matches("String_Node_Str") && !importLine.matches("String_Node_Str")) {
          String importedPackage=importLine.split("String_Node_Str")[0];
          classInfo.importList.add(importedPackage);
        }
      }
      if (pref.isJUnitVersion3) {
      }
 else       if (pref.isJUnitVersion4) {
        classInfo.importList.add("String_Node_Str");
        classInfo.importList.add("String_Node_Str");
      }
      if (pref.isTestMethodGenEnabledSupportJMock2) {
        classInfo.importList.add("String_Node_Str");
        classInfo.importList.add("String_Node_Str");
        classInfo.importList.add("String_Node_Str");
        if (pref.isUsingJUnitHelperRuntime) {
          classInfo.importList.add("String_Node_Str");
        }
      }
      if (pref.isTestMethodGenEnabledSupportEasyMock) {
        classInfo.importList.add("String_Node_Str");
        classInfo.importList.add("String_Node_Str");
      }
    }
    List<String> targets=SourceCodeParseUtil.getTargetMethods(targetClassSourceStr,pref.isTestMethodGenIncludePublic,pref.isTestMethodGenIncludeProtected,pref.isTestMethodGenIncludePackageLocal);
    for (    String target : targets) {
      Matcher matcher=RegExp.groupMethodPattern.matcher(target);
      if (matcher.find()) {
        MethodInfo each=new MethodInfo();
        if (pref.isTestMethodGenNotBlankEnabled || pref.isTestMethodGenReturnEnabled) {
          String returnTypeFull=getType(matcher.group(1));
          Matcher toGenericsMatcher=Pattern.compile(RegExp.genericsGroup).matcher(returnTypeFull);
          while (toGenericsMatcher.find()) {
            String[] generics=toGenericsMatcher.group().replaceAll("String_Node_Str",StrConst.empty).replaceAll("String_Node_Str",StrConst.empty).split(StrConst.comma);
            for (            String generic : generics) {
              generic=getClassInSourceCode(generic,StrConst.empty,new ArrayList<String>());
              each.returnType.generics.add(generic);
            }
          }
          each.returnType.name=returnTypeFull.replace(RegExp.generics,StrConst.empty);
          each.returnType.nameInMethodName=getTypeAvailableInMethodName(each.returnType.name);
        }
        each.methodName=matcher.group(2);
        String args=matcher.group(3);
        String[] tmpArr=args.split(StrConst.comma);
        int tmpArrLen=tmpArr.length;
        List<String> tmpArrList=new ArrayList<String>();
        String buf=StrConst.empty;
        for (int i=0; i < tmpArrLen; i++) {
          String element=tmpArr[i].trim();
          if (element.matches("String_Node_Str")) {
            tmpArrList.add(element);
            continue;
          }
          if (element.matches("String_Node_Str")) {
            buf+=element;
            continue;
          }
          if (element.matches("String_Node_Str")) {
            String result=buf + StrConst.comma + element;
            tmpArrList.add(result);
            buf=StrConst.empty;
            continue;
          }
          if (!buf.equals(StrConst.empty)) {
            buf+=StrConst.comma + element;
            continue;
          }
          tmpArrList.add(element);
        }
        String[] argArr=tmpArrList.toArray(new String[0]);
        if (pref.isTestMethodGenNotBlankEnabled || pref.isTestMethodGenArgsEnabled) {
          int argArrLen=argArr.length;
          for (int i=0; i < argArrLen; i++) {
            ArgType argType=new ArgType();
            String argTypeFull=argArr[i];
            Matcher toGenericsMatcher=Pattern.compile(RegExp.genericsGroup).matcher(argTypeFull);
            while (toGenericsMatcher.find()) {
              String[] generics=toGenericsMatcher.group().replaceAll("String_Node_Str",StrConst.empty).replaceAll("String_Node_Str",StrConst.empty).split(StrConst.comma);
              for (              String generic : generics) {
                generic=getClassInSourceCode(generic,StrConst.empty,new ArrayList<String>());
                argType.generics.add(generic);
              }
            }
            String argTypeStr=argTypeFull.replaceAll(RegExp.generics,StrConst.empty);
            argType.name=getType(argTypeStr);
            argType.nameInMethodName=getTypeAvailableInMethodName(argTypeStr);
            each.argTypes.add(argType);
          }
        }
        if (pref.isTestMethodGenExecludeAccessors) {
          String fieldName=null;
          String fieldType=null;
          if (each.methodName.matches("String_Node_Str")) {
            fieldName=each.methodName.substring(3);
            if (each.argTypes.size() > 0) {
              fieldType=each.argTypes.get(0).name;
            }
          }
 else           if (each.methodName.matches("String_Node_Str")) {
            fieldName=each.methodName.substring(3);
            fieldType=each.returnType.name;
          }
 else           if (each.methodName.matches("String_Node_Str")) {
            fieldName=each.methodName.substring(2);
            fieldType=each.returnType.name;
          }
          if (fieldName != null) {
            fieldName=fieldName.substring(0,1).toLowerCase() + fieldName.substring(1);
            fieldType=fieldType.replaceAll("String_Node_Str","String_Node_Str").replaceAll("String_Node_Str","String_Node_Str");
            String searchRegexp="String_Node_Str" + fieldType + RegExp.wsReq+ fieldName+ "String_Node_Str";
            if (targetClassSourceStr.matches(searchRegexp)) {
              continue;
            }
          }
        }
        String prefix=pref.isJUnitVersion3 ? StrConst.testMethodPrefix4Version3 + pref.testMethodDelimiter : StrConst.empty;
        each.testMethodName=prefix + each.methodName;
        if (pref.isTestMethodGenArgsEnabled) {
          each.testMethodName+=pref.testMethodDelimiter + pref.testMethodArgsPrefix;
          if (each.argTypes.size() == 0) {
            each.testMethodName+=pref.testMethodArgsDelimiter;
          }
          for (          ArgType argType : each.argTypes) {
            each.testMethodName+=pref.testMethodArgsDelimiter + argType.nameInMethodName;
          }
        }
        if (pref.isTestMethodGenReturnEnabled) {
          each.testMethodName+=pref.testMethodDelimiter + pref.testMethodReturnPrefix + pref.testMethodReturnDelimiter+ each.returnType.nameInMethodName;
        }
        if (target.matches(RegExp.matchesStaticMethod)) {
          each.isStatic=true;
        }
        testMethods.add(each);
        if (pref.isTestMethodGenExceptions) {
          String throwsExceptions=matcher.group(4);
          if (throwsExceptions != null) {
            String[] exceptions=throwsExceptions.replaceAll("String_Node_Str" + RegExp.wsReq,StrConst.empty).split(StrConst.comma);
            for (            String exp : exceptions) {
              exp=exp.trim();
              MethodInfo expTest=ObjectUtil.deepCopy(each);
              expTest.testingTargetException=new ExceptionInfo();
              expTest.testingTargetException.name=exp;
              expTest.testingTargetException.nameInMethodName=TestCaseGenerateUtil.getTypeAvailableInMethodName(exp);
              expTest.testMethodName=expTest.testMethodName + pref.testMethodDelimiter + pref.testMethodExceptionPrefix+ pref.testMethodExceptionDelimiter+ expTest.testingTargetException.nameInMethodName;
              testMethods.add(expTest);
            }
          }
        }
      }
    }
  }
  finally {
    FileResourceUtil.close(br);
    FileResourceUtil.close(isr);
    FileResourceUtil.close(is);
  }
  classInfo.methods=testMethods;
  return classInfo;
}