1 package org
.eclipse
.linuxtools
.lttng
.event
;
3 import org
.eclipse
.linuxtools
.lttng
.trace
.LTTngTrace
;
4 import org
.eclipse
.linuxtools
.tmf
.trace
.TmfTraceContext
;
5 import junit
.framework
.TestCase
;
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()
16 public class LttngTimestampTest
extends TestCase
{
17 private final static boolean skipIndexing
=true;
18 private final static boolean waitForCompletion
=true;
19 private final static String tracepath1
="traceset/trace-618339events-1293lost-1cpu";
21 private final static String firstEventTimeSecond
= "952";
22 private final static String firstEventTimeNano
= "088954601";
23 private final static long firstEventTimeFull
= 952088954601L;
25 private LTTngTrace
initializeEventStream() {
26 LTTngTrace tmpStream
= null;
28 tmpStream
= new LTTngTrace(tracepath1
, waitForCompletion
, skipIndexing
);
31 fail("ERROR : Could not open " + tracepath1
+ ". Test failed!" );
38 private LttngTimestamp
prepareToTest() {
39 LttngTimestamp tmpTime
= null;
41 // This trace should be valid
43 LTTngTrace tmpStream
= initializeEventStream();
44 tmpTime
= (LttngTimestamp
)tmpStream
.parseEvent( new TmfTraceContext(null, null, 0) ).getTimestamp();
47 fail("ERROR : Failed to get reference!");
53 public void testConstructors() {
54 LttngTimestamp tmpTime
= null;
55 @SuppressWarnings("unused")
56 LttngTimestamp tmpTime2
= null;
58 // Default construction with good argument
60 tmpTime
= new LttngTimestamp(1);
63 fail("Construction failed!");
68 tmpTime
= new LttngTimestamp(1);
69 tmpTime2
= new LttngTimestamp(tmpTime
);
72 fail("Construction failed!");
77 public void testGetter() {
78 LttngTimestamp tmpTime
= prepareToTest();
80 assertEquals("Time in second is wrong", firstEventTimeSecond
, tmpTime
.getSeconds() );
81 assertEquals("Time in nano second is wrong", firstEventTimeNano
, tmpTime
.getNanoSeconds() );
83 assertEquals("Full time is wrong", firstEventTimeFull
, tmpTime
.getValue() );
87 public void testToString() {
88 LttngTimestamp tmpTime
= prepareToTest();
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() );