1 package org
.eclipse
.linuxtools
.lttng
.core
.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
.core
.event
.LttngEventType
;
10 import org
.eclipse
.linuxtools
.lttng
.core
.tests
.LTTngCoreTestPlugin
;
11 import org
.eclipse
.linuxtools
.lttng
.core
.trace
.LTTngTextTrace
;
12 import org
.eclipse
.linuxtools
.tmf
.core
.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 @SuppressWarnings("nls")
28 public class LttngEventTypeTest
extends TestCase
{
29 private final static String tracepath1
="traceset/trace-15316events_nolost_newformat.txt";
30 private final static boolean skipIndexing
=true;
32 private final static String firstEventChannel
= "metadata";
33 private final static long firstEventCpu
= 0;
34 private final static String firstEventMarker
= "core_marker_id";
36 private static LTTngTextTrace testStream
= null;
37 private LTTngTextTrace
initializeEventStream() {
38 if (testStream
== null) {
40 URL location
= FileLocator
.find(LTTngCoreTestPlugin
.getPlugin().getBundle(), new Path(tracepath1
), null);
41 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
42 LTTngTextTrace tmpStream
= new LTTngTextTrace(testfile
.getPath(), skipIndexing
);
43 testStream
= tmpStream
;
46 System
.out
.println("ERROR : Could not open " + tracepath1
);
51 testStream
.seekEvent(0);
57 private LttngEventType
prepareToTest() {
58 LttngEventType tmpEventType
= null;
60 // This trace should be valid
62 LTTngTextTrace tmpStream
= initializeEventStream();
63 tmpEventType
= (LttngEventType
)tmpStream
.getNextEvent( new TmfContext(null, 0) ).getType();
66 fail("ERROR : Failed to get reference!");
72 public void testConstructors() {
73 LttngEventType tmpEventType
= null;
74 @SuppressWarnings("unused")
75 LttngEventType tmpEventType2
= null;
77 // Default construction, no argument
79 tmpEventType
= new LttngEventType();
82 fail("Construction failed!");
85 // Default construction with good arguments
87 tmpEventType
= new LttngEventType("test", 0L, "test", 0, new String
[1]);
90 fail("Construction failed!");
95 tmpEventType
= new LttngEventType("test", 0L, "test", 0, new String
[1]);
96 tmpEventType2
= new LttngEventType(tmpEventType
);
99 fail("Construction failed!");
104 public void testGetter() {
105 LttngEventType tmpEventType
= prepareToTest();
107 assertTrue("Channel name not what was expected!",firstEventChannel
.equals((String
)tmpEventType
.getTracefileName()) );
108 assertTrue("Cpu Id not what was expected!",firstEventCpu
== tmpEventType
.getCpuId() );
109 assertTrue("Marker Name not what was expected!",firstEventMarker
.equals((String
)tmpEventType
.getMarkerName()) );
110 // Just test the non-nullity of labels
111 assertNotSame("getLabels returned null",null, tmpEventType
.getLabels() );
114 public void testToString() {
115 LttngEventType tmpEventType
= prepareToTest();
117 // Just make sure toString() does not return null or the java reference
118 assertNotSame("toString returned null",null, tmpEventType
.toString() );
119 assertNotSame("toString is not overridded!", tmpEventType
.getClass().getName() + '@' + Integer
.toHexString(tmpEventType
.hashCode()), tmpEventType
.toString() );