@Test public void testMultipleClasses() { interestingClasses.clear(); String className = Integer.class.getName(); interestingClasses.add(className); className = String.class.getName(); interestingClasses.add(className); List<Class> instrumentedClasses = instrumentation.instrumentClasses(interestingClasses,className); assert (instrumentedClasses.size() == 2); assertEquals(instrumentedClasses.get(0),Integer.class); assertEquals(instrumentedClasses.get(1),String.class); }
public List<Class> instrumentClasses(List<String> interestingClasses, String testingClassName){ List<Class> instrumentedClasses = new ArrayList<>(); List<String> instrumentedClassesName = new ArrayList<>(); List<String> nonDuplicatedClasses = interestingClasses.stream().distinct().collect(Collectors.toList()); try{ for(String clazz : nonDuplicatedClasses){ if (clazz.equals(testingClassName)){ continue; } Properties.TARGET_CLASS=clazz; DependencyAnalysis.addNewTargetClass(clazz); } Properties.TARGET_CLASS=testingClassName; instrumentClassByTestExecution(testingClassName); }catch (Exception e){ LOG.warn("Could not instrument the target class!"); } for(String clazz: nonDuplicatedClasses ){ if(instrumentedClassesName.contains(clazz)){ continue; } LOG.debug("Instrumenting class "+ clazz); Class<?> cls; try { Properties.TARGET_CLASS=clazz; cls = Class.forName(clazz,true, BotsingTestGenerationContext.getInstance().getClassLoaderForSUT()); if(clazz != testingClassName){ instrumentClassByTestExecution(clazz); } instrumentedClasses.add(cls); instrumentedClassesName.add(clazz); } catch (ClassNotFoundException | NoClassDefFoundError e) { LOG.warn("Error in loading {}",clazz); } } return instrumentedClasses; }
ClassInstrumentation { public List<Class> instrumentClasses(List<String> interestingClasses, String testingClassName){ List<Class> instrumentedClasses = new ArrayList<>(); List<String> instrumentedClassesName = new ArrayList<>(); List<String> nonDuplicatedClasses = interestingClasses.stream().distinct().collect(Collectors.toList()); try{ for(String clazz : nonDuplicatedClasses){ if (clazz.equals(testingClassName)){ continue; } Properties.TARGET_CLASS=clazz; DependencyAnalysis.addNewTargetClass(clazz); } Properties.TARGET_CLASS=testingClassName; instrumentClassByTestExecution(testingClassName); }catch (Exception e){ LOG.warn("Could not instrument the target class!"); } for(String clazz: nonDuplicatedClasses ){ if(instrumentedClassesName.contains(clazz)){ continue; } LOG.debug("Instrumenting class "+ clazz); Class<?> cls; try { Properties.TARGET_CLASS=clazz; cls = Class.forName(clazz,true, BotsingTestGenerationContext.getInstance().getClassLoaderForSUT()); if(clazz != testingClassName){ instrumentClassByTestExecution(clazz); } instrumentedClasses.add(cls); instrumentedClassesName.add(clazz); } catch (ClassNotFoundException | NoClassDefFoundError e) { LOG.warn("Error in loading {}",clazz); } } return instrumentedClasses; } }
ClassInstrumentation { public List<Class> instrumentClasses(List<String> interestingClasses, String testingClassName){ List<Class> instrumentedClasses = new ArrayList<>(); List<String> instrumentedClassesName = new ArrayList<>(); List<String> nonDuplicatedClasses = interestingClasses.stream().distinct().collect(Collectors.toList()); try{ for(String clazz : nonDuplicatedClasses){ if (clazz.equals(testingClassName)){ continue; } Properties.TARGET_CLASS=clazz; DependencyAnalysis.addNewTargetClass(clazz); } Properties.TARGET_CLASS=testingClassName; instrumentClassByTestExecution(testingClassName); }catch (Exception e){ LOG.warn("Could not instrument the target class!"); } for(String clazz: nonDuplicatedClasses ){ if(instrumentedClassesName.contains(clazz)){ continue; } LOG.debug("Instrumenting class "+ clazz); Class<?> cls; try { Properties.TARGET_CLASS=clazz; cls = Class.forName(clazz,true, BotsingTestGenerationContext.getInstance().getClassLoaderForSUT()); if(clazz != testingClassName){ instrumentClassByTestExecution(clazz); } instrumentedClasses.add(cls); instrumentedClassesName.add(clazz); } catch (ClassNotFoundException | NoClassDefFoundError e) { LOG.warn("Error in loading {}",clazz); } } return instrumentedClasses; }  }
ClassInstrumentation { public List<Class> instrumentClasses(List<String> interestingClasses, String testingClassName){ List<Class> instrumentedClasses = new ArrayList<>(); List<String> instrumentedClassesName = new ArrayList<>(); List<String> nonDuplicatedClasses = interestingClasses.stream().distinct().collect(Collectors.toList()); try{ for(String clazz : nonDuplicatedClasses){ if (clazz.equals(testingClassName)){ continue; } Properties.TARGET_CLASS=clazz; DependencyAnalysis.addNewTargetClass(clazz); } Properties.TARGET_CLASS=testingClassName; instrumentClassByTestExecution(testingClassName); }catch (Exception e){ LOG.warn("Could not instrument the target class!"); } for(String clazz: nonDuplicatedClasses ){ if(instrumentedClassesName.contains(clazz)){ continue; } LOG.debug("Instrumenting class "+ clazz); Class<?> cls; try { Properties.TARGET_CLASS=clazz; cls = Class.forName(clazz,true, BotsingTestGenerationContext.getInstance().getClassLoaderForSUT()); if(clazz != testingClassName){ instrumentClassByTestExecution(clazz); } instrumentedClasses.add(cls); instrumentedClassesName.add(clazz); } catch (ClassNotFoundException | NoClassDefFoundError e) { LOG.warn("Error in loading {}",clazz); } } return instrumentedClasses; }  List<Class> instrumentClasses(List<String> interestingClasses, String testingClassName); static void instrumentClassByTestExecution(String targetClass); }
ClassInstrumentation { public List<Class> instrumentClasses(List<String> interestingClasses, String testingClassName){ List<Class> instrumentedClasses = new ArrayList<>(); List<String> instrumentedClassesName = new ArrayList<>(); List<String> nonDuplicatedClasses = interestingClasses.stream().distinct().collect(Collectors.toList()); try{ for(String clazz : nonDuplicatedClasses){ if (clazz.equals(testingClassName)){ continue; } Properties.TARGET_CLASS=clazz; DependencyAnalysis.addNewTargetClass(clazz); } Properties.TARGET_CLASS=testingClassName; instrumentClassByTestExecution(testingClassName); }catch (Exception e){ LOG.warn("Could not instrument the target class!"); } for(String clazz: nonDuplicatedClasses ){ if(instrumentedClassesName.contains(clazz)){ continue; } LOG.debug("Instrumenting class "+ clazz); Class<?> cls; try { Properties.TARGET_CLASS=clazz; cls = Class.forName(clazz,true, BotsingTestGenerationContext.getInstance().getClassLoaderForSUT()); if(clazz != testingClassName){ instrumentClassByTestExecution(clazz); } instrumentedClasses.add(cls); instrumentedClassesName.add(clazz); } catch (ClassNotFoundException | NoClassDefFoundError e) { LOG.warn("Error in loading {}",clazz); } } return instrumentedClasses; }  List<Class> instrumentClasses(List<String> interestingClasses, String testingClassName); static void instrumentClassByTestExecution(String targetClass);  }