Search in sources :

Example 11 with TestCase

use of org.eclipse.titan.log.viewer.parsers.data.TestCase in project titan.EclipsePlug-ins by eclipse.

the class OpenTextTableStatisticalViewMenuAction method run.

@Override
public void run() {
    Object element = this.selection.getFirstElement();
    if (!(element instanceof TestCase)) {
        return;
    }
    TestCase tc = (TestCase) element;
    LogFileMetaData logFileMetaData = this.statisticalView.getLogFileMetaData();
    TextTableViewHelper.open(logFileMetaData.getProjectName(), logFileMetaData.getProjectRelativePath(), tc.getStartRecordNumber());
}
Also used : TestCase(org.eclipse.titan.log.viewer.parsers.data.TestCase) LogFileMetaData(org.eclipse.titan.log.viewer.models.LogFileMetaData)

Example 12 with TestCase

use of org.eclipse.titan.log.viewer.parsers.data.TestCase in project titan.EclipsePlug-ins by eclipse.

the class TestCaseActionProvider method fillActionBars.

@Override
public void fillActionBars(final IActionBars actionBars) {
    final IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
    if (selection.size() == 1 && selection.getFirstElement() instanceof TestCase) {
        openTestCaseAction.selectionChanged(null, selection);
        actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, openTestCaseAction);
    }
}
Also used : TestCase(org.eclipse.titan.log.viewer.parsers.data.TestCase) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 13 with TestCase

use of org.eclipse.titan.log.viewer.parsers.data.TestCase in project titan.EclipsePlug-ins by eclipse.

the class TestCaseExtractor method extractTestCasesFromIndexedLogFile.

/**
 * Extracts test cases from a log file which already has a previously created index file
 *
 * @param logFile the log file to extract test cases from, can NOT be null
 * @throws IOException if file IO or parse errors occur
 * @throws ClassNotFoundException if test cases can not be read from the index file
 */
public void extractTestCasesFromIndexedLogFile(final IFile logFile) throws IOException, ClassNotFoundException {
    this.logFile = logFile;
    File indexFile = LogFileCacheHandler.getIndexFileForLogFile(logFile);
    if (indexFile.length() == 0) {
        throw new IOException();
    }
    ObjectInputStream indexFileInputStream = null;
    try {
        indexFileInputStream = new ObjectInputStream(new FileInputStream(indexFile));
        Object o = indexFileInputStream.readObject();
        if (o instanceof List) {
            List<?> testCases = (List<?>) o;
            double sizeFactor = 100.0 / testCases.size();
            int i = 0;
            for (Object testCase : testCases) {
                i++;
                if (testCase instanceof TestCase) {
                    this.currentTestCase = (TestCase) testCase;
                    this.currentProgress = (int) (sizeFactor * i);
                    addTestCase();
                } else {
                    // $NON-NLS-1$
                    throw new ClassNotFoundException("Class not found!");
                }
            }
        }
    } finally {
        IOUtils.closeQuietly(indexFileInputStream);
    }
}
Also used : TestCase(org.eclipse.titan.log.viewer.parsers.data.TestCase) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException) File(java.io.File) IFile(org.eclipse.core.resources.IFile) FileInputStream(java.io.FileInputStream) ObjectInputStream(java.io.ObjectInputStream)

Example 14 with TestCase

use of org.eclipse.titan.log.viewer.parsers.data.TestCase in project titan.EclipsePlug-ins by eclipse.

the class TestCaseExtractor method getTestCaseFromIndexFile.

/**
 * Fetches a given test case with a passed id from a previously created index file
 *
 * @param indexFile the index file to extract test cases from, can NOT be null
 * @param testCaseNumber number of the test case to fetch
 * @throws IOException if file IO or parse errors occur
 * @throws ClassNotFoundException if test cases can not be read from the index file
 */
public static TestCase getTestCaseFromIndexFile(final File indexFile, final int testCaseNumber) throws IOException, TechnicalException, ClassNotFoundException {
    ObjectInputStream indexFileInputStream = null;
    try {
        indexFileInputStream = new ObjectInputStream(new FileInputStream(indexFile));
        Object o = indexFileInputStream.readObject();
        if (o instanceof List) {
            List<?> testCases = (List<?>) o;
            // the vector is zero based but the testCase number starts numbering on 1
            // so there must be an alignment
            int testCasePosition = testCaseNumber - 1;
            if (testCases.size() < testCasePosition) {
                // $NON-NLS-1$
                throw new TechnicalException(Messages.getString("TestCaseExtractor.4"));
            }
            return (TestCase) testCases.get(testCasePosition);
        }
    } finally {
        IOUtils.closeQuietly(indexFileInputStream);
    }
    return null;
}
Also used : TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) TestCase(org.eclipse.titan.log.viewer.parsers.data.TestCase) ArrayList(java.util.ArrayList) List(java.util.List) FileInputStream(java.io.FileInputStream) ObjectInputStream(java.io.ObjectInputStream)

Example 15 with TestCase

use of org.eclipse.titan.log.viewer.parsers.data.TestCase in project titan.EclipsePlug-ins by eclipse.

the class TestCaseExtractor method addCrashedTestCase.

private void addCrashedTestCase() {
    if (!this.crashed) {
        this.crashed = true;
        this.testCaseVector.add(new TestCase(logFile, -1, Messages.getString("TestCaseExtractor.3"), this.filePointer, Constants.VERDICT_CRASHED, this.recordNumber, this.recordNumber));
    }
}
Also used : TestCase(org.eclipse.titan.log.viewer.parsers.data.TestCase)

Aggregations

TestCase (org.eclipse.titan.log.viewer.parsers.data.TestCase)20 IFile (org.eclipse.core.resources.IFile)10 File (java.io.File)7 IOException (java.io.IOException)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)5 TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)5 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)5 ArrayList (java.util.ArrayList)4 CoreException (org.eclipse.core.runtime.CoreException)4 UserException (org.eclipse.titan.log.viewer.exceptions.UserException)4 PreferencesHolder (org.eclipse.titan.log.viewer.preferences.PreferencesHolder)4 IViewReference (org.eclipse.ui.IViewReference)4 ParseException (java.text.ParseException)3 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 TestCaseExtractor (org.eclipse.titan.log.viewer.extractors.TestCaseExtractor)3 LogFileMetaData (org.eclipse.titan.log.viewer.models.LogFileMetaData)3 LogRecordIndex (org.eclipse.titan.log.viewer.models.LogRecordIndex)3 Parser (org.eclipse.titan.log.viewer.parsers.Parser)3 StatisticalData (org.eclipse.titan.log.viewer.views.details.StatisticalData)3