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();
}
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();
}
}
}
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();
}
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();
}
Aggregations