Search in sources :

Example 1 with ExecutedTestcase

use of org.eclipse.titan.executor.views.testexecution.ExecutedTestcase in project titan.EclipsePlug-ins by eclipse.

the class JniExecutor method batchedInsertNotify.

/**
 * Inserts a lists of messages into the notifications view in a batched manner
 * <p>
 * A list of String arrays issued to store every data reported regarding the message in a undecoded way. On this way if a data is not needed we
 * don't need to decode it.
 *
 * @param s the list of String arrays.
 */
@Override
public void batchedInsertNotify(final ArrayList<String[]> s) {
    if (loggingIsEnabled && consoleLogging) {
        for (String[] sv : s) {
            consoleStream.println(sv[2] + ": " + sv[4]);
        }
    }
    List<String> times = new ArrayList<String>(s.size());
    List<Notification> tempNotifications = new ArrayList<Notification>(s.size());
    if (severityLevelExtraction) {
        int severity;
        for (String[] value : s) {
            severity = Integer.parseInt(value[3]);
            Formatter formatter = new Formatter();
            formatter.format(DATETIMEFORMAT, new Date(Long.parseLong(value[0]) * 1000), Long.valueOf(value[1]));
            times.add(formatter.toString());
            tempNotifications.add(new Notification(formatter.toString(), SeverityResolver.getSeverityString(severity), value[2], value[4]));
            formatter.close();
        }
    } else {
        for (String[] value : s) {
            Formatter formatter = new Formatter();
            formatter.format(DATETIMEFORMAT, new Date(Long.parseLong(value[0]) * 1000), Long.valueOf(value[1]));
            times.add(formatter.toString());
            tempNotifications.add(new Notification(formatter.toString(), EMPTY_STRING, value[2], value[4]));
            formatter.close();
        }
    }
    addNotifications(tempNotifications);
    if (verdictExtraction) {
        for (int i = 0; i < s.size(); i++) {
            if (executionFinishedMatcher.reset(s.get(i)[4]).matches()) {
                String reason = executionFinishedMatcher.group(2);
                if (reasonMatcher.reset(reason).matches()) {
                    executedTests.add(new ExecutedTestcase(times.get(i), executionFinishedMatcher.group(1), reasonMatcher.group(1), reasonMatcher.group(2)));
                } else {
                    executedTests.add(new ExecutedTestcase(times.get(i), executionFinishedMatcher.group(1), executionFinishedMatcher.group(2), ""));
                }
            }
        }
    }
}
Also used : ExecutedTestcase(org.eclipse.titan.executor.views.testexecution.ExecutedTestcase) Formatter(java.util.Formatter) ArrayList(java.util.ArrayList) Notification(org.eclipse.titan.executor.views.notification.Notification) Date(java.util.Date)

Example 2 with ExecutedTestcase

use of org.eclipse.titan.executor.views.testexecution.ExecutedTestcase in project titan.EclipsePlug-ins by eclipse.

the class SingleExecutor method processConsoleOutput.

/**
 * Processes the output of the Main Controller
 * <p>
 * Note that the output is not reported in full lines.
 *
 * @param text the newly reported text
 *
 * @see #readFullLineOnly(BufferedReader)
 */
private void processConsoleOutput(final String text) {
    builder.append(text);
    StringReader reader = new StringReader(builder.toString());
    BufferedReader stdout = new BufferedReader(reader);
    fastOffset = 0;
    readFullLineOnly(stdout);
    while (null != fastLine) {
        if (verdictExtraction && (executionFinished.reset(fastLine).matches())) {
            String reason = executionFinished.group(2);
            if (reasonMatcher.reset(reason).matches()) {
                executedTests.add(new ExecutedTestcase((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), executionFinished.group(1), reasonMatcher.group(1), reasonMatcher.group(2)));
            } else {
                executedTests.add(new ExecutedTestcase((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), executionFinished.group(1), executionFinished.group(2), ""));
            }
            if (project == null) {
                return;
            }
            try {
                project.refreshLocal(IResource.DEPTH_INFINITE, null);
            } catch (CoreException e) {
                ErrorReporter.logExceptionStackTrace(e);
            }
        }
        addNotification(new Notification((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), "", "", fastLine));
        builder.delete(0, fastOffset);
        if (Activator.getMainView() != null) {
            Activator.getMainView().refreshIfSelected(mainControllerRoot);
        } else {
            TestExecutionView.refreshInput(this);
        }
        fastOffset = 0;
        readFullLineOnly(stdout);
    }
    try {
        stdout.close();
    } catch (IOException e) {
        ErrorReporter.logExceptionStackTrace(e);
    }
    reader.close();
}
Also used : ExecutedTestcase(org.eclipse.titan.executor.views.testexecution.ExecutedTestcase) CoreException(org.eclipse.core.runtime.CoreException) Formatter(java.util.Formatter) StringReader(java.io.StringReader) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) Date(java.util.Date) Notification(org.eclipse.titan.executor.views.notification.Notification)

Example 3 with ExecutedTestcase

use of org.eclipse.titan.executor.views.testexecution.ExecutedTestcase in project titan.EclipsePlug-ins by eclipse.

the class JniExecutor method insertNotify.

/**
 * Inserts a notification message into the notifications view.
 *
 * @param time the MainController reported time, when the notification message was created
 * @param source the source line info of the notification message
 * @param severity the severity of the message
 * @param msg the message to be shown
 */
@Override
public void insertNotify(final Timeval time, final String source, final int severity, final String msg) {
    if (loggingIsEnabled && consoleLogging) {
        consoleStream.println(source + ": " + msg);
    }
    Formatter formatter = new Formatter();
    formatter.format(DATETIMEFORMAT, new Date(time.tv_sec * 1000), time.tv_usec);
    if (severityLevelExtraction) {
        addNotification(new Notification(formatter.toString(), SeverityResolver.getSeverityString(severity), source, msg));
    } else {
        addNotification(new Notification(formatter.toString(), EMPTY_STRING, source, msg));
    }
    if (verdictExtraction && executionFinishedMatcher.reset(msg).matches()) {
        String reason = executionFinishedMatcher.group(2);
        if (reasonMatcher.reset(reason).matches()) {
            executedTests.add(new ExecutedTestcase(formatter.toString(), executionFinishedMatcher.group(1), reasonMatcher.group(1), reasonMatcher.group(2)));
        } else {
            executedTests.add(new ExecutedTestcase(formatter.toString(), executionFinishedMatcher.group(1), executionFinishedMatcher.group(2), ""));
        }
    }
}
Also used : ExecutedTestcase(org.eclipse.titan.executor.views.testexecution.ExecutedTestcase) Formatter(java.util.Formatter) Date(java.util.Date) Notification(org.eclipse.titan.executor.views.notification.Notification)

Aggregations

Date (java.util.Date)3 Formatter (java.util.Formatter)3 Notification (org.eclipse.titan.executor.views.notification.Notification)3 ExecutedTestcase (org.eclipse.titan.executor.views.testexecution.ExecutedTestcase)3 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 CoreException (org.eclipse.core.runtime.CoreException)1