Example #1
0
  /**
   * @param tc
   * @param sGUIFile
   * @param sEFGFile
   * @throws ParserConfigurationException
   * @throws IOException
   * @throws SAXException
   */
  public Replayer(TestCase tc, String sGUIFile, String sEFGFile)
      throws ParserConfigurationException, SAXException, IOException {
    super();
    this.tc = tc;
    this.sGUIFfile = sGUIFile;
    this.sEFGFfile = sEFGFile;

    // Initialize GUI object
    GUIStructure gui = (GUIStructure) IO.readObjFromFile(sGUIFile, GUIStructure.class);
    guiStructureAdapter = new GUIStructureWrapper(gui);

    // Initialize EFG object
    this.efg = (EFG) IO.readObjFromFile(sEFGFile, EFG.class);

    // Initialize EFG XML file
    DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
    domFactory.setNamespaceAware(true);
    DocumentBuilder builder;
    builder = domFactory.newDocumentBuilder();
    docGUI = builder.parse(sGUIFile);
    // docEFG = builder.parse(sEFGFile);
  }
Example #2
0
  /** Log the results of ripping. */
  @Override
  protected void onAfterExecute() {
    GUIStructure dGUIStructure = ripper.getResult();
    IO.writeObjToFile(dGUIStructure, config.getGuiFile());

    GUITARLog.log.info("-----------------------------");
    GUITARLog.log.info("OUTPUT SUMARY: ");
    GUITARLog.log.info("Number of Windows: " + dGUIStructure.getGUI().size());
    GUITARLog.log.info("GUI file:" + config.getGuiFile());
    GUITARLog.log.info("Open Component file:" + config.getLogWidgetFile());
    ComponentListType lOpenWins = ripper.getlOpenWindowComps();
    ComponentListType lCloseWins = ripper.getlCloseWindowComp();
    ObjectFactory factory = new ObjectFactory();

    LogWidget logWidget = factory.createLogWidget();
    logWidget.setOpenWindow(lOpenWins);
    logWidget.setCloseWindow(lCloseWins);

    IO.writeObjToFile(logWidget, config.getLogWidgetFile());

    // print time elapsed
    super.onAfterExecute();
  }
  /** @param args */
  public static void main(String[] args) {
    setupLog();

    try {
      if (args.length < 2) {
        String help = "";
        System.out.println(help);
      } else {

        // TODO: Make a configuration for parameters
        String PLUGIN = args[0];
        String INPUT_FILE = args[1];
        String OUTPUT_FILE = args[2];

        GUITARLog.log.info("===========================================");
        GUITARLog.log.info("GUIStructure2GraphConverter");
        GUITARLog.log.info("");
        GUITARLog.log.info("\tPlugin: \t" + PLUGIN);
        GUITARLog.log.info("\tInput file: \t" + INPUT_FILE);
        GUITARLog.log.info("\tOutput file: \t" + OUTPUT_FILE);

        GUITARLog.log.info("===========================================");

        String converterFullName = GraphConverter.class.getPackage().getName() + "." + PLUGIN;

        Class<?> converterClass = Class.forName(converterFullName);

        GraphConverter converter = (GraphConverter) converterClass.newInstance();

        Object obj = IO.readObjFromFile(INPUT_FILE, converter.getInputType());

        Object graph = converter.generate(obj);
        IO.writeObjToFile(graph, OUTPUT_FILE);

        // Debug only
        // Print out graphviz file
        if (args.length > 3) {
          GRAPHVIZ_FILE = args[3];
          // StringBuffer graphviz = ((EFGConverter) converter)
          // .printGraphviz();
          // graphviz.insert(0, "digraph " + GRAPHVIZ_FILE);
          // if (converter instanceof EFGConverter) {
          //
          // FileWriter fstream = new FileWriter(GRAPHVIZ_FILE);
          // BufferedWriter out = new BufferedWriter(fstream);
          // out.write(graphviz.toString());
          // System.out.println(graphviz);
          // out.close();
          // }
        }

        // GUITARLog.log.info("DONE");

      }
    } catch (ClassNotFoundException e) {
      System.out.println(
          "The converter can not be found. Please make ensure that the converter name is correct and the corresponding .jar file can be reached.");

    } catch (InstantiationException e) {
      System.out.println(
          "The converter is defined as an Abstract class, or an interface, or its constructor is not accessible without parameters.");
      GUITARLog.log.info("Please Report this bug");

    } catch (IllegalAccessException e) {
      GUITARLog.log.info("The converter is not accessible");

      // } catch (FileNotFoundException e) {
      // GUITARLog.log.info("Input File name is not correct ");

    } catch (Exception e) {
      e.printStackTrace();
      GUITARLog.log.info("Unknown ERROR");
    }
  }