Monster fix: TMF model update + corresponding LTTng adaptations + JUnits
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.tests / src / org / eclipse / linuxtools / lttng / event / LttngTimestampTest.java
CommitLineData
07d9e2ee
FC
1package org.eclipse.linuxtools.lttng.event;
2
07d9e2ee
FC
3import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
4import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
28b94d61 5import junit.framework.TestCase;
07d9e2ee
FC
6
7/*
8 Functions tested here :
9 public LttngTimestamp(TmfTimestamp newEventTime)
10 public LttngTimestamp(long newEventTime)
11 public String getSeconds()
12 public String getNanoSeconds()
13 public String toString()
14 */
15
28b94d61 16public class LttngTimestampTest extends TestCase {
07d9e2ee
FC
17 private final static boolean skipIndexing=true;
18 private final static boolean waitForCompletion=true;
eddd9002 19 private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
07d9e2ee
FC
20
21 private final static String firstEventTimeSecond = "952";
22 private final static String firstEventTimeNano = "088954601";
23 private final static long firstEventTimeFull = 952088954601L;
24
25 private LTTngTrace initializeEventStream() {
26 LTTngTrace tmpStream = null;
27 try {
28 tmpStream = new LTTngTrace(tracepath1, waitForCompletion, skipIndexing);
29 }
30 catch (Exception e) {
31 fail("ERROR : Could not open " + tracepath1 + ". Test failed!" );
32 }
33
34 return tmpStream;
35 }
36
37
38 private LttngTimestamp prepareToTest() {
39 LttngTimestamp tmpTime = null;
40
41 // This trace should be valid
42 try {
43 LTTngTrace tmpStream = initializeEventStream();
44 tmpTime = (LttngTimestamp)tmpStream.parseEvent( new TmfTraceContext(null, null, 0) ).getTimestamp();
45 }
46 catch (Exception e) {
47 fail("ERROR : Failed to get reference!");
48 }
49
50 return tmpTime;
51 }
28b94d61 52
07d9e2ee
FC
53 public void testConstructors() {
54 LttngTimestamp tmpTime = null;
55 @SuppressWarnings("unused")
56 LttngTimestamp tmpTime2 = null;
57
58 // Default construction with good argument
59 try {
60 tmpTime = new LttngTimestamp(1);
61 }
62 catch( Exception e) {
63 fail("Construction failed!");
64 }
65
66 // Copy constructor
67 try {
68 tmpTime = new LttngTimestamp(1);
69 tmpTime2 = new LttngTimestamp(tmpTime);
70 }
71 catch( Exception e) {
72 fail("Construction failed!");
73 }
74 }
75
76
07d9e2ee
FC
77 public void testGetter() {
78 LttngTimestamp tmpTime = prepareToTest();
79
80 assertEquals("Time in second is wrong", firstEventTimeSecond, tmpTime.getSeconds() );
81 assertEquals("Time in nano second is wrong", firstEventTimeNano, tmpTime.getNanoSeconds() );
82
83 assertEquals("Full time is wrong", firstEventTimeFull, tmpTime.getValue() );
84 }
85
86
07d9e2ee
FC
87 public void testToString() {
88 LttngTimestamp tmpTime = prepareToTest();
89
90 // Just make sure toString() does not return null or the java reference
91 assertNotSame("toString returned null",null, tmpTime.toString() );
92 assertNotSame("toString is not overridded!", tmpTime.getClass().getName() + '@' + Integer.toHexString(tmpTime.hashCode()), tmpTime.toString() );
93 }
94
95}
This page took 0.027805 seconds and 5 git commands to generate.