1 package org
.eclipse
.linuxtools
.lttng
.tests
.event
;
3 import junit
.framework
.TestCase
;
5 import org
.eclipse
.linuxtools
.lttng
.event
.LttngTimestamp
;
6 import org
.eclipse
.linuxtools
.lttng
.trace
.LTTngTextTrace
;
7 import org
.eclipse
.linuxtools
.tmf
.trace
.TmfTraceContext
;
10 Functions tested here :
11 public LttngTimestamp(TmfTimestamp newEventTime)
12 public LttngTimestamp(long newEventTime)
13 public String getSeconds()
14 public String getNanoSeconds()
15 public String toString()
18 public class LttngTimestampTest
extends TestCase
{
19 private final static String tracepath1
="traceset/trace-15316events_nolost_newformat.txt";
20 private final static boolean skipIndexing
=true;
22 private final static String firstEventTimeSecond
= "13589";
23 private final static String firstEventTimeNano
= "759412127";
24 private final static long firstEventTimeFull
= 13589759412127L;
26 private LTTngTextTrace
initializeEventStream() {
27 LTTngTextTrace tmpStream
= null;
29 tmpStream
= new LTTngTextTrace(tracepath1
, skipIndexing
);
32 fail("ERROR : Could not open " + tracepath1
+ ". Test failed!" );
39 private LttngTimestamp
prepareToTest() {
40 LttngTimestamp tmpTime
= null;
42 // This trace should be valid
44 LTTngTextTrace tmpStream
= initializeEventStream();
45 tmpTime
= (LttngTimestamp
)tmpStream
.getNextEvent( new TmfTraceContext(null, null, 0) ).getTimestamp();
48 fail("ERROR : Failed to get reference!");
54 public void testConstructors() {
55 LttngTimestamp tmpTime
= null;
56 @SuppressWarnings("unused")
57 LttngTimestamp tmpTime2
= null;
59 // Default construction with good argument
61 tmpTime
= new LttngTimestamp(1);
64 fail("Construction failed!");
69 tmpTime
= new LttngTimestamp(1);
70 tmpTime2
= new LttngTimestamp(tmpTime
);
73 fail("Construction failed!");
78 public void testGetter() {
79 LttngTimestamp tmpTime
= prepareToTest();
81 assertEquals("Time in second is wrong", firstEventTimeSecond
, tmpTime
.getSeconds() );
82 assertEquals("Time in nano second is wrong", firstEventTimeNano
, tmpTime
.getNanoSeconds() );
84 assertEquals("Full time is wrong", firstEventTimeFull
, tmpTime
.getValue() );
88 public void testToString() {
89 LttngTimestamp tmpTime
= prepareToTest();
91 // Just make sure toString() does not return null or the java reference
92 assertNotSame("toString returned null",null, tmpTime
.toString() );
93 assertNotSame("toString is not overridded!", tmpTime
.getClass().getName() + '@' + Integer
.toHexString(tmpTime
.hashCode()), tmpTime
.toString() );