temporary re-factoring project
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.tests / src / org / eclipse / linuxtools / lttng / tests / jni / JniMarkerTest.java
1
2 package org.eclipse.linuxtools.lttng.tests.jni;
3
4 import org.eclipse.linuxtools.lttng.jni.JniEvent;
5 import org.eclipse.linuxtools.lttng.jni.JniException;
6 import org.eclipse.linuxtools.lttng.jni.JniMarker;
7 import org.eclipse.linuxtools.lttng.jni.JniTrace;
8 import org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer;
9
10 import junit.framework.TestCase;
11
12 /*
13 Functions tested here :
14 public JniMarker(JniMarker oldMarker)
15 public JniMarker(long newMarkerPtr) throws JniException
16
17 public String[] requestMarkerFieldToString()
18
19 public String getName()
20 public String getFormatOverview()
21 public ArrayList<JniMarkerField> getMarkerFieldArrayList()
22
23 public String toString()
24 public void printMarkerInformation()
25 */
26
27 public class JniMarkerTest extends TestCase
28 {
29 private final static boolean printLttDebug = false;
30
31 private final static String tracepath="traceset/trace-15316events_nolost_newformat";
32 private final static String eventName="kernel0";
33
34 private final static int numberOfMarkersFieldInMarker = 3;
35
36 private JniMarker prepareMarkerToTest() {
37
38 JniEvent tmpEvent = null;
39 JniMarker tmpMarker = null;
40
41 // This trace should be valid
42 // We will read the second event to have something interesting to test on
43 try {
44 tmpEvent = new JniTrace(tracepath, printLttDebug).requestEventByName(eventName);
45 tmpEvent.readNextEvent();
46
47 tmpMarker = tmpEvent.requestEventMarker();
48 }
49 catch( JniException e) { }
50
51 return tmpMarker;
52 }
53
54 public void testEventConstructors() {
55
56 JniEvent tmpEvent = null;
57
58 JniMarker testMarker1 = null;
59 JniMarker testMarker2 = null;
60
61 // This event should be valid and will be used in test
62 try {
63 tmpEvent = new JniTrace(tracepath, printLttDebug).requestEventByName(eventName);
64 }
65 catch( JniException e) { }
66
67 // Test constructor with pointer on a wrong pointer
68 try {
69 testMarker1 = new JniMarker( new Jni_C_Pointer(0) );
70 fail("Construction with wrong pointer should fail!");
71 }
72 catch( JniException e) {
73 }
74
75 // Test constructor with pointer on a correct pointer
76 try {
77 testMarker1 = new JniMarker( tmpEvent.requestEventMarker().getMarkerPtr() );
78 }
79 catch( JniException e) {
80 fail("Construction with correct pointer failed!");
81 }
82
83
84 // Test copy constructor
85 try {
86 testMarker1 = new JniMarker( tmpEvent.requestEventMarker().getMarkerPtr() );
87 testMarker2 = new JniMarker( testMarker1);
88 }
89 catch( JniException e) {
90 fail("Copy constructor failed!");
91 }
92
93 assertSame("JniMarker name not same after using copy constructor", testMarker1.getName() , testMarker2.getName());
94
95 }
96
97 public void testGetSet() {
98
99 JniMarker testMarker = prepareMarkerToTest();
100
101 // Test that all Get/Set return data
102 assertNotSame("getName is empty","",testMarker.getName() );
103 assertNotSame("getFormat is empty","",testMarker.getFormatOverview() );
104
105 assertNotSame("getMarkerFieldArrayList is null",null,testMarker.getMarkerFieldsArrayList() );
106 // Also check that the map contain a certains number of data
107 assertSame("getMarkerFieldArrayList returned an unexpected number of markers",numberOfMarkersFieldInMarker,testMarker.getMarkerFieldsArrayList().size() );
108
109 assertNotSame("getMarkerPtr is 0",0,testMarker.getMarkerPtr() );
110 }
111
112 public void testPrintAndToString() {
113
114 JniMarker testMarker = prepareMarkerToTest();
115
116 // Test printMarkerInformation
117 try {
118 testMarker.printMarkerInformation();
119 }
120 catch( Exception e) {
121 fail("printMarkerInformation failed!");
122 }
123
124 // Test ToString()
125 assertNotSame("toString returned empty data","",testMarker.toString() );
126
127 }
128 }
This page took 0.041431 seconds and 6 git commands to generate.