@Test public void testIsNotInDomain(){ instrumentedClasses.add(Integer.class); RawControlFlowGraph realRCFG1 = new RawControlFlowGraph(BotsingTestGenerationContext.getInstance().getClassLoaderForSUT(),Integer.class.getName(),selectedmethod,0); RawControlFlowGraph rcfg1 = Mockito.spy(realRCFG1); BytecodeInstruction stmnt = testingUtils.mockNewStatement(Integer.class.getName(),selectedmethod,100); BytecodeInstruction stmnt2 = testingUtils.mockNewStatement(Integer.class.getName(),selectedmethod,102); rcfg1.addVertex(stmnt); rcfg1.addVertex(stmnt2); GraphPool.getInstance(BotsingTestGenerationContext.getInstance().getClassLoaderForSUT()).registerRawCFG(rcfg1); CUT.collectCFGS(instrumentedClasses); assertFalse(CUT.isNotInDomain(Integer.class.getName(),selectedmethod,101)); assertTrue(CUT.isNotInDomain(Integer.class.getName(),selectedmethod,99)); }
protected boolean isNotInDomain(String className, String methodName, int lineNumber) { for (RawControlFlowGraph classCFG: cfgs.get(className)){ if(classCFG.getMethodName().contains(methodName)){ int maxLine = -1; int minLine = Integer.MAX_VALUE; for (BytecodeInstruction instruction: classCFG.vertexSet()){ int currentLineNumber = instruction.getLineNumber(); if(currentLineNumber > maxLine){ maxLine = currentLineNumber; } if(currentLineNumber < minLine && currentLineNumber>0){ minLine = currentLineNumber; } } if(lineNumber<maxLine && lineNumber > minLine){ return false; } } } return true; }
CFGGenerator { protected boolean isNotInDomain(String className, String methodName, int lineNumber) { for (RawControlFlowGraph classCFG: cfgs.get(className)){ if(classCFG.getMethodName().contains(methodName)){ int maxLine = -1; int minLine = Integer.MAX_VALUE; for (BytecodeInstruction instruction: classCFG.vertexSet()){ int currentLineNumber = instruction.getLineNumber(); if(currentLineNumber > maxLine){ maxLine = currentLineNumber; } if(currentLineNumber < minLine && currentLineNumber>0){ minLine = currentLineNumber; } } if(lineNumber<maxLine && lineNumber > minLine){ return false; } } } return true; } }
CFGGenerator { protected boolean isNotInDomain(String className, String methodName, int lineNumber) { for (RawControlFlowGraph classCFG: cfgs.get(className)){ if(classCFG.getMethodName().contains(methodName)){ int maxLine = -1; int minLine = Integer.MAX_VALUE; for (BytecodeInstruction instruction: classCFG.vertexSet()){ int currentLineNumber = instruction.getLineNumber(); if(currentLineNumber > maxLine){ maxLine = currentLineNumber; } if(currentLineNumber < minLine && currentLineNumber>0){ minLine = currentLineNumber; } } if(lineNumber<maxLine && lineNumber > minLine){ return false; } } } return true; }  }
CFGGenerator { protected boolean isNotInDomain(String className, String methodName, int lineNumber) { for (RawControlFlowGraph classCFG: cfgs.get(className)){ if(classCFG.getMethodName().contains(methodName)){ int maxLine = -1; int minLine = Integer.MAX_VALUE; for (BytecodeInstruction instruction: classCFG.vertexSet()){ int currentLineNumber = instruction.getLineNumber(); if(currentLineNumber > maxLine){ maxLine = currentLineNumber; } if(currentLineNumber < minLine && currentLineNumber>0){ minLine = currentLineNumber; } } if(lineNumber<maxLine && lineNumber > minLine){ return false; } } } return true; }  void generateInterProceduralCFG(); }
CFGGenerator { protected boolean isNotInDomain(String className, String methodName, int lineNumber) { for (RawControlFlowGraph classCFG: cfgs.get(className)){ if(classCFG.getMethodName().contains(methodName)){ int maxLine = -1; int minLine = Integer.MAX_VALUE; for (BytecodeInstruction instruction: classCFG.vertexSet()){ int currentLineNumber = instruction.getLineNumber(); if(currentLineNumber > maxLine){ maxLine = currentLineNumber; } if(currentLineNumber < minLine && currentLineNumber>0){ minLine = currentLineNumber; } } if(lineNumber<maxLine && lineNumber > minLine){ return false; } } } return true; }  void generateInterProceduralCFG();  }