1 package org
.eclipse
.linuxtools
.lttng
.core
.tests
.event
;
6 import junit
.framework
.TestCase
;
8 import org
.eclipse
.core
.runtime
.FileLocator
;
9 import org
.eclipse
.core
.runtime
.Path
;
10 import org
.eclipse
.linuxtools
.lttng
.core
.event
.LttngEventType
;
11 import org
.eclipse
.linuxtools
.lttng
.core
.tests
.LTTngCoreTestPlugin
;
12 import org
.eclipse
.linuxtools
.lttng
.core
.trace
.LTTngTextTrace
;
13 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfContext
;
16 Functions tested here :
17 public LttngEventType()
18 public LttngEventType(String thisTracefileName, Long thisCpuId, String thisMarkerName, String[] thisMarkerfieldsName)
19 public LttngEventType(LttngEventType oldType)
21 public String getTracefileName()
22 public Long getCpuId()
23 public String getMarkerName()
25 public String toString()
28 @SuppressWarnings("nls")
29 public class LttngEventTypeTest
extends TestCase
{
30 private final static String tracepath1
="traceset/trace-15316events_nolost_newformat.txt";
31 private final static boolean skipIndexing
=true;
33 private final static String firstEventChannel
= "metadata";
34 private final static long firstEventCpu
= 0;
35 private final static String firstEventMarker
= "core_marker_id";
37 private static LTTngTextTrace testStream
= null;
38 private LTTngTextTrace
initializeEventStream() {
39 if (testStream
== null) {
41 URL location
= FileLocator
.find(LTTngCoreTestPlugin
.getPlugin().getBundle(), new Path(tracepath1
), null);
42 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
43 LTTngTextTrace tmpStream
= new LTTngTextTrace(testfile
.getPath(), skipIndexing
);
44 testStream
= tmpStream
;
47 System
.out
.println("ERROR : Could not open " + tracepath1
);
52 testStream
.seekEvent(0);
58 private LttngEventType
prepareToTest() {
59 LttngEventType tmpEventType
= null;
61 // This trace should be valid
63 LTTngTextTrace tmpStream
= initializeEventStream();
64 tmpEventType
= (LttngEventType
)tmpStream
.getNextEvent( new TmfContext(null, 0) ).getType();
67 fail("ERROR : Failed to get reference!");
73 public void testConstructors() {
74 LttngEventType tmpEventType
= null;
75 @SuppressWarnings("unused")
76 LttngEventType tmpEventType2
= null;
78 // Default construction, no argument
80 tmpEventType
= new LttngEventType();
83 fail("Construction failed!");
86 // Default construction with good arguments
88 tmpEventType
= new LttngEventType("test", 0L, "test", 0, new String
[1]);
91 fail("Construction failed!");
96 tmpEventType
= new LttngEventType("test", 0L, "test", 0, new String
[1]);
97 tmpEventType2
= new LttngEventType(tmpEventType
);
100 fail("Construction failed!");
105 public void testGetter() {
106 LttngEventType tmpEventType
= prepareToTest();
108 assertTrue("Channel name not what was expected!",firstEventChannel
.equals((String
)tmpEventType
.getTracefileName()) );
109 assertTrue("Cpu Id not what was expected!",firstEventCpu
== tmpEventType
.getCpuId() );
110 assertTrue("Marker Name not what was expected!",firstEventMarker
.equals((String
)tmpEventType
.getMarkerName()) );
111 // Just test the non-nullity of labels
112 assertNotSame("getLabels returned null",null, tmpEventType
.getLabels() );
115 public void testToString() {
116 LttngEventType tmpEventType
= prepareToTest();
118 // Just make sure toString() does not return null or the java reference
119 assertNotSame("toString returned null",null, tmpEventType
.toString() );
120 assertNotSame("toString is not overridded!", tmpEventType
.getClass().getName() + '@' + Integer
.toHexString(tmpEventType
.hashCode()), tmpEventType
.toString() );