1 package org
.eclipse
.linuxtools
.lttng
.tests
.event
;
6 import junit
.framework
.TestCase
;
7 import org
.eclipse
.core
.runtime
.FileLocator
;
8 import org
.eclipse
.core
.runtime
.Path
;
9 import org
.eclipse
.linuxtools
.lttng
.event
.LttngEventType
;
10 import org
.eclipse
.linuxtools
.lttng
.tests
.LTTngCoreTestPlugin
;
11 import org
.eclipse
.linuxtools
.lttng
.trace
.LTTngTextTrace
;
12 import org
.eclipse
.linuxtools
.tmf
.trace
.TmfContext
;
15 Functions tested here :
16 public LttngEventType()
17 public LttngEventType(String thisTracefileName, Long thisCpuId, String thisMarkerName, String[] thisMarkerfieldsName)
18 public LttngEventType(LttngEventType oldType)
20 public String getTracefileName()
21 public Long getCpuId()
22 public String getMarkerName()
24 public String toString()
27 public class LttngEventTypeTest
extends TestCase
{
28 private final static String tracepath1
="traceset/trace-15316events_nolost_newformat.txt";
29 private final static boolean skipIndexing
=true;
31 private final static String firstEventChannel
= "metadata";
32 private final static long firstEventCpu
= 0;
33 private final static String firstEventMarker
= "core_marker_id";
35 private static LTTngTextTrace testStream
= null;
36 private LTTngTextTrace
initializeEventStream() {
37 if (testStream
== null) {
39 URL location
= FileLocator
.find(LTTngCoreTestPlugin
.getPlugin().getBundle(), new Path(tracepath1
), null);
40 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
41 LTTngTextTrace tmpStream
= new LTTngTextTrace(testfile
.getPath(), skipIndexing
);
42 testStream
= tmpStream
;
45 System
.out
.println("ERROR : Could not open " + tracepath1
);
50 testStream
.seekEvent(0);
56 private LttngEventType
prepareToTest() {
57 LttngEventType tmpEventType
= null;
59 // This trace should be valid
61 LTTngTextTrace tmpStream
= initializeEventStream();
62 tmpEventType
= (LttngEventType
)tmpStream
.getNextEvent( new TmfContext(null, 0) ).getType();
65 fail("ERROR : Failed to get reference!");
71 public void testConstructors() {
72 LttngEventType tmpEventType
= null;
73 @SuppressWarnings("unused")
74 LttngEventType tmpEventType2
= null;
76 // Default construction, no argument
78 tmpEventType
= new LttngEventType();
81 fail("Construction failed!");
84 // Default construction with good arguments
86 tmpEventType
= new LttngEventType("test", 0L, "test", new String
[1]);
89 fail("Construction failed!");
94 tmpEventType
= new LttngEventType("test", 0L, "test", new String
[1]);
95 tmpEventType2
= new LttngEventType(tmpEventType
);
98 fail("Construction failed!");
103 public void testGetter() {
104 LttngEventType tmpEventType
= prepareToTest();
106 assertTrue("Channel name not what was expected!",firstEventChannel
.equals((String
)tmpEventType
.getTracefileName()) );
107 assertTrue("Cpu Id not what was expected!",firstEventCpu
== tmpEventType
.getCpuId() );
108 assertTrue("Marker Name not what was expected!",firstEventMarker
.equals((String
)tmpEventType
.getMarkerName()) );
109 // Just test the non-nullity of labels
110 assertNotSame("getLabels returned null",null, tmpEventType
.getLabels() );
113 public void testToString() {
114 LttngEventType tmpEventType
= prepareToTest();
116 // Just make sure toString() does not return null or the java reference
117 assertNotSame("toString returned null",null, tmpEventType
.toString() );
118 assertNotSame("toString is not overridded!", tmpEventType
.getClass().getName() + '@' + Integer
.toHexString(tmpEventType
.hashCode()), tmpEventType
.toString() );