static public void runTest(String code, String subFolder, String file,
boolean doCompare, boolean store) throws Exception {
ASTParser parser = ASTParser.newParser(AST.JLS3);
CompilationUnit node;
Graph testGraph;
OutputStream out;
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setResolveBindings(true);
// parser.setBindingsRecovery(true);
parser.setSource(code.toCharArray());
parser.setUnitName("Foo.java");
// parser.setProject(JavaCore.create(null));
node = (CompilationUnit) parser.createAST(null);
for (IProblem problem : node.getProblems()) {
System.out.println("Compile problem for " + subFolder + "_" + file);
System.out.println(problem.getMessage());
}
Assert.assertEquals(0, node.getProblems().length);
List<MethodDeclaration> methods = WorkspaceUtilities
.scanForMethodDeclarationsFromAST(node);
Assert.assertEquals(1, methods.size());
IControlFlowGraph cfg = new EclipseNodeFirstCFG(methods.get(0));
testGraph = cfg.getDotGraph();
if (store) {
out = new FileOutputStream("test/" + subFolder + "_" + file);
} else {
out = new FileOutputStream("test/lastrun/" + subFolder + "_" + file);
}
testGraph.printGraph(out);
out.close();
if (doCompare) {
InputStream original = new FileInputStream("test/" + subFolder
+ "_" + file);
Parser graphParser = new Parser(original);
Graph realGraph;
graphParser.parse();
realGraph = graphParser.getGraph();
Assert