2 package org
.eclipse
.linuxtools
.lttng
.tests
.jni
;
5 import junit
.framework
.TestCase
;
7 import org
.eclipse
.linuxtools
.lttng
.jni
.JniEvent
;
8 import org
.eclipse
.linuxtools
.lttng
.jni
.JniMarker
;
9 import org
.eclipse
.linuxtools
.lttng
.jni
.exception
.JniException
;
10 import org
.eclipse
.linuxtools
.lttng
.jni
.factory
.JniTraceFactory
;
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
= JniTraceFactory
.getJniTrace(tracepath
, printLttDebug
).requestEventByName(eventName
);
45 tmpEvent
.readNextEvent();
47 tmpMarker
= tmpEvent
.requestEventMarker();
49 catch( JniException e
) { }
54 public void testEventConstructors() {
56 JniEvent tmpEvent
= null;
58 @SuppressWarnings("unused")
59 JniMarker testMarker1
= null;
60 @SuppressWarnings("unused")
61 JniMarker testMarker2
= null;
63 // This event should be valid and will be used in test
65 tmpEvent
= JniTraceFactory
.getJniTrace(tracepath
, printLttDebug
).requestEventByName(eventName
);
67 catch( JniException e
) { }
69 // Test constructor with pointer on a correct pointer
71 testMarker1
= tmpEvent
.getParentTracefile().allocateNewJniMarker( tmpEvent
.requestEventMarker().getMarkerPtr() );
73 catch( JniException e
) {
74 fail("Construction with correct pointer failed!");
78 // Test copy constructor
80 testMarker1 = new JniMarker( tmpEvent.requestEventMarker().getMarkerPtr() );
81 testMarker2 = new JniMarker( testMarker1);
83 catch( JniException e) {
84 fail("Copy constructor failed!");
86 assertSame("JniMarker name not same after using copy constructor", testMarker1.getName() , testMarker2.getName());
91 public void testGetSet() {
93 JniMarker testMarker
= prepareMarkerToTest();
95 // Test that all Get/Set return data
96 assertNotSame("getName is empty","",testMarker
.getName() );
97 assertNotSame("getFormat is empty","",testMarker
.getFormatOverview() );
99 assertNotSame("getMarkerFieldArrayList is null",null,testMarker
.getMarkerFieldsArrayList() );
100 // Also check that the map contain a certains number of data
101 assertSame("getMarkerFieldArrayList returned an unexpected number of markers",numberOfMarkersFieldInMarker
,testMarker
.getMarkerFieldsArrayList().size() );
103 assertNotSame("getMarkerPtr is 0",0,testMarker
.getMarkerPtr() );
106 public void testPrintAndToString() {
108 JniMarker testMarker
= prepareMarkerToTest();
110 // Test printMarkerInformation
112 testMarker
.printMarkerInformation();
114 catch( Exception e
) {
115 fail("printMarkerInformation failed!");
119 assertNotSame("toString returned empty data","",testMarker
.toString() );