Search in sources :

Example 1 with SyslogTrace

use of org.eclipse.tracecompass.tmf.tests.stubs.trace.text.SyslogTrace in project tracecompass by tracecompass.

the class TextTraceTest method testInitTrace.

@Test
public void testInitTrace() throws Exception {
    URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(PATH), null);
    String path = FileLocator.toFileURL(location).toURI().getPath();
    SyslogTrace trace = new SyslogTrace();
    IResource resource = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(PATH));
    trace.initTrace(resource, path, SyslogEvent.class);
    assertEquals("getEventType", SyslogEvent.class, trace.getEventType());
    assertEquals("getPath", fTestFile.toURI().getPath(), trace.getPath());
    assertEquals("getName", NAME, trace.getName());
    assertEquals("getCacheSize", 100, trace.getCacheSize());
    trace.dispose();
}
Also used : Path(org.eclipse.core.runtime.Path) SyslogTrace(org.eclipse.tracecompass.tmf.tests.stubs.trace.text.SyslogTrace) URL(java.net.URL) IResource(org.eclipse.core.resources.IResource) Test(org.junit.Test)

Example 2 with SyslogTrace

use of org.eclipse.tracecompass.tmf.tests.stubs.trace.text.SyslogTrace in project tracecompass by tracecompass.

the class TextTraceTest method setUp.

// ------------------------------------------------------------------------
// Housekeeping
// ------------------------------------------------------------------------
@BeforeClass
public static void setUp() throws Exception {
    IEclipsePreferences defaultPreferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
    defaultPreferences.put(ITmfTimePreferencesConstants.DATIME, "MMM d HH:mm:ss");
    defaultPreferences.put(ITmfTimePreferencesConstants.SUBSEC, ITmfTimePreferencesConstants.SUBSEC_NO_FMT);
    defaultPreferences.put(ITmfTimePreferencesConstants.LOCALE, Locale.US.toLanguageTag());
    TmfTimestampFormat.updateDefaultFormats();
    if (fTrace == null) {
        try {
            URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(PATH), null);
            URI uri = FileLocator.toFileURL(location).toURI();
            fTestFile = new File(uri);
            fTrace = new SyslogTrace();
            IResource resource = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(PATH));
            fTrace.initTrace(resource, uri.getPath(), SyslogEvent.class);
            // Dummy request to force the trace indexing
            TmfEventRequest request = new TmfEventRequest(SyslogEvent.class, TmfTimeRange.ETERNITY, 0, ITmfEventRequest.ALL_DATA, ExecutionType.FOREGROUND) {
            };
            fTrace.sendRequest(request);
            request.waitForCompletion();
        } catch (URISyntaxException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : Path(org.eclipse.core.runtime.Path) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) SyslogTrace(org.eclipse.tracecompass.tmf.tests.stubs.trace.text.SyslogTrace) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) URI(java.net.URI) File(java.io.File) ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) URL(java.net.URL) IResource(org.eclipse.core.resources.IResource) BeforeClass(org.junit.BeforeClass)

Example 3 with SyslogTrace

use of org.eclipse.tracecompass.tmf.tests.stubs.trace.text.SyslogTrace in project tracecompass by tracecompass.

the class TextTraceTest method testValidation.

@Test
public void testValidation() throws URISyntaxException, IOException {
    SyslogTrace trace = new SyslogTrace();
    String validTracePath = fTestFile.getAbsolutePath();
    IStatus status = trace.validate(null, validTracePath);
    assertTrue(status.isOK());
    assertTrue(status instanceof TraceValidationStatus);
    assertEquals(185, ((TraceValidationStatus) status).getConfidence());
    URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(OTHER_PATH), null);
    URI uri = FileLocator.toFileURL(location).toURI();
    File otherFile = new File(uri);
    String validNoConfidenceTrace = otherFile.getAbsolutePath();
    status = trace.validate(null, validNoConfidenceTrace);
    assertTrue(status instanceof TraceValidationStatus);
    assertEquals(0, ((TraceValidationStatus) status).getConfidence());
    assertTrue(status.isOK());
    String invalidTrace = fTestFile.getParentFile().getAbsolutePath();
    status = trace.validate(null, invalidTrace);
    assertFalse(status.isOK());
    trace.dispose();
}
Also used : Path(org.eclipse.core.runtime.Path) IStatus(org.eclipse.core.runtime.IStatus) TraceValidationStatus(org.eclipse.tracecompass.tmf.core.trace.TraceValidationStatus) SyslogTrace(org.eclipse.tracecompass.tmf.tests.stubs.trace.text.SyslogTrace) URI(java.net.URI) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 4 with SyslogTrace

use of org.eclipse.tracecompass.tmf.tests.stubs.trace.text.SyslogTrace in project tracecompass by tracecompass.

the class TextTraceTest method testEmptyConstructor.

// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
@Test
public void testEmptyConstructor() {
    SyslogTrace trace = new SyslogTrace();
    assertEquals("getEventType", null, trace.getEventType());
    assertEquals("getPath", null, trace.getPath());
    assertEquals("getName", "", trace.getName());
    assertEquals("getCacheSize", 100, trace.getCacheSize());
    ITmfTimestamp initRange = TmfTimestamp.fromSeconds(60);
    assertEquals("getInitialRangeOffset", initRange, trace.getInitialRangeOffset());
    trace.dispose();
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) SyslogTrace(org.eclipse.tracecompass.tmf.tests.stubs.trace.text.SyslogTrace) Test(org.junit.Test)

Aggregations

SyslogTrace (org.eclipse.tracecompass.tmf.tests.stubs.trace.text.SyslogTrace)4 URL (java.net.URL)3 Path (org.eclipse.core.runtime.Path)3 Test (org.junit.Test)3 File (java.io.File)2 URI (java.net.URI)2 IResource (org.eclipse.core.resources.IResource)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 IStatus (org.eclipse.core.runtime.IStatus)1 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)1 ITmfEventRequest (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)1 TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)1 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)1 TraceValidationStatus (org.eclipse.tracecompass.tmf.core.trace.TraceValidationStatus)1 BeforeClass (org.junit.BeforeClass)1