2 package org
.eclipse
.linuxtools
.lttng
.tests
.jni
;
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
;
10 import junit
.framework
.TestCase
;
13 Functions tested here :
14 public JniMarker(JniMarker oldMarker)
15 public JniMarker(long newMarkerPtr) throws JniException
17 public String[] requestMarkerFieldToString()
19 public String getName()
20 public String getFormatOverview()
21 public ArrayList<JniMarkerField> getMarkerFieldArrayList()
23 public String toString()
24 public void printMarkerInformation()
27 public class JniMarkerTest
extends TestCase
29 private final static boolean printLttDebug
= false;
31 private final static String tracepath
="traceset/trace-15316events_nolost_newformat";
32 private final static String eventName
="kernel0";
34 private final static int numberOfMarkersFieldInMarker
= 3;
36 private JniMarker
prepareMarkerToTest() {
38 JniEvent tmpEvent
= null;
39 JniMarker tmpMarker
= null;
41 // This trace should be valid
42 // We will read the second event to have something interesting to test on
44 tmpEvent
= new JniTrace(tracepath
, printLttDebug
).requestEventByName(eventName
);
45 tmpEvent
.readNextEvent();
47 tmpMarker
= tmpEvent
.requestEventMarker();
49 catch( JniException e
) { }
54 public void testEventConstructors() {
56 JniEvent tmpEvent
= null;
58 JniMarker testMarker1
= null;
59 JniMarker testMarker2
= null;
61 // This event should be valid and will be used in test
63 tmpEvent
= new JniTrace(tracepath
, printLttDebug
).requestEventByName(eventName
);
65 catch( JniException e
) { }
67 // Test constructor with pointer on a wrong pointer
69 testMarker1
= new JniMarker( new Jni_C_Pointer(0) );
70 fail("Construction with wrong pointer should fail!");
72 catch( JniException e
) {
75 // Test constructor with pointer on a correct pointer
77 testMarker1
= new JniMarker( tmpEvent
.requestEventMarker().getMarkerPtr() );
79 catch( JniException e
) {
80 fail("Construction with correct pointer failed!");
84 // Test copy constructor
86 testMarker1
= new JniMarker( tmpEvent
.requestEventMarker().getMarkerPtr() );
87 testMarker2
= new JniMarker( testMarker1
);
89 catch( JniException e
) {
90 fail("Copy constructor failed!");
93 assertSame("JniMarker name not same after using copy constructor", testMarker1
.getName() , testMarker2
.getName());
97 public void testGetSet() {
99 JniMarker testMarker
= prepareMarkerToTest();
101 // Test that all Get/Set return data
102 assertNotSame("getName is empty","",testMarker
.getName() );
103 assertNotSame("getFormat is empty","",testMarker
.getFormatOverview() );
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() );
109 assertNotSame("getMarkerPtr is 0",0,testMarker
.getMarkerPtr() );
112 public void testPrintAndToString() {
114 JniMarker testMarker
= prepareMarkerToTest();
116 // Test printMarkerInformation
118 testMarker
.printMarkerInformation();
120 catch( Exception e
) {
121 fail("printMarkerInformation failed!");
125 assertNotSame("toString returned empty data","",testMarker
.toString() );