2010-01-19 Francois Chouinard <fchouinard@gmail.com>
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.tests / src / org / eclipse / linuxtools / lttng / tests / event / LttngEventReferenceTest.java
CommitLineData
03c71d1e
ASL
1package org.eclipse.linuxtools.lttng.tests.event;
2
03c71d1e 3import junit.framework.TestCase;
5fbe0b84 4
03c71d1e 5import org.eclipse.linuxtools.lttng.event.LttngEventReference;
03c71d1e 6import org.eclipse.linuxtools.lttng.trace.LTTngTextTrace;
86de1b08 7import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
03c71d1e
ASL
8
9/*
10 Functions tested here :
5fbe0b84
FC
11 public LttngEventReference(String newTracefilePath, String newTracePath)
12 public LttngEventReference(LttngEventReference oldReference)
13 public String getTracepath()
14 public void setTracepath(String tracepath)
15 public String toString()
03c71d1e
ASL
16 */
17
18public class LttngEventReferenceTest extends TestCase {
19 private final static String tracepath1="traceset/trace-15316events_nolost_newformat.txt";
20 private final static boolean skipIndexing=true;
21
22 private final static String firstEventReference = "metadata_0";
23
5fbe0b84 24
03c71d1e 25 private LTTngTextTrace initializeEventStream() {
5fbe0b84
FC
26 LTTngTextTrace tmpStream = null;
27 try {
28 tmpStream = new LTTngTextTrace(tracepath1, skipIndexing);
29 }
30 catch (Exception e) {
31 fail("ERROR : Could not open " + tracepath1 + ". Test failed!" );
32 }
33
34 return tmpStream;
35 }
36
03c71d1e
ASL
37
38 private LttngEventReference prepareToTest() {
39 LttngEventReference tmpEventRef = null;
40
41 // This trace should be valid
42 try {
43 LTTngTextTrace tmpStream = initializeEventStream();
86de1b08 44 tmpEventRef = (LttngEventReference)tmpStream.getNextEvent(new TmfTraceContext(null, null, 0) ).getReference();
03c71d1e
ASL
45 }
46 catch (Exception e) {
47 fail("ERROR : Failed to get reference!");
48 }
49
50 return tmpEventRef;
51 }
52
53 public void testConstructors() {
54 LttngEventReference testRef = null;
55 @SuppressWarnings("unused")
56 LttngEventReference testRef2 = null;
57
5fbe0b84 58 // Default construction with good argument
03c71d1e
ASL
59 try {
60 testRef = new LttngEventReference("test", "test");
61 }
62 catch( Exception e) {
63 fail("Construction failed!");
64 }
65
66 // Copy constructor
67 try {
68 testRef = new LttngEventReference("test", "test");
69 testRef2 = new LttngEventReference(testRef);
70 }
71 catch( Exception e) {
72 fail("Construction failed!");
73 }
74 }
75
76
77 public void testGetter() {
78 LttngEventReference tmpRef = prepareToTest();
79
80 assertTrue("Tracepath not what was expected!",((String)tmpRef.getValue()).contains(firstEventReference) );
81 assertEquals("Content not what expected!",firstEventReference,tmpRef.getTracepath());
82 }
83
03c71d1e
ASL
84 public void testToString() {
85 LttngEventReference tmpRef = prepareToTest();
86
87 // Just make sure toString() does not return null or the java reference
88 assertNotSame("toString returned null",null, tmpRef.toString() );
89 assertNotSame("toString is not overridded!", tmpRef.getClass().getName() + '@' + Integer.toHexString(tmpRef.hashCode()), tmpRef.toString() );
90 }
91
92}
This page took 0.028998 seconds and 5 git commands to generate.