Search in sources :

Example 1 with ApetTestSuite

use of apet.testCases.ApetTestSuite in project abstools by abstools.

the class apetHandler method callXMLParser.

private ApetTestSuite callXMLParser() {
    // TODO The xml filename should be a constant
    XMLParser parser = new XMLParser(ApetShellCommand.XML_FILE_PATH);
    ApetTestSuite suite = null;
    try {
        suite = parser.read();
        System.out.println("Test cases parsed from the xml file and stored in the APetTestSuite");
    } catch (Exception e) {
        System.out.println("aPET error: Error parsing the XML file");
    }
    return suite;
}
Also used : ApetTestSuite(apet.testCases.ApetTestSuite) XMLParser(apet.testCases.XMLParser) IOException(java.io.IOException) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 2 with ApetTestSuite

use of apet.testCases.ApetTestSuite in project abstools by abstools.

the class apetHandler method execute.

/**
 * the command has been executed, so extract the needed information
 * from the application context.
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    final Shell shellEclipse = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell();
    ApetShellCommand shell = new ApetShellCommand();
    try {
        ConsoleHandler.defaultConsole = ConsoleHandler.findCostabsConsole();
        String absFile = SourceUtils.extractResource(SourceUtils.obtainActiveEditor()).getLocation().toString();
        // Creating the costabs tmp directory
        File f = new File("//tmp//costabs//absPL");
        f.mkdirs();
        if (CostabsLink.ENTRIES_STRINGS.size() <= 0) {
            Status status = new Status(IStatus.ERROR, "costabs", 0, "At least one function or method must be selected in the outline view.", null);
            ErrorDialog.openError(shellEclipse, "aPET Error", "aPET cannot be run.", status);
        } else {
            /*OptionsDialog mDialog = new OptionsDialog (shellEclipse);
				mDialog.open();				
				if (mDialog.getReturnCode() == OptionsDialog.CANCEL) {
					ConsoleHandler.write("Don't do anything, cancelled by the user");*/
            IPreferencePage page = new ApetPreferences();
            PreferenceManager mgr = new PreferenceManager();
            IPreferenceNode node = new PreferenceNode("1", page);
            mgr.addToRoot(node);
            PreferenceDialog dialog = new PreferenceDialog(shellEclipse, mgr);
            dialog.create();
            dialog.setMessage("aPET preferences");
            dialog.open();
            if (dialog.getReturnCode() == PreferenceDialog.CANCEL) {
                return null;
            } else {
                callPrologBackend(absFile);
                shell.callAPet(CostabsLink.ENTRIES_STRINGS);
                printError(shell);
                ApetTestSuite suite = callXMLParser();
                if (translate) {
                    Model m = getABSModel(absFile);
                    generateABSUnitTests(m, suite, new File(new File(absFile).getParentFile(), absUnitOutputFile));
                }
            }
            ConsoleHandler.write(shell.getResult());
        }
    } catch (Exception e) {
        ConsoleHandler.write(shell.getError());
        e.printStackTrace(new PrintStream(ConsoleHandler.getDefault().newMessageStream()));
    }
    return null;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) PrintStream(java.io.PrintStream) PreferenceNode(org.eclipse.jface.preference.PreferenceNode) IPreferenceNode(org.eclipse.jface.preference.IPreferenceNode) ApetShellCommand(apet.console.ApetShellCommand) ApetPreferences(apet.preferences.ApetPreferences) IPreferenceNode(org.eclipse.jface.preference.IPreferenceNode) PreferenceManager(org.eclipse.jface.preference.PreferenceManager) IOException(java.io.IOException) ExecutionException(org.eclipse.core.commands.ExecutionException) Shell(org.eclipse.swt.widgets.Shell) PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) Model(abs.frontend.ast.Model) IPreferencePage(org.eclipse.jface.preference.IPreferencePage) ApetTestSuite(apet.testCases.ApetTestSuite) File(java.io.File)

Aggregations

ApetTestSuite (apet.testCases.ApetTestSuite)2 IOException (java.io.IOException)2 ExecutionException (org.eclipse.core.commands.ExecutionException)2 Model (abs.frontend.ast.Model)1 ApetShellCommand (apet.console.ApetShellCommand)1 ApetPreferences (apet.preferences.ApetPreferences)1 XMLParser (apet.testCases.XMLParser)1 File (java.io.File)1 PrintStream (java.io.PrintStream)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 IPreferenceNode (org.eclipse.jface.preference.IPreferenceNode)1 IPreferencePage (org.eclipse.jface.preference.IPreferencePage)1 PreferenceDialog (org.eclipse.jface.preference.PreferenceDialog)1 PreferenceManager (org.eclipse.jface.preference.PreferenceManager)1 PreferenceNode (org.eclipse.jface.preference.PreferenceNode)1 Shell (org.eclipse.swt.widgets.Shell)1